Menu

Select

Dropdown trigger. 3 styles × 3 sizes × 5 states.

Installation

$ npx uix-ui@latest add select

This copies the file into components/ui/select.tsx in your project. npx shadcn@latest add @uix/select works too.

Usage

select.tsx
import { Select } from "@/components/ui/select";

<div style={{ width: 320, maxWidth: "100%" }}>
  <Select label="Tea" defaultValue="darjeeling">
    <option value="darjeeling">Darjeeling tin</option>
    <option value="green">Sylhet green</option>
    <option value="chai">Masala chai</option>
  </Select>
</div>

Examples

With a placeholder

Filled, error and disabled

Pick a courier to continue.

Props

PropTypeDefaultDescription
appearanceoutline | filled | underline"outline"
sizesm | md | lg"md"
labelReact.ReactNode–
secondaryLabelReact.ReactNode–Right-aligned note next to the label, for example "Optional".
feedbackReact.ReactNode–Message under the field.
helperReact.ReactNode–Same as feedback.
errorstring–Error message; also marks the field invalid and replaces the feedback.
placeholderstring–First, disabled option shown until a value is picked.
leadingAvatarReact.ReactNode–Avatar at the start (for example <Avatar size="xs" initials="AB" />).
leadingIconReact.ReactNode–Icon at the start.
leadingContentReact.ReactNode–Selector or text at the start, for example "Email ▾".
leadingDividerboolean–Hairline after the leading parts.
prefixReact.ReactNode–Fixed text before the value, for example "https://".
tagsReact.ReactNode[]–Tag chips before the value.
suffixReact.ReactNode–Fixed text after the value, for example ".com".
trailingDividerboolean–Hairline before the trailing parts.
trailingContentReact.ReactNode–Action at the end, for example a "Copy" button.
helpIconboolean | string–Help icon; a string becomes its accessible name and tooltip.
trailingIconReact.ReactNode–Icon at the end.

Everything else is passed to the root element, so className, aria-* and event handlers work as usual.

Dependencies

Installed for you by the CLI.

  • class-variance-authority
  • clsx
  • tailwind-merge
  • lib/utils.ts
  • components/ui/icons.tsx
esc

↑↓ to navigate · ↵ to select · esc to close