Skip to contentVibraUI
Inputs & filters

Native select

The browser's own select with the kit's field shape and a chevron.

A real select element — the platform's own picker on a phone — with its boundary at --input and a chevron drawn over it, as in shadcn's base-nova. Vibra focuses it with the kit's solid 2px accent outline, as it does Input and Select, where shadcn's draws a translucent halo, and keeps its padding and the chevron on the inline axis, so a right-to-left select mirrors. It stands on the card plane in both themes, as Input and the Select trigger do, where shadcn's wears a translucent input tint in the dark that reads a step lighter than the fields beside it. className styles the wrapper that holds the chevron; every other prop reaches the select.

Install

npx shadcn@latest add @vibra/native-select

Needs the @vibra registry in your components.json — set it up once.

Examples

Small, in a table footer

size="sm" beside the page buttons: as wide as its longest number, and the phone's own picker where it matters most.

Beside its label

Settings rows: the label and its hint at the start, the select at the end and described by the hint; the row stacks on a phone.

Required, with an error

A prompt that can't be picked again; sending without a role marks the field invalid, points it at the message and moves the focus to it.

Disabled, with the reason

A setting fixed at creation still shows its value, and the line under it says why and where it can change.

A time range

Two selects read as a sentence, each labelled, in a fieldset named for the range; the line under them counts the hours across midnight.

Dependent on another

The region follows the country — its label, its options — starts over when the country changes, and says why it waits.

Right to left

The demo's currency in Arabic: the value starts at the right, the chevron and the room for it keep the inline end.

Props

PropTypeDefaultDescription
size"sm" | "default""default"32px tall, or 28px for a toolbar.
classNamestring—Styles the wrapper, not the select: give the width there (w-full) and the select fills it.
disabledbooleanfalseDims the field and takes it out of the tab order, so write why beside it.
NativeSelectOption.disabled + hiddenboolean—On an empty first option (value=""), a prompt that shows until something is chosen and can never be picked again.

Dependencies

Source

components/ui/native-select.tsx
import * as React from "react"
import { cn } from "@/lib/utils"
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(
        "group/native-select relative w-fit has-[select:disabled]:opacity-50",
        className
      )}
      data-slot="native-select-wrapper"
      data-size={size}
    >
      {/* On the card plane in both themes, as Input and the Select trigger are,
          so a form's fields stand on one surface side by side. */}
      <select
        data-slot="native-select"
        data-size={size}
        className="h-8 w-full min-w-0 appearance-none rounded-lg border border-input bg-card py-1 ps-2.5 pe-8 text-sm transition-colors select-none focus-ring selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[size=sm]:py-0.5 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40"
        {...props}
      />
      <ChevronDownIcon className="pointer-events-none absolute top-1/2 end-2.5 size-4 -translate-y-1/2 text-muted-foreground select-none" aria-hidden="true" data-slot="native-select-icon" />
    </div>
  )
}

function NativeSelectOption({
  className,
  ...props
}: React.ComponentProps<"option">) {
  return (
    <option
      data-slot="native-select-option"
      className={cn("bg-[Canvas] text-[CanvasText]", className)}
      {...props}
    />
  )
}

function NativeSelectOptGroup({
  className,
  ...props
}: React.ComponentProps<"optgroup">) {
  return (
    <optgroup
      data-slot="native-select-optgroup"
      className={cn("bg-[Canvas] text-[CanvasText]", className)}
      {...props}
    />
  )
}

export { NativeSelect, NativeSelectOptGroup, NativeSelectOption }