Native Select
The browser's own select, styled to match your inputs. No JavaScript needed. Same markup and props in every style: switch the style in the header to see it change.
Basic
A <select> with the Input classes plus vin-native-select. The menu is the browser's own, so it works with every keyboard, screen reader and phone.
Used for tax and currency.
<div class="vin-field" style="width: 100%; max-width: 320px">
<label class="vin-label" for="country">Country</label>
<select id="country" class="vin-input vin-native-select" aria-describedby="country-hint">
<option>India</option>
<option>United Kingdom</option>
<option>United States</option>
<option>Germany</option>
</select>
<p class="vin-hint" id="country-hint">Used for tax and currency.</p>
</div>Used for tax and currency.
import { NativeSelect } from "@/components/vin/native-select";
export function NativeSelectBasic() {
return (
<NativeSelect label="Country" hint="Used for tax and currency." style={{ width: "100%", maxWidth: 320 }}>
<option>India</option>
<option>United Kingdom</option>
<option>United States</option>
<option>Germany</option>
</NativeSelect>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import NativeSelect from "@/components/vin/native-select.vue";
</script>
<template>
<NativeSelect label="Country" hint="Used for tax and currency." style="width: 100%; max-width: 320px">
<option>India</option>
<option>United Kingdom</option>
<option>United States</option>
<option>Germany</option>
</NativeSelect>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import NativeSelect from "$lib/components/vin/native-select.svelte";
</script>
<NativeSelect label="Country" hint="Used for tax and currency." style="width: 100%; max-width: 320px">
<option>India</option>
<option>United Kingdom</option>
<option>United States</option>
<option>Germany</option>
</NativeSelect>Sizes
The same three heights as Input and Button.
<div style="display: grid; gap: 12px; width: 100%; max-width: 240px">
<select class="vin-input vin-native-select vin-input--sm" aria-label="Small"><option>Small</option><option>Medium</option></select>
<select class="vin-input vin-native-select" aria-label="Medium"><option>Medium</option><option>Small</option></select>
<select class="vin-input vin-native-select vin-input--lg" aria-label="Large"><option>Large</option><option>Medium</option></select>
</div>import { NativeSelect } from "@/components/vin/native-select";
export function NativeSelectSizes() {
return (
<div style={{ display: "grid", gap: 12, width: "100%", maxWidth: 240 }}>
<NativeSelect size="sm" aria-label="Small"><option>Small</option><option>Medium</option></NativeSelect>
<NativeSelect aria-label="Medium"><option>Medium</option><option>Small</option></NativeSelect>
<NativeSelect size="lg" aria-label="Large"><option>Large</option><option>Medium</option></NativeSelect>
</div>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import NativeSelect from "@/components/vin/native-select.vue";
</script>
<template>
<div style="display: grid; gap: 12px; width: 100%; max-width: 240px">
<NativeSelect size="sm" aria-label="Small"><option>Small</option><option>Medium</option></NativeSelect>
<NativeSelect aria-label="Medium"><option>Medium</option><option>Small</option></NativeSelect>
<NativeSelect size="lg" aria-label="Large"><option>Large</option><option>Medium</option></NativeSelect>
</div>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import NativeSelect from "$lib/components/vin/native-select.svelte";
</script>
<div style="display: grid; gap: 12px; width: 100%; max-width: 240px">
<NativeSelect size="sm" aria-label="Small"><option>Small</option><option>Medium</option></NativeSelect>
<NativeSelect aria-label="Medium"><option>Medium</option><option>Small</option></NativeSelect>
<NativeSelect size="lg" aria-label="Large"><option>Large</option><option>Medium</option></NativeSelect>
</div>Error and disabled
Errors and hints work exactly like they do on Input.
Pick a role to continue.
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
<div class="vin-field">
<label class="vin-label" for="ns-role">Role</label>
<select id="ns-role" class="vin-input vin-native-select" aria-invalid="true" aria-describedby="ns-role-error">
<option value="">Choose a role</option>
<option>Admin</option>
<option>Editor</option>
</select>
<p class="vin-error" id="ns-role-error">Pick a role to continue.</p>
</div>
<div class="vin-field">
<label class="vin-label" for="ns-region">Region</label>
<select id="ns-region" class="vin-input vin-native-select" disabled><option>Mumbai</option></select>
</div>
</div>Pick a role to continue.
import { NativeSelect } from "@/components/vin/native-select";
export function NativeSelectStates() {
return (
<div style={{ display: "grid", gap: 16, width: "100%", maxWidth: 320 }}>
<NativeSelect label="Role" error="Pick a role to continue." defaultValue="">
<option value="">Choose a role</option>
<option>Admin</option>
<option>Editor</option>
</NativeSelect>
<NativeSelect label="Region" disabled><option>Mumbai</option></NativeSelect>
</div>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import NativeSelect from "@/components/vin/native-select.vue";
</script>
<template>
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
<NativeSelect label="Role" error="Pick a role to continue.">
<option value="">Choose a role</option>
<option>Admin</option>
<option>Editor</option>
</NativeSelect>
<NativeSelect label="Region" disabled><option>Mumbai</option></NativeSelect>
</div>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import NativeSelect from "$lib/components/vin/native-select.svelte";
</script>
<div style="display: grid; gap: 16px; width: 100%; max-width: 320px">
<NativeSelect label="Role" error="Pick a role to continue." value="">
<option value="">Choose a role</option>
<option>Admin</option>
<option>Editor</option>
</NativeSelect>
<NativeSelect label="Region" disabled><option>Mumbai</option></NativeSelect>
</div>Installation
React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:
npx @vinish/ui add native-selectimport { NativeSelect } from "@/components/vin/native-select";import NativeSelect from "@/components/vin/native-select.vue";import NativeSelect from "$lib/components/vin/native-select.svelte";The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.
Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.
API
From spec/native-select.json, which every framework version is tested against.
| Prop | Values | Default | In HTML |
|---|---|---|---|
size | smmdlg | md | vin-input--{value} |
labelVisible label. Without it, pass an aria-label. | ReactNode | — | <label class="vin-label" for="…"> |
hintHelp text under the select. | ReactNode | — | <p class="vin-hint" id="…"> + aria-describedby |
errorAn error message. Also marks the select invalid. | ReactNode | — | <p class="vin-error"> + aria-invalid="true" |
disabled | boolean | false | disabled attribute |
Parts
| React, Vue, Svelte | HTML classes |
|---|---|
<NativeSelect> | .vin-native-select |
Accessibility
- A native <select>: full keyboard, screen reader and touch support from the browser.
- Every select has a label: a <label for> or an aria-label.
- Errors set aria-invalid="true" and are linked with aria-describedby.
- Use Native Select when you don't need custom option content; it is the most robust choice.
Customize
Saved in this browser. Style and accent are in the header.