Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

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

PropTypeDefaultDescription
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

KeyDoes
Arrow keysChange the option (native <select>)

Accessibility

  • The label, hint and error are linked to the control (aria-describedby), and error sets aria-invalid.

Generated from src/components/Select.tsx. Something wrong or missing? Open an issue.