← Components

Selection and input · Material 3: Menus (exposed dropdown)

Select

Pick one option from a list. The list grows from the trigger, the highlight slides, and the value rolls into place.

Examples and variants

Select

Custom list with the sliding highlight.

Example
function SelectBasic() {
  return (
    <Select defaultValue="calm">
      <SelectTrigger aria-label="Motion">
        <SelectValue />
      </SelectTrigger>
      <SelectContent>
        <SelectItem value="still">Still</SelectItem>
        <SelectItem value="calm">Calm</SelectItem>
        <SelectItem value="liquid">Liquid</SelectItem>
      </SelectContent>
    </Select>
  )
}

Native

The platform picker, styled. Best on phones and in long forms.

Example
function SelectNative() {
  return (
    <NativeSelect defaultValue="calm" aria-label="Motion">
      <NativeSelectOption value="still">Still</NativeSelectOption>
      <NativeSelectOption value="calm">Calm</NativeSelectOption>
      <NativeSelectOption value="liquid">Liquid</NativeSelectOption>
    </NativeSelect>
  )
}

Spec drawing

Measured from the live component at default density. Each code maps to the token that sets it; change the token and the drawing follows.

Install

With the CLI

The shadcn CLI only delivers files: it copies our code from the Isotopi registry into your project and installs the packages it uses. Add the foundation once, then the component.

Terminal
npx shadcn@latest add https://isotopi.com/r/minimal.json
npx shadcn@latest add https://isotopi.com/r/select.json
npx shadcn@latest add https://isotopi.com/r/native-select.json

By hand

