Skip to content
Statix Design System

Forms

Native Select

A styled browser <select>. It opens the system picker, which works best on phones and with long lists such as countries.

import { NativeSelect, NativeSelectOption, NativeSelectOptGroup } from '@statix/ui/native-select';

Playground

Controls
<NativeSelect>
	<NativeSelectOption value="DE">Germany</NativeSelectOption>
	<NativeSelectOption value="AT">Austria</NativeSelectOption>
</NativeSelect>

Examples

Basic

Bind the value. The wrapper is w-fit by default; pass wrapperClass="w-full" to fill the column.

<script lang="ts">
	import { Label } from '@statix/ui/label';
	import { NativeSelect, NativeSelectOption } from '@statix/ui/native-select';

	let country = $state('DE');
</script>

<div class="flex w-full max-w-xs flex-col gap-2">
	<Label for="ns-country">Country</Label>
	<NativeSelect id="ns-country" bind:value={country} autocomplete="country" wrapperClass="w-full">
		<NativeSelectOption value="DE">Germany</NativeSelectOption>
		<NativeSelectOption value="AT">Austria</NativeSelectOption>
		<NativeSelectOption value="CH">Switzerland</NativeSelectOption>
		<NativeSelectOption value="NL">Netherlands</NativeSelectOption>
	</NativeSelect>
</div>

Option groups

NativeSelectOptGroup renders an <optgroup>.

<script lang="ts">
	import { Label } from '@statix/ui/label';
	import { NativeSelect, NativeSelectOptGroup, NativeSelectOption } from '@statix/ui/native-select';
</script>

<div class="flex w-full max-w-xs flex-col gap-2">
	<Label for="ns-backup">Daily backup at</Label>
	<NativeSelect id="ns-backup" value="03:10" wrapperClass="w-full">
		<NativeSelectOptGroup label="Night (recommended)">
			<NativeSelectOption value="01:00">01:00</NativeSelectOption>
			<NativeSelectOption value="03:10">03:10</NativeSelectOption>
			<NativeSelectOption value="05:00">05:00</NativeSelectOption>
		</NativeSelectOptGroup>
		<NativeSelectOptGroup label="Evening">
			<NativeSelectOption value="21:00">21:00</NativeSelectOption>
			<NativeSelectOption value="23:00">23:00</NativeSelectOption>
		</NativeSelectOptGroup>
	</NativeSelect>
</div>

Sizes and pill

sm (36px), md (44px, default), lg (52px) and the pill variant.

<script lang="ts">
	import { NativeSelect, NativeSelectOption } from '@statix/ui/native-select';
</script>

{#each ['sm', 'md', 'lg'] as const as size (size)}
	<NativeSelect {size} aria-label="Rows per page, size {size}" value="25">
		<NativeSelectOption value="10">10 per page</NativeSelectOption>
		<NativeSelectOption value="25">25 per page</NativeSelectOption>
		<NativeSelectOption value="50">50 per page</NativeSelectOption>
	</NativeSelect>
{/each}
<NativeSelect variant="pill" aria-label="Rows per page, pill" value="25">
	<NativeSelectOption value="10">10 per page</NativeSelectOption>
	<NativeSelectOption value="25">25 per page</NativeSelectOption>
	<NativeSelectOption value="50">50 per page</NativeSelectOption>
</NativeSelect>

Invalid and disabled

aria-invalid turns the border red. A disabled select fades to 60%.

Choose how we should address you on invoices.

<script lang="ts">
	import { Label } from '@statix/ui/label';
	import { NativeSelect, NativeSelectOption } from '@statix/ui/native-select';
</script>

<div class="flex w-full max-w-xs flex-col gap-5">
	<div class="flex flex-col gap-2">
		<Label for="ns-salutation">Salutation</Label>
		<NativeSelect
			id="ns-salutation"
			wrapperClass="w-full"
			aria-invalid="true"
			aria-describedby="ns-salutation-error"
		>
			<NativeSelectOption value="">Choose</NativeSelectOption>
			<NativeSelectOption value="ms">Ms</NativeSelectOption>
			<NativeSelectOption value="mr">Mr</NativeSelectOption>
			<NativeSelectOption value="none">No salutation</NativeSelectOption>
		</NativeSelect>
		<p id="ns-salutation-error" class="text-small text-destructive">
			Choose how we should address you on invoices.
		</p>
	</div>
	<div class="flex flex-col gap-2">
		<Label for="ns-currency">Currency</Label>
		<NativeSelect id="ns-currency" wrapperClass="w-full" disabled>
			<NativeSelectOption value="EUR">Euro (€)</NativeSelectOption>
		</NativeSelect>
	</div>
</div>

Guidelines

Do

  • Use NativeSelect on mobile-first screens and for long, well-known lists such as countries.
  • Use the same labels and layout as Input so forms look even.

Don't

  • Don't try to style the options. Browsers draw the open list themselves.
  • Don't use it when options need icons or descriptions. Use Select.

Accessibility

  • Renders a native <select>, so keyboard, screen reader and autofill support come from the browser.
  • Label it with <Label for> pointing at its id, or aria-label.
  • The chevron icon is decorative and hidden from assistive technology.

API reference

NativeSelect

renders <select> and accepts its attributes

The select inside a wrapper that holds the chevron. class goes on the select, wrapperClass on the wrapper.

PropTypeDefault
value bindany

The selected value.

–
variant 'default' | 'pill'

default has 16px corners. pill is fully rounded.

'default'
size 'sm' | 'md' | 'lg'

Height: 36, 44 or 52px. default is an alias of md.

'md'
ref bindHTMLSelectElement | null

The <select> element.

–
class ClassValue

Merged with the select classes; yours win.

–
wrapperClass ClassValue

Classes for the wrapper, for example w-full.

–
Data attributeMeaning
data-slot="native-select"On the <select>. The wrapper has "native-select-wrapper".
data-size / data-variantThe current size and variant.

NativeSelectOption

renders <option> and accepts its attributes
PropTypeDefault
ref bindHTMLElement | null

The rendered element.

–
class ClassValue

Merged with the default classes; yours win.

–

NativeSelectOptGroup

renders <optgroup> and accepts its attributes
PropTypeDefault
label string

Group heading.

–
ref bindHTMLElement | null

The rendered element.

–
class ClassValue

Merged with the default classes; yours win.

–