Skip to content
Haze UI

Select

Native select with the same field finish as the input, a chevron over the right edge and an optional disabled placeholder option.

pnpm dlx shadcn@latest add @haze/select
Open preview in a new tab
Liveno JavaScript

When to use

  • Choosing one value from a list of roughly 4 to 15 fixed options
  • Region, country, time zone or billing cycle pickers in forms
  • Mobile-first forms where the operating system's own picker is the best experience

When not to use

  • Two or three options that fit on screen; use radio-group or toggle-group
  • Options that need icons, search or rich content

Installation

Add the Haze registry to components.json once, then install Select with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/select
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Element id; reference it from a label or Field.
namestringidForm field name.
options*{ value: string; label: string; disabled?: boolean }[]–The choices, in display order.
valuestring–Value of the option that is selected on load.
placeholderstring–Adds a disabled, empty first option with this text; it is selected only when no value is given.
requiredboolean–Marks the field required.
classstring–Extra classes on the select element.
...restattributes–Any other select attribute: disabled, aria-invalid, aria-describedby.

Keyboard interactions

Arrow UpArrow Down
Changes the selected option
AltArrow Down or Space
Opens the option list
Type a letter
Jumps to the next option starting with it

Accessibility

  • The chevron is aria-hidden and ignores the pointer, so the whole box opens the native picker and screen readers announce a plain select.
  • Options use the popover colors so the native list is dark on Windows.
  • The placeholder option is disabled with an empty value, so a required select cannot be submitted without a real choice.
  • The component renders no label; pair it with Field or a label whose for matches the id.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Select" with `npx shadcn@latest add @haze/select`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Select from "@/components/haze/ui/select.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/select.md

  • Customize with real content

    Adapt the Haze select ui for our product. Replace the demo values of these props with our real content: id, name, options, value, placeholder, required, class, ...rest. Keep the layout, the heading level rules and these accessibility details: The chevron is aria-hidden and ignores the pointer, so the whole box opens the native picker and screen readers announce a plain select. Options use the popover colors so the native list is dark on Windows. The placeholder option is disabled with an empty value, so a required select cannot be submitted without a real choice. The component renders no label; pair it with Field or a label whose for matches the id. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using select, check it fits: use it when choosing one value from a list of roughly 4 to 15 fixed options; region, country, time zone or billing cycle pickers in forms; mobile-first forms where the operating system's own picker is the best experience. Avoid it when two or three options that fit on screen; use radio-group or toggle-group; options that need icons, search or rich content. Alternatives: @haze/radio-group, @haze/toggle-group, @haze/dropdown-menu.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog