component. -->
Demo
Shows an input component.
npx @react-native-reusables/cli@latest add input
Copy/paste the following code to ~/components/ui/input.tsx
~/components/ui/input.tsx
import * as React from 'react';import { TextInput, type TextInputProps } from 'react-native';import { cn } from '~/lib/utils'; const Input = React.forwardRef<React.ElementRef<typeof TextInput>, TextInputProps>( ({ className, placeholderClassName, ...props }, ref) => { return ( <TextInput ref={ref} className={cn( 'web:flex h-10 native:h-12 web:w-full rounded-md border border-input bg-background px-3 web:py-2 text-base lg:text-sm native:text-lg native:leading-[1.25] text-foreground placeholder:text-muted-foreground web:ring-offset-background file:border-0 file:bg-transparent file:font-medium web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2', props.editable === false && 'opacity-50 web:cursor-not-allowed', className )} placeholderClassName={cn('text-muted-foreground', placeholderClassName)} {...props} /> ); }); Input.displayName = 'Input'; export { Input };
import { Input } from '~/components/ui/input';import { Text } from '~/components/ui/text'; function Example() { const [value, setValue] = React.useState(''); const onChangeText = (text: string) => { setValue(text); }; return ( <Input placeholder='Write some stuff...' value={value} onChangeText={onChangeText} aria-labelledby='inputLabel' aria-errormessage='inputError' /> );}
Extends Text Input props
Text Input