Select
Dropdown trigger. 3 styles × 3 sizes × 5 states.
import { Select } from "@/components/ui/select";
export default function Example() {
return (
<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>
);
}
Installation
$ npx uix-ui@latest add selectThis copies the file into components/ui/select.tsx in your project. npx shadcn@latest add @uix/select works too.
Usage
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
import { Select } from "@/components/ui/select";
export default function Example() {
return (
<div style={{ width: 320, maxWidth: "100%" }}>
<Select label="Delivery area" placeholder="Choose an area" defaultValue="">
<option value="dhanmondi">Dhanmondi</option>
<option value="gulshan">Gulshan</option>
<option value="mirpur">Mirpur</option>
</Select>
</div>
);
}
Filled, error and disabled
Pick a courier to continue.
import { Select } from "@/components/ui/select";
export default function Example() {
return (
<div style={{ width: 320, display: "grid", gap: 16 }}>
<Select appearance="filled" label="Filled" defaultValue="1"><option value="1">Same day</option><option value="2">Next day</option></Select>
<Select label="Courier" error="Pick a courier to continue." defaultValue="" placeholder="Choose a courier"><option value="pathao">Pathao</option><option value="redx">RedX</option></Select>
<Select label="Disabled" disabled defaultValue="1"><option value="1">Pickup only</option></Select>
</div>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
appearance | outline | filled | underline | "outline" | |
size | sm | md | lg | "md" | |
label | React.ReactNode | – | |
secondaryLabel | React.ReactNode | – | Right-aligned note next to the label, for example "Optional". |
feedback | React.ReactNode | – | Message under the field. |
helper | React.ReactNode | – | Same as feedback. |
error | string | – | Error message; also marks the field invalid and replaces the feedback. |
placeholder | string | – | First, disabled option shown until a value is picked. |
leadingAvatar | React.ReactNode | – | Avatar at the start (for example <Avatar size="xs" initials="AB" />). |
leadingIcon | React.ReactNode | – | Icon at the start. |
leadingContent | React.ReactNode | – | Selector or text at the start, for example "Email ▾". |
leadingDivider | boolean | – | Hairline after the leading parts. |
prefix | React.ReactNode | – | Fixed text before the value, for example "https://". |
tags | React.ReactNode[] | – | Tag chips before the value. |
suffix | React.ReactNode | – | Fixed text after the value, for example ".com". |
trailingDivider | boolean | – | Hairline before the trailing parts. |
trailingContent | React.ReactNode | – | Action at the end, for example a "Copy" button. |
helpIcon | boolean | string | – | Help icon; a string becomes its accessible name and tooltip. |
trailingIcon | React.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-authorityclsxtailwind-merge
lib/utils.tscomponents/ui/icons.tsx