Skip to content

Input ​

Text input field with label support and validation variants.

Also known as: text field, text input, form field, text box

View in Storybook

When to use ​

  • Single-line text entry. For multiline, use Textarea.
  • For search with suggestions, use Autocomplete. For selection from options, use Select.

Import ​

tsx
import { Input } from '@vacano/ui'

Usage ​

tsx
const [value, setValue] = useState('')

<Input
  value={value}
  onChange={(e) => setValue(e.target.value)}
  placeholder="Enter text"
/>

With Label ​

tsx
<Input label="Email" placeholder="Enter your email" />

Variants ​

tsx
<Input variant="normal" label="Normal" />
<Input variant="error" label="Error" />

Sizes ​

tsx
<Input size="default" label="Default Size" />
<Input size="compact" label="Compact Size" />

Full Width ​

tsx
<Input fullWidth label="Full Width Input" />

With Message ​

tsx
<Input label="Email" variant="error" message="Invalid email address" />
<Input label="Username" message="Must be at least 3 characters" />

With Prefix ​

tsx
<Input label="Website" prefix="https://" placeholder="example.com" />
<Input label="Price" prefix="$" placeholder="0.00" />

Disabled ​

tsx
<Input disabled label="Disabled" value="Cannot edit" />

Props ​

PropTypeDefaultDescription
labelstring-Label text above input
variant'normal' | 'error''normal'Visual variant
size'compact' | 'default''default'Input size
fullWidthbooleanfalseFull width input
messagestring-Message text below input (error, hint)
prefixReactNode-Prefix content inside input (text, icon)
classNamestring-CSS class name for the root element
classnamesInputClassNames-Custom class names for inner elements
refRef<HTMLInputElement>-Ref to the underlying input element
data-test-idstring-Test identifier attribute

All standard HTML input attributes are also supported (e.g. value, onChange, placeholder, disabled, type, name, autoFocus, etc.).

ClassNames ​

KeyDescription
inputInput element
labelLabel element

Released under the MIT License.