Components
Input
A native text input with field sizes and an invalid state.
Server-compatible (no "use client")
import.tsx
input-states.tsx
Edit on GitHubPurpose
Input is a styled native <input>. Every native attribute works: type, name, autoComplete,
required, pattern, list, …
Import
import { Input } from "@neshel-ui/components";Usage
Preview: input-states
Use letters and numbers only.
import { Input, Label } from "@neshel-ui/components";
import { Inline, Stack } from "@neshel-ui/layout";
import { Caption } from "@neshel-ui/typography";
export default function InputStates() {
return (
<Stack space="5" className="max-w-sm">
<Stack space="2">
<Label htmlFor="demo-email" required>
Email
</Label>
<Input
id="demo-email"
type="email"
autoComplete="email"
placeholder="ana@example.com"
required
/>
</Stack>
<Stack space="2">
<Label htmlFor="demo-username">Username</Label>
<Input
id="demo-username"
invalid
aria-describedby="demo-username-error"
defaultValue="ana!"
/>
<Caption id="demo-username-error" tone="destructive">
Use letters and numbers only.
</Caption>
</Stack>
<Inline space="2">
<Input aria-label="Small field" uiSize="sm" placeholder="sm" />
<Input aria-label="Large field" uiSize="lg" placeholder="lg" />
</Inline>
<Input aria-label="Disabled field" disabled defaultValue="Disabled" />
</Stack>
);
}API
InputProps
| Prop | Type | Default | Description |
|---|---|---|---|
| invalid | boolean | — | Sets aria-invalid="true" unless aria-invalid is given explicitly. |
| ref | Ref<HTMLInputElement> | — | — |
| uiSize | FieldSize | — | Styling size; the native numeric size attribute keeps its HTML meaning. |
Also accepts the props of: React DOM attributes.
uiSize(sm md lg) is the visual size; the native numericsizeattribute keeps its HTML meaning.invalidsetsaria-invalid="true"unless you passaria-invalidyourself.
Controlled and uncontrolled
React's native rules apply: defaultValue (uncontrolled) or value + onChange (controlled).
Accessibility
Always label the input (<Label htmlFor>, aria-label or aria-labelledby). Reference hints and
errors with aria-describedby. Use the right type and autoComplete so browsers and assistive
technology can help users.
Common mistakes
- Using
size="lg"for styling: that sets the native character width. UseuiSize. - A placeholder instead of a label.
See Forms.