Skip to content
VinUIComponentsNative Select

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.

native-select-basic.html
<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>

Sizes

The same three heights as Input and Button.

native-select-sizes.html
<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>

Error and disabled

Errors and hints work exactly like they do on Input.

Pick a role to continue.

native-select-states.html
<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>

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:

Terminal
npx @vinish/ui add native-select
React
import { NativeSelect } from "@/components/vin/native-select";
Vue
import NativeSelect from "@/components/vin/native-select.vue";
Svelte
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.

PropValuesDefaultIn HTML
sizesmmdlgmdvin-input--{value}
label
Visible label. Without it, pass an aria-label.
ReactNode—<label class="vin-label" for="…">
hint
Help text under the select.
ReactNode—<p class="vin-hint" id="…"> + aria-describedby
error
An error message. Also marks the select invalid.
ReactNode—<p class="vin-error"> + aria-invalid="true"
disabledbooleanfalsedisabled attribute

Parts

React, Vue, SvelteHTML 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.