import { Stack } from 'expo-router';
import * as React from 'react';
import { View } from 'react-native';
import Animated, { FadeIn } from 'react-native-reanimated';
import { ActivityIndicator } from '@/components/nativewindui/ActivityIndicator';
import { Button } from '@/components/nativewindui/Button';
import { Icon } from '../Icon';
import { Text } from '@/components/nativewindui/Text';
export default function ButtonScreen() {
const [isLoading, setIsLoading] = React.useState(false);
return (
<>
<Stack.Screen options={{ title: 'Button' }} />
<View className="flex-1 items-center justify-center gap-8">
<Button>
<Icon name="play.fill" className="ios:size-4 text-white" />
<Text>Primary</Text>
</Button>
<Button variant="secondary">
<Text>Secondary</Text>
</Button>
<Button
onPress={() => {
setIsLoading((prev) => !prev);
}}
variant="tonal">
{isLoading && (
<Animated.View entering={FadeIn.delay(200)}>
<ActivityIndicator size="small" />
</Animated.View>
)}
<Text>Tonal</Text>
</Button>
<Button variant="plain">
<Text>Plain</Text>
</Button>
<Button variant="tonal" size="icon">
<Icon name="heart.fill" className="ios:text-primary text-foreground size-5" />
</Button>
</View>
</>
);
}
npx nwui-cli@latest add button
import { Button } from '@/components/nativewindui/Button';
<Button>
<Text>Press me</Text>
</Button>
Button
Inherits all the props from React Native's Pressable component.
Prop | Type | Default | Description |
---|---|---|---|
variant | 'primary' | 'secondary' | 'tonal' | 'plain' | 'primary' | The visual style of the button. Defaults to "primary". |
size | 'none' | 'sm' | 'md' | 'lg' | 'icon' | 'md' | The size of the button. Defaults to "md". |
androidRootClassName | string | ANDROID ONLY: The class name of the root responsible for hiding the ripple overflow. |