WFP logoDesign System

Native Select

View on shadcn/ui

A native HTML select element with custom styling.

Installation

pnpm dlx shadcn@latest add https://designsystem.wfp.org/r/native-select.json

Usage

import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select";
<NativeSelect>
  <NativeSelectOption value="">Select a fruit</NativeSelectOption>
  <NativeSelectOption value="apple">Apple</NativeSelectOption>
  <NativeSelectOption value="banana">Banana</NativeSelectOption>
</NativeSelect>

Examples

With groups

Organize options using NativeSelectOptGroup for better categorization.

Disabled state

Disable individual options or the entire select component.

Invalid state

Show validation errors with the aria-invalid attribute and error styling.

API reference

NativeSelect

PropTypeDefaultDescription
classNamestring-Additional CSS classes
disabledbooleanfalseWhether the select is disabled
valuestring-Controlled value
onChangefunction-Change event handler

All standard HTML select attributes are supported.

NativeSelectOption

PropTypeDefaultDescription
valuestring-Value of the option
disabledbooleanfalseWhether option is disabled

All standard HTML option attributes are supported.

NativeSelectOptGroup

PropTypeDefaultDescription
labelstring-Label for the option group
classNamestring-Additional CSS classes

All standard HTML optgroup attributes are supported.