No CLI needed. Add the foundation once (see Getting started), then follow these steps. They include every component this one builds on.

  1. Install the packages it uses.

    Terminal
    npm install @base-ui/react cn lucide-react
  2. Copy these 2 files to the same paths in your project. Imports use the @/ alias for your project root.

    • components/ui/select.tsxselect
      components/ui/select.tsx
      "use client"
      
      import * as React from "react"
      import { Select as SelectPrimitive } from "@base-ui/react/select"
      import { cn } from "cn"
      import { ChevronDownIcon, CheckIcon } from "lucide-react"
      import { layoutTop } from "@/lib/motion/layout-offset"
      
      const Select = SelectPrimitive.Root
      
      function SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {
        return (
          <SelectPrimitive.Group
            data-slot="select-group"
            className={cn("scroll-my-1 p-1", className)}
            {...props}
          />
        )
      }
      
      function SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {
        const holder = React.useRef<HTMLSpanElement>(null)
        const previous = React.useRef("")
        const [roll, setRoll] = React.useState<{ from: string; to: string; id: number } | null>(null)
      
        React.useEffect(() => {
          const node = holder.current
          if (!node) return
          const read = () => {
            const text = node.querySelector("[data-slot=select-value]")?.textContent?.trim() ?? ""
            if (!text || text === previous.current) return
            const motion = node.closest<HTMLElement>("[data-motion]")?.dataset.motion
            const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
            if (previous.current && motion !== "calm" && motion !== "still" && !reduced) {
              setRoll({ from: previous.current, to: text, id: Date.now() })
            }
            previous.current = text
          }
          read()
          const observer = new MutationObserver(read)
          observer.observe(node, { subtree: true, childList: true, characterData: true })
          return () => observer.disconnect()
        }, [])
      
        return (
          <span ref={holder} className="relative inline-grid overflow-hidden">
            <SelectPrimitive.Value
              data-slot="select-value"
              className={cn("col-start-1 row-start-1 flex flex-1 text-left", roll && "invisible", className)}
              {...props}
            />
            {roll ? (
              <span key={roll.id} aria-hidden className="select-roll col-start-1 row-start-1" onAnimationEnd={() => setRoll(null)}>
                <span className="select-roll-out">{roll.from}</span>
                <span className="select-roll-in">{roll.to}</span>
              </span>
            ) : null}
          </span>
        )
      }
      
      function SelectTrigger({
        className,
        size = "default",
        children,
        ...props
      }: SelectPrimitive.Trigger.Props & {
        size?: "sm" | "default"
      }) {
        return (
          <SelectPrimitive.Trigger
            data-slot="select-trigger"
            data-size={size}
            className={cn(
              "flex w-fit items-center justify-between gap-inline-sm rounded-(--field-corner) border-solid border-(length:--field-stroke-width) border-(--field-stroke-color) bg-(--field-container) hover:bg-(--field-container-hover) py-(--field-padding-y) pe-(--field-padding-x) ps-(--field-padding-x) text-sm whitespace-nowrap shadow-(--field-elevation) outline-none transition-[background-color,box-shadow] duration-(--duration-fast) ease-(--ease-out) select-none focus-visible:bg-(--field-container-focus) focus-visible:shadow-(--field-focus-shadow) disabled:cursor-not-allowed disabled:bg-(--field-container-disabled) disabled:text-(--field-label-disabled) disabled:shadow-none data-placeholder:text-(--field-placeholder) data-[size=default]:h-(--field-height-md) data-[size=sm]:h-control-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-icon-sm",
              className
            )}
            {...props}
          >
            {children}
            <SelectPrimitive.Icon
              render={
                <ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
              }
            />
          </SelectPrimitive.Trigger>
        )
      }
      
      function SelectContent({
        className,
        children,
        side = "bottom",
        sideOffset = 4,
        align = "center",
        alignOffset = 0,
        alignItemWithTrigger = false,
        ...props
      }: SelectPrimitive.Popup.Props &
        Pick<
          SelectPrimitive.Positioner.Props,
          "align" | "alignOffset" | "side" | "sideOffset" | "alignItemWithTrigger"
        >) {
        return (
          <SelectPrimitive.Portal>
            <SelectPrimitive.Positioner
              side={side}
              sideOffset={sideOffset}
              align={align}
              alignOffset={alignOffset}
              alignItemWithTrigger={alignItemWithTrigger}
              className="isolate z-(--z-dropdown)"
            >
              <SelectPrimitive.Popup
                data-slot="select-content"
                data-align-trigger={alignItemWithTrigger}
                className={cn(
                  "menu-scroll grow-from-origin relative isolate z-(--z-dropdown) h-auto max-h-(--available-height) w-(--anchor-width) min-w-36 overflow-x-hidden overflow-y-auto rounded-(--menu-corner) bg-(--menu-container) p-(--space-2) text-foreground shadow-(--menu-elevation) outline-none",
                  className
                )}
                {...props}
              >
                <SelectHighlight>{children}</SelectHighlight>
              </SelectPrimitive.Popup>
            </SelectPrimitive.Positioner>
          </SelectPrimitive.Portal>
        )
      }
      
      function SelectHighlight({ children }: { children: React.ReactNode }) {
        const ref = React.useRef<HTMLDivElement>(null)
        const [box, setBox] = React.useState({ top: 0, height: 0 })
        const [ready, setReady] = React.useState(false)
      
        React.useLayoutEffect(() => {
          const root = ref.current
          if (!root) return
          const read = () => {
            const items = [...root.querySelectorAll<HTMLElement>("[data-slot=select-item]")]
            const item = items.find((entry) => entry.hasAttribute("data-highlighted"))
            if (!item) return
            setBox({ top: layoutTop(item, root), height: item.offsetHeight })
            setReady(true)
          }
          read()
          const observer = new MutationObserver(read)
          observer.observe(root, { subtree: true, attributes: true, attributeFilter: ["data-highlighted"] })
          const resize = new ResizeObserver(read)
          resize.observe(root)
          return () => {
            observer.disconnect()
            resize.disconnect()
          }
        }, [])
      
        return (
          <div ref={ref} className="relative">
            {ready ? (
              <span
                aria-hidden
                className="select-pill pointer-events-none absolute right-0 left-0 rounded-(--menu-item-corner) bg-(--menu-item-highlight)"
                style={{ top: box.top, height: box.height }}
              />
            ) : null}
            <SelectPrimitive.List>{children}</SelectPrimitive.List>
          </div>
        )
      }
      
      function SelectLabel({
        className,
        ...props
      }: SelectPrimitive.GroupLabel.Props) {
        return (
          <SelectPrimitive.GroupLabel
            data-slot="select-label"
            className={cn("px-1.5 py-1 text-xs text-muted-foreground", className)}
            {...props}
          />
        )
      }
      
      function SelectItem({
        className,
        children,
        ...props
      }: SelectPrimitive.Item.Props) {
        return (
          <SelectPrimitive.Item
            data-slot="select-item"
            className={cn(
              "select-item relative z-[1] flex w-full cursor-default items-center gap-inline-sm rounded-(--menu-item-corner) py-(--space-inset-control-y) pr-8 pl-(--menu-item-padding-x) text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:text-(--menu-item-label-disabled)",
              className
            )}
            {...props}
          >
            <SelectPrimitive.ItemText className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">
              {children}
            </SelectPrimitive.ItemText>
            <SelectPrimitive.ItemIndicator
              render={
                <span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
              }
            >
              <CheckIcon className="pointer-events-none" />
            </SelectPrimitive.ItemIndicator>
          </SelectPrimitive.Item>
        )
      }
      
      function SelectSeparator({
        className,
        ...props
      }: SelectPrimitive.Separator.Props) {
        return (
          <SelectPrimitive.Separator
            data-slot="select-separator"
            className={cn("pointer-events-none my-1 h-stack-sm", className)}
            {...props}
          />
        )
      }
      
      export {
        Select,
        SelectContent,
        SelectGroup,
        SelectItem,
        SelectLabel,
        SelectSeparator,
        SelectTrigger,
        SelectValue,
      }
      
    • components/ui/native-select.tsxnative-select
      components/ui/native-select.tsx
      import * as React from "react"
      import { cn } from "cn"
      import { ChevronDownIcon } from "lucide-react"
      
      type NativeSelectProps = Omit<React.ComponentProps<"select">, "size"> & {
        size?: "sm" | "default"
      }
      
      function NativeSelect({ className, size = "default", ...props }: NativeSelectProps) {
        return (
          <div
            className={cn("relative w-fit", className)}
            data-slot="native-select-wrapper"
            data-size={size}
          >
            <select
              data-slot="native-select"
              data-size={size}
              className="h-(--field-height-md) w-full min-w-40 appearance-none rounded-(--field-corner) border-solid border-(length:--field-stroke-width) border-(--field-stroke-color) bg-(--field-container) hover:bg-(--field-container-hover) pr-8 ps-(--field-padding-x) text-sm text-(--field-label) shadow-(--field-elevation) outline-none transition-[background-color,box-shadow] duration-(--duration-fast) ease-(--ease-out) focus-visible:bg-(--field-container-focus) focus-visible:shadow-(--field-focus-shadow) disabled:cursor-not-allowed disabled:bg-(--field-container-disabled) disabled:text-(--field-label-disabled) disabled:shadow-none data-[size=sm]:h-control-sm"
              {...props}
            />
            <ChevronDownIcon
              className="pointer-events-none absolute top-1/2 right-3 size-icon-sm -translate-y-1/2 text-muted-foreground"
              aria-hidden
              data-slot="native-select-icon"
            />
          </div>
        )
      }
      
      function NativeSelectOption({ className, ...props }: React.ComponentProps<"option">) {
        return <option data-slot="native-select-option" className={className} {...props} />
      }
      
      function NativeSelectOptGroup({ className, ...props }: React.ComponentProps<"optgroup">) {
        return <optgroup data-slot="native-select-optgroup" className={className} {...props} />
      }
      
      export { NativeSelect, NativeSelectOptGroup, NativeSelectOption }
      

