Veil UI
Components

Select

A native-style single select built on Radix Select.

Installation

$ npx veil-ui@latest add select

Usage

import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select";

<Select defaultValue="weekly">
  <SelectTrigger aria-label="Frequency">
    <SelectValue />
  </SelectTrigger>
  <SelectContent>
    <SelectItem value="daily">Daily</SelectItem>
    <SelectItem value="weekly">Weekly</SelectItem>
  </SelectContent>
</Select>;

Examples

Basic

Groups

Disabled

API reference

The package exports select along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.

Accessibility

  • The trigger is a labelled combobox; typeahead and arrow keys navigate items, Escape closes the popup.
  • Error and disabled states are exposed through native attributes and Radix data attributes.
  • Focus-visible rings follow the shared token system in both themes.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add select --framework vue or switch the framework in components.json.

<script setup lang="ts">
import {
  SelectContent,
  SelectPortal,
  SelectScrollDownButton,
  SelectScrollUpButton,
  SelectViewport,
} from "reka-ui";
import { ChevronDown, ChevronUp } from "lucide-vue-next";

import { cn } from "@/lib/utils";

defineOptions({ inheritAttrs: false });

const props = withDefaults(
  defineProps<{
    class?: string;
    position?: "item-aligned" | "popper";
  }>(),
  { position: "popper" },
);
</script>

<template>
  <SelectPortal>
    <SelectContent
      v-bind="$attrs"
      data-slot="select-content"
      :position="position"
      align="center"
      :side-offset="4"
      :class="
        cn(
          'relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md',
          'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=bottom]:slide-out-to-top-2 data-[side=top]:slide-out-to-bottom-2 data-[side=left]:slide-out-to-right-2 data-[side=right]:slide-out-to-left-2 origin-[var(--reka-select-content-transform-origin)]',
          position === 'popper' &&
            'w-[var(--reka-select-trigger-width)] min-w-[var(--reka-select-trigger-width)]',
          props.class,
        )
      "
    >
      <SelectScrollUpButton
        data-slot="select-scroll-up"
        class="flex h-6 items-center justify-center"
      >
        <ChevronUp class="size-4" />
      </SelectScrollUpButton>
      <SelectViewport class="p-1">
        <slot />
      </SelectViewport>
      <SelectScrollDownButton
        data-slot="select-scroll-down"
        class="flex h-6 items-center justify-center"
      >
        <ChevronDown class="size-4" />
      </SelectScrollDownButton>
    </SelectContent>
  </SelectPortal>
</template>

On this page