--- name: gluestack-ui-setup description: Gluestack-ui component library setup and usage. Use when implementing pre-built accessible components. --- # Gluestack-ui Setup Skill This skill covers Gluestack-ui component library for React Native. ## When to Use Use this skill when: - Need pre-built accessible components - Implementing forms with inputs, selects, etc. - Building modals, tooltips, popovers - Want shadcn/ui-like experience for mobile ## Core Principle **ACCESSIBLE BY DEFAULT** - Gluestack components are built with accessibility in mind. ## Installation ```bash npx gluestack-ui init ``` Follow the prompts to configure: - Style engine (NativeWind recommended) - TypeScript - Path aliases ## Available Components ### Form Components ```typescript import { Input, InputField, InputSlot, InputIcon, } from '@gluestack-ui/themed'; ``` ### Button ```typescript import { Button, ButtonText, ButtonIcon } from '@gluestack-ui/themed'; ``` ### Select ```typescript import { Select, SelectTrigger, SelectInput, SelectPortal, SelectBackdrop, SelectContent, SelectItem, } from '@gluestack-ui/themed'; ``` ### Checkbox ```typescript import { Checkbox, CheckboxIndicator, CheckboxIcon, CheckboxLabel, } from '@gluestack-ui/themed'; import { CheckIcon } from 'lucide-react-native'; I agree to terms ``` ### Modal ```typescript import { Modal, ModalBackdrop, ModalContent, ModalHeader, ModalBody, ModalFooter, ModalCloseButton, } from '@gluestack-ui/themed'; const [showModal, setShowModal] = useState(false); setShowModal(false)}> Modal Title Modal content goes here ``` ### Toast ```typescript import { useToast, Toast, ToastTitle, ToastDescription } from '@gluestack-ui/themed'; function Component(): React.ReactElement { const toast = useToast(); const showToast = () => { toast.show({ placement: 'top', render: ({ id }) => ( Success! Your action was completed. ), }); }; return ( ); } ``` ### Alert ```typescript import { Alert, AlertIcon, AlertText } from '@gluestack-ui/themed'; import { InfoIcon } from 'lucide-react-native'; This is an informational alert. Something went wrong! ``` ## Combining with NativeWind ```typescript import { Button, ButtonText } from '@gluestack-ui/themed'; // Use className for additional styling ``` ## Form Example ```typescript import { View, Text } from 'react-native'; import { Input, InputField, Button, ButtonText, FormControl, FormControlLabel, FormControlLabelText, FormControlError, FormControlErrorText, } from '@gluestack-ui/themed'; import { useForm, Controller } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; import { z } from 'zod'; const schema = z.object({ email: z.string().email('Invalid email'), password: z.string().min(8, 'Password must be at least 8 characters'), }); type FormData = z.infer; export function LoginForm(): React.ReactElement { const { control, handleSubmit, formState: { errors } } = useForm({ resolver: zodResolver(schema), }); const onSubmit = (data: FormData) => { console.log(data); }; return ( Email ( )} /> {errors.email?.message} Password ( )} /> {errors.password?.message} ); } ``` ## Theming ```typescript // gluestack-ui.config.ts import { config } from '@gluestack-ui/config'; export default { ...config, tokens: { ...config.tokens, colors: { ...config.tokens.colors, primary500: '#3B82F6', primary600: '#2563EB', }, }, }; ``` ## Notes - Gluestack components work seamlessly with NativeWind - All components support accessibility attributes - Use FormControl for form validation feedback - Toast requires ToastProvider at app root - Modal requires OverlayProvider for proper rendering