Components / Core
Select
Native <select>, styled. Pass <option> elements as children.
import { Select } from "@stylhero/ui";
Example
Code
import { Select } from "@stylhero/ui";
function SelectExample() {
return (
<Select label="Country" defaultValue="mx">
<option value="mx">Mexico</option>
<option value="us">United States</option>
<option value="ca">Canada</option>
</Select>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
error |
ReactNode |
- | |
hint |
ReactNode |
- | Help text under the field. Replaced by error when set. |
label |
ReactNode |
- |
Also takes every <select> attribute (id, style, data-*, aria-*, event handlers…), passed to that element. Takes a ref.
Keyboard
| Key | Does |
|---|---|
| Arrow keys | Change the option (native <select>) |
Accessibility
- The label, hint and error are linked to the control (
aria-describedby), anderrorsetsaria-invalid.
Generated from src/components/Select.tsx. Something wrong or missing? Open an issue.