Imports

What the examples on this page import:

Imports
import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"

Anatomy

  1. 1Trigger · Same tokens as the text field (--field-*).
  2. 2List · --menu-container, --menu-corner, --menu-elevation.
  3. 3Highlight · --menu-item-highlight, slides between items.
  4. 4Check · Marks the selected item.

Props

PropTypeDefaultDescription
value / defaultValuestring—Selected value.
onValueChange(value: string) => void—Called on change.
SelectTrigger size"sm" | "default""default"Trigger height.

Tokens

Every visual spec is a component token in styles/tokens/components.css, pointing at a semantic token. Change a token to restyle the component; themes change the semantic layer.

TokenPoints toLightDark
--field-height-smvar(--size-control-sm)32pxsame
--field-height-mdvar(--size-control-md)40pxsame
--field-height-lgvar(--size-control-lg)48pxsame
--field-padding-xvar(--space-inset-control-x)12pxsame
--field-padding-x-textvar(--space-inset-control-x-lg)16pxsame
--field-padding-yvar(--space-inset-control-y)8pxsame
--field-cornervar(--shape-full)999pxsame
--field-corner-multilinevar(--shape-md)14pxsame
--field-containervar(--surface-container)oklch(0.965 0.005 95)oklch(0.12 0 0)
--field-container-focusvar(--surface-container-lowest)oklch(1 0 0)oklch(0.14 0 0)
--field-labelvar(--on-surface)oklch(0.22 0.01 260)oklch(1 0 0)
--field-container-hovercolor-mix(in oklch, var(--field-container), var(--field-label) var(--state-hover-mix))color-mix(in oklch, var(--field-container), var(--field-label) var(--state-hover-mix))same
--field-container-disabledvar(--color-bg-disabled)color-mix(in oklch, var(--color-fg-default) var(--state-disabled-container-mix), transparent)same
--field-label-disabledvar(--color-fg-disabled)oklch(0.62 0.01 95)oklch(0.53 0 0)
--field-placeholdervar(--on-surface-variant)oklch(0.45 0.01 95)oklch(0.68 0 0)
--field-stroke-widthvar(--stroke-width-control)0pxsame
--field-stroke-colorvar(--stroke-color-default)oklch(0.22 0.01 260 / 18%)oklch(1 0 0 / 12%)
--field-elevationvar(--elevation-1)0 1px 1px -0.5px oklch(0.22 0.01 260 / 7%), 0 2px 3px -1px oklch(0.22 0.01 260 / 10%), 0 4px 8px -4px oklch(0.22 0.01 260 / 6%)0 1px 2px oklch(0 0 0 / 35%), 0 2px 10px oklch(0 0 0 / 25%)
--field-focus-halo-widthvar(--state-field-stroke)3pxsame
--field-focus-shadowvar(--focus-field)0 0 0 var(--state-field-stroke) color-mix(in oklch, var(--color-fg-default) var(--state-field-stroke-mix), transparent), var(--elevation-3)same
--field-error-shadowvar(--focus-ring-invalid)0 0 0 var(--state-focus-ring-offset) var(--focus-ring-gap, var(--color-bg-canvas)), 0 0 0 calc(var(--state-focus-ring-offset) + var(--state-focus-ring-width)) var(--color-danger)same
--field-label-gapvar(--space-1)4pxsame
--field-action-labelvar(--field-placeholder)oklch(0.45 0.01 95)oklch(0.68 0 0)
--field-action-label-hovervar(--field-label)oklch(0.22 0.01 260)oklch(1 0 0)
--field-action-container-hovervar(--color-bg-hover)oklch(0.965 0.005 95)oklch(0.22 0 0)
--field-action-container-pressedvar(--color-bg-pressed)oklch(0.94 0.007 95)oklch(0.27 0 0)
--field-choice-container-hovercolor-mix(in oklch, var(--field-container), var(--field-label) var(--state-hover-mix))color-mix(in oklch, var(--field-container), var(--field-label) var(--state-hover-mix))same
--menu-containervar(--surface-container-raised)oklch(1 0 0)oklch(0.22 0 0)
--menu-cornervar(--shape-md)14pxsame
--menu-paddingvar(--space-inset-overlay)8pxsame
--menu-elevationvar(--elevation-2)0 1px 1px -0.5px oklch(0.22 0.01 260 / 6%), 0 3px 3px -1.5px oklch(0.22 0.01 260 / 6%), 0 6px 6px -3px oklch(0.22 0.01 260 / 6%), 0 12px 12px -6px oklch(0.22 0.01 260 / 6%), 0 24px 24px -12px oklch(0.22 0.01 260 / 6%)0 4px 12px oklch(0 0 0 / 40%), 0 12px 28px oklch(0 0 0 / 35%)
--menu-item-heightvar(--size-row-sm)32pxsame
--menu-item-padding-xvar(--space-inset-control-x-sm)8pxsame
--menu-item-cornervar(--shape-sm)8pxsame
--menu-item-highlightvar(--color-bg-hover)oklch(0.965 0.005 95)oklch(0.22 0 0)
--menu-item-label-disabledvar(--color-fg-disabled)oklch(0.62 0.01 95)oklch(0.53 0 0)
--menu-item-dangervar(--color-danger-fg)oklch(0.48 0.18 25)oklch(0.78 0.14 22)
--menu-min-widthvar(--layout-menu-min)180pxsame

