Design system / Molecules
Molecule / Selection
Select
Select combines a trigger, displayed value and option list for one selection. Radix manages selection and disclosure unless controlled. The caller supplies options, field labeling, validation and persistence.
Live example
Current component with fictional data. Example changes are not persisted.
Responsibility
Trigger, value display and portaled options complete one selection concern. The caller supplies the options and a persistent field label. The surrounding form owns validation and other field coordination.
Public contract
The table describes supported inputs, exported parts and caller responsibilities. A callback supplies a command, such as saving a draft. These notes are maintained manually; check current source types before integration.
| Prop / part | Type | Requirement | Responsibility |
|---|---|---|---|
| value / defaultValue / onValueChange | Radix Root props | Optional | Controlled or uncontrolled selected string; use onValueChange to bind consumer state. |
| open / defaultOpen / onOpenChange | Radix Root props | Optional | Controlled or primitive-owned disclosure state. |
| size | "sm" | "default" | Trigger · default default | A local trigger size, not a Root prop. |
| position / align | Radix Content props | Defaults item-aligned / center | Popup positioning; Content renders a portal and scroll controls. |
| value / disabled | Radix Item props | Item value required | Consumer supplies the options and unavailable-item policy. |
API notes are curated documentation, not generated types. The source linked above is the current implementation; update these notes alongside API changes.
State and behavior
Identify which values the caller controls and which behavior the component or underlying primitive owns. A local example does not supply persistence, authorization or a complete product lifecycle.
Radix owns selection/open mechanics unless controlled. The consumer owns option data, field value, validation and persistence. ProgramOperations binds value and onValueChange to local edition-creation state; no fetching hook lives in Select.
Dependencies
- Radix Select Root, Trigger, Value, Content and Item
- Portal, viewport and scroll buttons
- Lucide Check and chevrons
- cn()
Token and styling contract
These notes identify theme roles, utilities and direct style values used by the source. Direct colors or timings are implementation exceptions, not recommendations to bypass the theme.
border-input / ring-ring / aria-invalid:border-destructive- Trigger boundary, focus and invalid state.
bg-popover / text-popover-foreground- Portaled content.
bg-accent / text-accent-foreground- Focused option treatment.
text-md / h-9 / h-8- Local compact typography and trigger sizes.
Boundaries and limitations
- No loading, remote search or error-message contract is added by this wrapper.
- SelectLabel labels an option group, not the external field. Supply a persistent field label.
Where to make a change
Change trigger/content/option presentation in select.tsx. Keep field options and scope business rules in the feature; keep requests in its behavior/service seam. Primitive API changes require reviewing all assemblies, not just SelectTrigger.
Selected real uses
ProgramOperations
The Scope label targets scope-level on SelectTrigger. The root receives edition-creation state and its setter, and the options come from SCOPE_LEVELS.
Repository path: src/app/(tenants)/console/[tenantCode]/admin/programs/[programCode]/program-operations.tsx
These traces describe selected uses, not every dependency. Repository-only paths are shown as references; only approved files have public source views.
Usage contract
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "@/components/ui/select";
<label htmlFor="scope">Scope</label>
<Select value={scope} onValueChange={setScope}>
<SelectTrigger id="scope"><SelectValue /></SelectTrigger>
<SelectContent><SelectItem value="global">Global</SelectItem></SelectContent>
</Select>Illustrative consumer bindings, not a self-contained product workflow. Live examples supply only local state or explicit fictional props.