Park UI Logo
GitHub
Components
Select

Select

Displays a list of options for the user to pick from.

'use client'
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react'
import { Select, createListCollection } from '~/components/ui/select'

const collection = createListCollection({
  items: [
    { label: 'React', value: 'react' },
    { label: 'Solid', value: 'solid' },
    { label: 'Vue', value: 'vue' },
    { label: 'Svelte', value: 'svelte', disabled: true },
  ],
})

export const Demo = (props: Select.RootProps) => {
  return (
    <Select.Root positioning={{ sameWidth: true }} width="2xs" {...props} collection={collection}>
      <Select.Label>Framework</Select.Label>
      <Select.Control>
        <Select.Trigger>
          <Select.ValueText placeholder="Select a Framework" />
          <ChevronsUpDownIcon />
        </Select.Trigger>
      </Select.Control>
      <Select.Positioner>
        <Select.Content>
          <Select.ItemGroup>
            <Select.ItemGroupLabel>Framework</Select.ItemGroupLabel>
            {collection.items.map((item) => (
              <Select.Item key={item.value} item={item}>
                <Select.ItemText>{item.label}</Select.ItemText>
                <Select.ItemIndicator>
                  <CheckIcon />
                </Select.ItemIndicator>
              </Select.Item>
            ))}
          </Select.ItemGroup>
        </Select.Content>
      </Select.Positioner>
    </Select.Root>
  )
}

Usage

import { Select, createListCollection } from '~/components/ui/select'

Installation

npx @park-ui/cli components add select