Components / Core
Input
Text field with a label, hint and error, and optional icons or text inside it (start, end). ref points at the input.
import { Input } from "@stylhero/ui";
Example
Code
import { Input, Stack, SearchIcon } from "@stylhero/ui";
function InputExample() {
return (
<Stack gap={4}>
<Input label="Email" type="email" placeholder="you@example.com" hint="We never share it." />
<Input label="Search" start={<SearchIcon />} placeholder="Parts, builds…" />
<Input label="Weight" type="number" end="kg" error="Enter a number above 0." defaultValue={0} />
</Stack>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
end |
ReactNode |
- | Icon, text or IconButton inside the field, after the value (e.g. "kg"). |
error |
ReactNode |
- | |
hint |
ReactNode |
- | Help text under the field. Replaced by error when set. |
label |
ReactNode |
- | |
start |
ReactNode |
- | Icon or text inside the field, before the value (e.g. a search icon or "$"). |
Also takes every <input> attribute (id, style, data-*, aria-*, event handlers…), passed to that element. Takes a ref.
Accessibility
- The label, hint and error are linked to the control (
aria-describedby), anderrorsetsaria-invalid.
Generated from src/components/Input.tsx. Something wrong or missing? Open an issue.