Input

An Input component allows users to enter text data. Built on top of heroui-native Input.

Demo

React Native components render to native views, so this is the component running in the example app, in the theme you are reading in.

9:41
Input running in the Nayan UI example app

Usage

Input.tsx
import { View } from 'react-native';
import { NInput, NText } from '@nayan-ui/native';
export default function InputScreen() {
return (
<View className="p-4 gap-1">
<NText className="text-lg font-bold">Basic</NText>
<NInput label="Name" />
<NText className="text-lg font-bold">With description</NText>
<NInput label="Email" description="We'll never share your email." />
<NText className="text-lg font-bold">Required</NText>
<NInput label="Username" isRequired />
<NText className="text-lg font-bold">Invalid with error</NText>
<NInput label="Password" isInvalid errorMessage="Password must be at least 8 characters." />
<NText className="text-lg font-bold">Disabled</NText>
<NInput label="Organization" isDisabled />
<NText className="text-lg font-bold">Multiline (textarea)</NText>
<NInput label="Bio" multiline description="Tell us about yourself." />
<NText className="text-lg font-bold">All combined</NText>
<NInput label="Phone" description="Include country code." isRequired isInvalid errorMessage="Invalid phone number." />
</View>
);
}

Attributes

14 props
NameTypeDefaultDetails
labelstringOptionalLabel for the input field.
descriptionstringOptionalDescription text below the input.
errorMessagestringOptionalError message to display.
multilinebooleanfalseWhether to render as a multiline textarea.
isDisabledbooleanfalseWhether the input is disabled.
isRequiredbooleanfalseWhether the input is required.
isInvalidbooleanfalseWhether the input is in an invalid state.
valuestringOptionalControlled input value.
onChange(value: string) => voidOptionalCallback when input value changes.
classNamestring' 'You can customise input by passing tailwind classes.
containerClassNamestring' 'You can customise container by passing tailwind classes.
labelClassNamestring' 'You can customise label by passing tailwind classes.
descriptionClassNamestring' 'You can customise description by passing tailwind classes.
errorClassNamestring' 'You can customise error by passing tailwind classes.

Tags

Other components solving nearby problems.