Components
Input
Single-line text fields with token sizes, icons, validation, and native semantics.
Input renders a native <input> inside a token-styled field. It supports four sizes, leading and
trailing icons, invalid, disabled, and read-only states, and fills the width of its container.
Input is exported from @orkest/ui/client because it uses client-side state. Render it inside a
Client Component.
Pair it with Label for the accessible name and Caption for help text.
Types#
Input forwards the native type attribute, so common HTML input types work without extra props:
text— plain textemail— email addressespassword— masked textnumber— numeric inputsearch— search fieldstel— telephone numbersurl— URLsdate— datestime— timesdatetime-local— dates and times
Native browser validation, autocomplete, and input modes remain available.
Live preview#
import { Box, Caption, Label, Stack } from '@orkest/ui';
import { Input } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Stack gap={1}>
<Label htmlFor="input-email">Email</Label>
<Input
id="input-email"
type="email"
placeholder="you@example.com"
aria-describedby="input-email-help"
/>
<Caption id="input-email-help">We only use this for account notices.</Caption>
</Stack>
</Box>
);
}Sizes#
import { Box, Stack } from '@orkest/ui';
import { Input } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Stack gap={2}>
<Input size="sm" placeholder="Small" aria-label="Small input" />
<Input size="md" placeholder="Medium" aria-label="Medium input" />
<Input size="lg" placeholder="Large" aria-label="Large input" />
<Input size="xl" placeholder="Extra large" aria-label="Extra large input" />
</Stack>
</Box>
);
}Icons#
Icons are decorative and follow the input size. The input keeps its own accessible name through a
label or aria-label.
import { Box, Stack } from '@orkest/ui';
import { Input } from '@orkest/ui/client';
import { Check, Search } from 'lucide-react';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Stack gap={2}>
<Input
leftIcon={Search}
placeholder="Search components"
aria-label="Search components"
/>
<Input rightIcon={Check} defaultValue="Looks good" aria-label="Validation status" />
</Stack>
</Box>
);
}Prefix and suffix#
import { Box } from '@orkest/ui';
import { Input } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Input prefix="$" suffix="USD" placeholder="0.00" aria-label="Amount" />
</Box>
);
}Actions#
clearable shows a clear action while the input has a value. passwordToggle adds a visibility
toggle for password fields. Both actions have accessible names and keep focus inside the field.
import { Box, Stack } from '@orkest/ui';
import { Input } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Stack gap={2}>
<Input clearable defaultValue="Clear me" aria-label="Clearable input" />
<Input type="password" passwordToggle defaultValue="secret" aria-label="Password" />
</Stack>
</Box>
);
}Character count#
import { Box } from '@orkest/ui';
import { Input } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Input showCount maxLength={40} placeholder="Short bio" aria-label="Short bio" />
</Box>
);
}The count is rendered below the field and updates as the value changes. maxLength still uses the
native constraint.
States#
Enter a valid email address.
import { Box, Label, Stack, Text } from '@orkest/ui';
import { Input } from '@orkest/ui/client';
export function Example() {
return (
<Box style={{ width: '22rem' }}>
<Stack gap={3}>
<Stack gap={1}>
<Label htmlFor="input-invalid">Email</Label>
<Input
id="input-invalid"
type="email"
invalid
defaultValue="not-an-email"
aria-describedby="input-invalid-error"
/>
<Text as="p" size="sm" tone="danger" id="input-invalid-error">
Enter a valid email address.
</Text>
</Stack>
<Input disabled placeholder="Disabled" aria-label="Disabled input" />
<Input readOnly defaultValue="Read-only value" aria-label="Read-only input" />
</Stack>
</Box>
);
}Props#
| Prop | Type | Default |
|---|---|---|
size | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
| Control height, padding, radius, and text size. Heights are 28px, 36px, 44px, and 52px. | ||
invalid | boolean | false |
| Applies the danger border and sets aria-invalid. | ||
leftIcon | LucideIcon | — |
| Decorative icon rendered before the input text. | ||
rightIcon | LucideIcon | — |
| Decorative icon rendered after the input text. | ||
prefix | ReactNode | — |
| Text or node rendered before the input value. | ||
suffix | ReactNode | — |
| Text or node rendered after the input value. | ||
clearable | boolean | false |
| Shows a clear action while the input has a value. | ||
clearLabel | string | 'Clear input' |
| Accessible name for the clear action. | ||
passwordToggle | boolean | false |
| Shows a visibility toggle when type is password. | ||
showPasswordLabel | string | 'Show password' |
| Accessible name for the show-password action. | ||
hidePasswordLabel | string | 'Hide password' |
| Accessible name for the hide-password action. | ||
showCount | boolean | false |
| Shows the current character count below the field. | ||
type | string | 'text' |
| Native input type, such as email, password, search, date, or number. | ||
maxLength | number | — |
| Native maximum length. Used by the character count when showCount is enabled. | ||
native attributes | InputHTMLAttributes<HTMLInputElement> | — |
| Placeholder, value, name, required, aria-describedby, events, and ref are forwarded. The native numeric size attribute is replaced by the control size. | ||
Input always fills its container width. Constrain it with a layout component such as Box or
Stack.
Accessibility#
- Provide an accessible name with
Label htmlFororaria-label. A placeholder is not a label. - Connect help and error text with
aria-describedby. invalidsetsaria-invalid. Pair it with visible error text; do not rely on the border color alone.disabledandreadOnlyuse the native attributes and remain distinguishable without color alone.- Leading and trailing icons are decorative and hidden from assistive technology.
- Clear and password actions are buttons with accessible names. The password toggle exposes
aria-pressed. - With a controlled
value, update it inonChangewhen the clear action fires. - The character count is supplementary.
maxLengthremains the native constraint. - Focus is shown by darkening the field border; no separate focus ring is drawn. Invalid fields keep the danger border.
- Refs are forwarded to the native input element.
Related#
- Textarea for multi-line input.
- Typography for Label, Caption, and error text.
- Icon for icon sizing rules.
- Button for form actions.