Docs

Select

Select

Displays a list of options for the user to pick from—triggered by a button.

import * as React from "react";
import { css } from "@pigment-css/react";
 
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select";
 
export function SelectExample(): React.JSX.Element {
  return (
    <Select defaultValue="1">
      <SelectTrigger className={css({ width: "180px" })}>
        <SelectValue />
      </SelectTrigger>
      <SelectContent className={css({ width: "180px" })}>
        <SelectItem value="1">Option 1</SelectItem>
        <SelectItem value="2">Option 2</SelectItem>
      </SelectContent>
    </Select>
  );
}

Installation

npx lotru@latest add ui/select

Usage

import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select";
<Select defaultValue="1">
  <SelectTrigger>
    <SelectValue />
  </SelectTrigger>
  <SelectContent>
    <SelectItem value="1">Option 1</SelectItem>
    <SelectItem value="2">Option 2</SelectItem>
  </SelectContent>
</Select>

On this page