Input

PreviousNext

A styled text input component with label, validation, icons, and grouped layouts.

Installation

pnpm dlx bna-ui add input

Usage

import { Input, GroupedInput, GroupedInputItem } from '@/components/ui/input';
<Input label='Username' placeholder='Enter your username' icon={User} />

Examples

Default

With Icons

Variants

Validation States

Right Components

Disabled State

Grouped Inputs

Form Example

API Reference

Input

The main input component with label, validation, and icon support. Extends all TextInputProps except style.

PropTypeDefaultDescription
labelstring-Label text displayed inside the input
errorstring-Error message to display below the input
iconReact.ComponentType<LucideProps>-Lucide icon component to display on the left
rightComponentReactNode | (() => ReactNode)-Component or function returning component for right side
containerStyleViewStyle-Style for the outer container
inputStyleTextStyle-Style for the text input
labelStyleTextStyle-Style for the label text
errorStyleTextStyle-Style for the error message
variant'filled' | 'outline''filled'Visual variant of the input
disabledbooleanfalseWhether the input is disabled
type'input' | 'textarea''input'Switches the layout to a multiline textarea when set to 'textarea'.
rowsnumber4Number of visible text lines. Only used when type is "textarea".
placeholderstring'Type your message...' when type is "textarea"Placeholder text shown when the input is empty. type="textarea" falls back to a default when omitted; type="input" has no fallback.

GroupedInput

Container component for grouping multiple inputs together.

PropTypeDescription
childrenReactNodeChild components (usually GroupedInputItem)
containerStyleViewStyleStyle for the container
titlestringOptional title for the group
titleStyleTextStyleStyle for the title text

GroupedInputItem

Input component designed to be used within GroupedInput. Extends all TextInputProps except style.

PropTypeDefaultDescription
labelstring-Label text displayed inside the input
errorstring-Error message (displayed at group level)
iconReact.ComponentType<LucideProps>-Lucide icon component to display on the left
rightComponentReactNode | (() => ReactNode)-Component or function returning component for right side
inputStyleTextStyle-Style for the text input
labelStyleTextStyle-Style for the label text
errorStyleTextStyle-Style for the error message
disabledbooleanfalseWhether the input is disabled
type'input' | 'textarea''input'Switches the layout to a multiline textarea when set to 'textarea'.
rowsnumber3Number of visible text lines. Only used when type is "textarea".

Accessibility

The Input component is built with accessibility in mind:

  • Proper focus management and keyboard navigation
  • Screen reader support with semantic labeling
  • High contrast support for error states
  • Proper touch targets for mobile devices
  • Support for dynamic text sizing
  • Keyboard shortcuts and hardware keyboard support

Styling

The Input component uses your theme colors and can be customized:

  • filled variant: Uses card background with subtle borders
  • outline variant: Transparent background with prominent borders
  • Error states: Uses danger/red theme color
  • Focus states: Uses primary theme color
  • Disabled states: Reduced opacity with muted colors

Best Practices

  • Use clear, descriptive labels
  • Provide helpful placeholder text
  • Show validation errors immediately after user interaction
  • Group related inputs using GroupedInput
  • Use appropriate input types (email, password, etc.)
  • Consider using icons to clarify input purpose
  • Ensure sufficient contrast for accessibility