import { Text } from '~/components/nativewindui/Text';
import { Button } from '~/components/nativewindui/Button';
import { Icon } from '@roninoss/icons';
import { Stack } from 'expo-router';
import * as React from 'react';
import { Platform, View } from 'react-native';
import Animated, { FadeIn } from 'react-native-reanimated';
import { ActivityIndicator } from '~/components/nativewindui/ActivityIndicator';
import { useColorScheme } from '~/lib/useColorScheme';
export default function ButtonScreen() {
const { colors } = useColorScheme();
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" color="white" size={21} />
<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"
color={Platform.OS === 'ios' ? colors.primary : colors.foreground}
size={21}
/>
</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. |