Motion

TriggerWhat happensTokens
OpenThe list grows from the trigger; items rise in with a stagger.--duration-fast, --duration-stagger
HighlightThe pill slides between items.--duration-fast
PickThe value rolls into the trigger.--duration-fast

Calm keeps the motion without overshoot. Still (and reduced motion) keeps a designed frame with no movement.

Accessibility

  • Arrow keys move; typing jumps to an option; Enter selects; Escape closes.
  • Label the trigger.

Usage

Do

  • Use for 5+ options.

Don’t

  • Don't use for 2 or 3 options (use Radio group or Segmented control).

Code

components/ui/select.tsx
"use client"

import * as React from "react"
import { Select as SelectPrimitive } from "@base-ui/react/select"
import { cn } from "cn"
import { ChevronDownIcon, CheckIcon } from "lucide-react"
import { layoutTop } from "@/lib/motion/layout-offset"

const Select = SelectPrimitive.Root

function SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {
  return (
    <SelectPrimitive.Group
      data-slot="select-group"
      className={cn("scroll-my-1 p-1", className)}
      {...props}
    />
  )
}

function SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {
  const holder = React.useRef<HTMLSpanElement>(null)
  const previous = React.useRef("")
  const [roll, setRoll] = React.useState<{ from: string; to: string; id: number } | null>(null)

  React.useEffect(() => {
    const node = holder.current
    if (!node) return
    const read = () => {
      const text = node.querySelector("[data-slot=select-value]")?.textContent?.trim() ?? ""
      if (!text || text === previous.current) return
      const motion = node.closest<HTMLElement>("[data-motion]")?.dataset.motion
      const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
      if (previous.current && motion !== "calm" && motion !== "still" && !reduced) {
        setRoll({ from: previous.current, to: text, id: Date.now() })
      }
      previous.current = text
    }
    read()
    const observer = new MutationObserver(read)
    observer.observe(node, { subtree: true, childList: true, characterData: true })
    return () => observer.disconnect()
  }, [])

  return (
    <span ref={holder} className="relative inline-grid overflow-hidden">
      <SelectPrimitive.Value
        data-slot="select-value"
        className={cn("col-start-1 row-start-1 flex flex-1 text-left", roll && "invisible", className)}
        {...props}
      />
      {roll ? (
        <span key={roll.id} aria-hidden className="select-roll col-start-1 row-start-1" onAnimationEnd={() => setRoll(null)}>
          <span className="select-roll-out">{roll.from}</span>
          <span className="select-roll-in">{roll.to}</span>
        </span>
      ) : null}
    </span>
  )
}

