Input
A one-line text field, with an optional label, helper text and icons. It shows when a value passes or fails validation, in four sizes and two corner shapes.
Installation
bash
npx @smicolon/fasla-ui@latest add inputRun init once per project before adding components. See Installation.
The examples below use icons from the lucide-react package; install it too if your project doesn't have it.
Preview
As it appears on your ID.
Variants
Coupon applied to your order.
Enter an email address, like [email protected].
Contact support to change it.
Sizes
Labels and icons
Optional
As it appears on your ID.
12/40
At least 8 characters.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "md" | "lg" | "md" | Field height: 28, 32, 36 or 40px. |
radius | "standard" | "rounded" | "standard" | Corner shape: 8px corners, or fully rounded ends. |
status | "default" | "success" | "default" | Set to success to mark a value that passed validation. |
invalid | boolean | false | Marks the field invalid. aria-invalid does the same. |
disabled | boolean | false | Disables the field and dims the whole group. |
label | ReactNode | — | The field's label, linked to the input for you. |
labelEnd | ReactNode | — | A short note at the end of the label row, such as Optional. |
description | ReactNode | — | Helper text under the field. A screen reader reads it with the field. |
descriptionEnd | ReactNode | — | A note at the end of the helper row, such as a character count. |
error | ReactNode | — | The message shown in place of description while the field is invalid. |
startIcon | ReactNode | — | An icon at the start of the field. |
endIcon | ReactNode | — | An icon or a small button at the end of the field. |
placeholder | string | — | Text shown while the field is empty. |
type | string | "text" | Input type, such as email. |
value | string | — | Field value. Use it with onChange. |
onChange | (event) => void | — | Called when the text changes. |
className | string | — | Extra CSS classes for the field group. |
Usage
tsx
import { Mail } from "lucide-react"
import { Input } from "@/components/ui/input"
export function EmailField() {
return (
<Input
name="email"
type="email"
label="Email"
description="We send the receipt here."
startIcon={<Mail />}
/>
)
}