Components
Native select
Native select control styled to match the Control UI control family.
Composition
Native options
- <NativeSelect>
- <optgroup>
- <option />
- <optgroup>
Installation
The Control UI source installs this component from src/registry/sources/control-ui/ui/native-select.tsx.
npx shadcn@latest add https://control-ui.dev/r/native-select.jsonDependencies
Control variants
src/registry/sources/control-ui/control-variants.ts
Support
Raw code
Primary installed source
"use client";
import { Input as InputPrimitive } from "@base-ui/react/input";import type { ComponentProps, CSSProperties } from "react";import type { ControlSize } from "@/components/control-ui/control-variants";import type { FieldKnobStyle } from "@/components/control-ui/knob-contracts/field-knobs";import { cn } from "@/components/control-ui/lib/cn";import type { SkinIconProps } from "@/components/control-ui/skin";import { useSkinIcon } from "@/components/control-ui/skin-provider";
export type NativeSelectProps = Omit<Omit<ComponentProps<"select">, "size">, "style"> & { style?: CSSProperties & FieldKnobStyle } & { size?: ControlSize;};
function NativeSelectChevronIcon(props: SkinIconProps) { return ( <svg viewBox="0 0 12 12" fill="none" aria-hidden="true" {...props}> <path d="M3 4.5 6 7.5 9 4.5" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" strokeLinejoin="round" /> </svg> );}
// `className` sizes the wrapper so the select and its chevron follow one width; `style` stays on the select, which carries the field knobs.export function NativeSelect({ ref, id, name, value, defaultValue, disabled, autoFocus, size = "md", className, children, ...props}: NativeSelectProps) { const ChevronDownGlyph = useSkinIcon("chevronDown", NativeSelectChevronIcon); return ( <div data-control-ui="native-select" data-control-family="field" data-field-kind="native-select" data-slot="wrapper" className={cn("relative inline-flex w-full items-center", className)} > <InputPrimitive ref={ref} id={id} name={name} value={value} defaultValue={defaultValue} disabled={disabled} autoFocus={autoFocus} render={ <select {...props} data-control-ui="native-select" data-field-kind="native-select" data-slot="root" data-size={size} data-control-family="field" data-control="true" className="w-full min-w-0" > {children} </select> } /> <span aria-hidden="true" data-control-ui="native-select" data-control-family="field" data-field-kind="native-select" data-slot="icon" className="pointer-events-none absolute" > <ChevronDownGlyph aria-hidden="true" /> </span> </div> );}
Knobs
Typed custom properties the recipe paints with. Set one on the root — style, a utility class, or a skin — and every slot inherits it.
| Knob | Syntax | Default |
|---|---|---|
--cui-field-label-radius | <length-percentage> | var(--radius-control) |
--cui-field-label-background | <color> | transparent |
--cui-field-label-hover-background | <color> | var(--hover-fill) |
--cui-field-label-checked-background | <color> | oklch(from var(--primary) l c h / 0.06) |
--cui-field-label-border-color | <color> | var(--border) |
--cui-field-label-checked-border-color | <color> | var(--primary) |
--cui-field-label-border-width | <length> | var(--control-rim-width) |
--cui-field-label-padding-block | <length-percentage> | calc(var(--spacing) * 3) |
--cui-field-label-padding-inline | <length-percentage> | calc(var(--spacing) * 3) |
--cui-field-legend-foreground | <color> | var(--foreground) |
--cui-field-legend-font-size | <length-percentage> | var(--text-label) |
--cui-field-legend-font-weight | <number> | var(--font-weight-semibold) |
--cui-field-radius | <length-percentage> | var(--nest-radius, var(--radius-control)) |
--cui-field-background | <color> | var(--control-fill) |
--cui-field-hover-background | <color> | var(--hover-fill) |
--cui-field-affordance-background | <color> | transparent |
--cui-field-affordance-shadow | * | 0 0 transparent |
--cui-field-affordance-foreground | <color> | var(--muted-foreground) |
--cui-field-affordance-hover-background | <color> | var(--hover-fill) |
--cui-field-foreground | <color> | var(--foreground) |
--cui-field-border-color | <color> | var(--control-rim) |
--cui-field-focus-border-color | <color> | var(--focus-rim) |
--cui-field-border-width | <length> | var(--control-rim-width) |
--cui-field-shadow | * | var(--shadow-inset) |
--cui-field-backdrop-filter | * | blur(0px) |
--cui-field-height | <length-percentage> | var(--control-h-md) |
--cui-field-padding-inline | <length-percentage> | var(--padding-x) |
--cui-field-font-size | <length-percentage> | var(--text-body) |
--cui-field-font-weight | <number> | var(--font-weight-normal) |
--cui-field-font-family | * | var(--font-body) |
--cui-field-group-radius | <length-percentage> | var(--radius-panel) |
--cui-field-group-background | <color> | var(--card) |
--cui-field-group-border-color | <color> | var(--border) |
--cui-field-group-border-width | <length> | 1px |
--cui-field-group-shadow | * | 0 0 transparent |
--cui-field-group-padding-block | <length-percentage> | calc(var(--spacing) * 3) |
--cui-field-group-padding-inline | <length-percentage> | calc(var(--spacing) * 4) |
--cui-field-group-separator-color | <color> | var(--border) |
--cui-field-group-separator-inset | <length-percentage> | 0px |
--cui-field-label-font-size | <length-percentage> | var(--text-label) |
--cui-field-label-font-weight | <number> | var(--font-weight-medium) |
--cui-field-description-font-size | <length-percentage> | var(--text-caption) |