function SelectTrigger({
  className,
  size = "default",
  children,
  ...props
}: SelectPrimitive.Trigger.Props & {
  size?: "sm" | "default"
}) {
  return (
    <SelectPrimitive.Trigger
      data-slot="select-trigger"
      data-size={size}
      className={cn(
        "flex w-fit items-center justify-between gap-inline-sm rounded-(--field-corner) border-solid border-(length:--field-stroke-width) border-(--field-stroke-color) bg-(--field-container) hover:bg-(--field-container-hover) py-(--field-padding-y) pe-(--field-padding-x) ps-(--field-padding-x) text-sm whitespace-nowrap shadow-(--field-elevation) outline-none transition-[background-color,box-shadow] duration-(--duration-fast) ease-(--ease-out) select-none focus-visible:bg-(--field-container-focus) focus-visible:shadow-(--field-focus-shadow) disabled:cursor-not-allowed disabled:bg-(--field-container-disabled) disabled:text-(--field-label-disabled) disabled:shadow-none data-placeholder:text-(--field-placeholder) data-[size=default]:h-(--field-height-md) data-[size=sm]:h-control-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-icon-sm",
        className
      )}
      {...props}
    >
      {children}
      <SelectPrimitive.Icon
        render={
          <ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
        }
      />
    </SelectPrimitive.Trigger>
  )
}

function SelectContent({
  className,
  children,
  side = "bottom",
  sideOffset = 4,
  align = "center",
  alignOffset = 0,
  alignItemWithTrigger = false,
  ...props
}: SelectPrimitive.Popup.Props &
  Pick<
    SelectPrimitive.Positioner.Props,
    "align" | "alignOffset" | "side" | "sideOffset" | "alignItemWithTrigger"
  >) {
  return (
    <SelectPrimitive.Portal>
      <SelectPrimitive.Positioner
        side={side}
        sideOffset={sideOffset}
        align={align}
        alignOffset={alignOffset}
        alignItemWithTrigger={alignItemWithTrigger}
        className="isolate z-(--z-dropdown)"
      >
        <SelectPrimitive.Popup
          data-slot="select-content"
          data-align-trigger={alignItemWithTrigger}
          className={cn(
            "menu-scroll grow-from-origin relative isolate z-(--z-dropdown) h-auto max-h-(--available-height) w-(--anchor-width) min-w-36 overflow-x-hidden overflow-y-auto rounded-(--menu-corner) bg-(--menu-container) p-(--space-2) text-foreground shadow-(--menu-elevation) outline-none",
            className
          )}
          {...props}
        >
          <SelectHighlight>{children}</SelectHighlight>
        </SelectPrimitive.Popup>
      </SelectPrimitive.Positioner>
    </SelectPrimitive.Portal>
  )
}

function SelectHighlight({ children }: { children: React.ReactNode }) {
  const ref = React.useRef<HTMLDivElement>(null)
  const [box, setBox] = React.useState({ top: 0, height: 0 })
  const [ready, setReady] = React.useState(false)

  React.useLayoutEffect(() => {
    const root = ref.current
    if (!root) return
    const read = () => {
      const items = [...root.querySelectorAll<HTMLElement>("[data-slot=select-item]")]
      const item = items.find((entry) => entry.hasAttribute("data-highlighted"))
      if (!item) return
      setBox({ top: layoutTop(item, root), height: item.offsetHeight })
      setReady(true)
    }
    read()
    const observer = new MutationObserver(read)
    observer.observe(root, { subtree: true, attributes: true, attributeFilter: ["data-highlighted"] })
    const resize = new ResizeObserver(read)
    resize.observe(root)
    return () => {
      observer.disconnect()
      resize.disconnect()
    }
  }, [])

  return (
    <div ref={ref} className="relative">
      {ready ? (
        <span
          aria-hidden
          className="select-pill pointer-events-none absolute right-0 left-0 rounded-(--menu-item-corner) bg-(--menu-item-highlight)"
          style={{ top: box.top, height: box.height }}
        />
      ) : null}
      <SelectPrimitive.List>{children}</SelectPrimitive.List>
    </div>
  )
}

function SelectLabel({
  className,
  ...props
}: SelectPrimitive.GroupLabel.Props) {
  return (
    <SelectPrimitive.GroupLabel
      data-slot="select-label"
      className={cn("px-1.5 py-1 text-xs text-muted-foreground", className)}
      {...props}
    />
  )
}

function SelectItem({
  className,
  children,
  ...props
}: SelectPrimitive.Item.Props) {
  return (
    <SelectPrimitive.Item
      data-slot="select-item"
      className={cn(
        "select-item relative z-[1] flex w-full cursor-default items-center gap-inline-sm rounded-(--menu-item-corner) py-(--space-inset-control-y) pr-8 pl-(--menu-item-padding-x) text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:text-(--menu-item-label-disabled)",
        className
      )}
      {...props}
    >
      <SelectPrimitive.ItemText className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">
        {children}
      </SelectPrimitive.ItemText>
      <SelectPrimitive.ItemIndicator
        render={
          <span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
        }
      >
        <CheckIcon className="pointer-events-none" />
      </SelectPrimitive.ItemIndicator>
    </SelectPrimitive.Item>
  )
}

function SelectSeparator({
  className,
  ...props
}: SelectPrimitive.Separator.Props) {
  return (
    <SelectPrimitive.Separator
      data-slot="select-separator"
      className={cn("pointer-events-none my-1 h-stack-sm", className)}
      {...props}
    />
  )
}

export {
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectLabel,
  SelectSeparator,
  SelectTrigger,
  SelectValue,
}
components/ui/native-select.tsx
import * as React from "react"
import { cn } from "cn"
import { ChevronDownIcon } from "lucide-react"

type NativeSelectProps = Omit<React.ComponentProps<"select">, "size"> & {
  size?: "sm" | "default"
}

function NativeSelect({ className, size = "default", ...props }: NativeSelectProps) {
  return (
    <div
      className={cn("relative w-fit", className)}
      data-slot="native-select-wrapper"
      data-size={size}
    >
      <select
        data-slot="native-select"
        data-size={size}
        className="h-(--field-height-md) w-full min-w-40 appearance-none rounded-(--field-corner) border-solid border-(length:--field-stroke-width) border-(--field-stroke-color) bg-(--field-container) hover:bg-(--field-container-hover) pr-8 ps-(--field-padding-x) text-sm text-(--field-label) shadow-(--field-elevation) outline-none transition-[background-color,box-shadow] duration-(--duration-fast) ease-(--ease-out) focus-visible:bg-(--field-container-focus) focus-visible:shadow-(--field-focus-shadow) disabled:cursor-not-allowed disabled:bg-(--field-container-disabled) disabled:text-(--field-label-disabled) disabled:shadow-none data-[size=sm]:h-control-sm"
        {...props}
      />
      <ChevronDownIcon
        className="pointer-events-none absolute top-1/2 right-3 size-icon-sm -translate-y-1/2 text-muted-foreground"
        aria-hidden
        data-slot="native-select-icon"
      />
    </div>
  )
}

function NativeSelectOption({ className, ...props }: React.ComponentProps<"option">) {
  return <option data-slot="native-select-option" className={className} {...props} />
}

function NativeSelectOptGroup({ className, ...props }: React.ComponentProps<"optgroup">) {
  return <optgroup data-slot="native-select-optgroup" className={className} {...props} />
}

export { NativeSelect, NativeSelectOptGroup, NativeSelectOption }