Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Select

    Dropdown built on a styled native select, with a label, hint, and error message.

    Choose your city.

    Role is required.

    Choose your city.

    Role is required.

    Choose your city.

    Role is required.

    Choose your city.

    Role is required.

    Choose your city.

    Role is required.

    <div class="grid gap-4">
        <x-markas.select name="city" label="City" hint="Choose your city.">
            <option value="jakarta">Jakarta</option>
            <option value="bandung" selected>Bandung</option>
            <option value="surabaya">Surabaya</option>
        </x-markas.select>
        <x-markas.select name="role" label="Role" error="Role is required.">
            <option value="">Choose a role</option>
            <option value="admin">Admin</option>
            <option value="editor">Editor</option>
        </x-markas.select>
        <x-markas.select name="plan" label="Plan" disabled>
            <option value="free">Free</option>
        </x-markas.select>
    </div>
    import { Select } from "@/components/markas/Select";
    
    export default function SelectExample() {
      return (
        <div className="grid gap-4">
          <Select
            name="city"
            label="City"
            hint="Choose your city."
            defaultValue="bandung"
          >
            <option value="jakarta">Jakarta</option>
            <option value="bandung">Bandung</option>
            <option value="surabaya">Surabaya</option>
          </Select>
          <Select name="role" label="Role" error="Role is required.">
            <option value="">Choose a role</option>
            <option value="admin">Admin</option>
            <option value="editor">Editor</option>
          </Select>
          <Select name="plan" label="Plan" disabled>
            <option value="free">Free</option>
          </Select>
        </div>
      );
    }
    <script setup lang="ts">
    import { ref } from "vue";
    import Select from "@/components/markas/Select.vue";
    
    const city = ref("bandung");
    const role = ref("");
    const plan = ref("free");
    </script>
    
    <template>
      <div class="grid gap-4">
        <Select v-model="city" name="city" label="City" hint="Choose your city.">
          <option value="jakarta">Jakarta</option>
          <option value="bandung">Bandung</option>
          <option value="surabaya">Surabaya</option>
        </Select>
        <Select v-model="role" name="role" label="Role" error="Role is required.">
          <option value="">Choose a role</option>
          <option value="admin">Admin</option>
          <option value="editor">Editor</option>
        </Select>
        <Select v-model="plan" name="plan" label="Plan" disabled>
          <option value="free">Free</option>
        </Select>
      </div>
    </template>
    <script lang="ts">
      import Select from "$lib/components/markas/Select.svelte";
    
      let city = $state("bandung");
      let role = $state("");
      let plan = $state("free");
    </script>
    
    <div class="grid gap-4">
      <Select bind:value={city} name="city" label="City" hint="Choose your city.">
        <option value="jakarta">Jakarta</option>
        <option value="bandung">Bandung</option>
        <option value="surabaya">Surabaya</option>
      </Select>
      <Select bind:value={role} name="role" label="Role" error="Role is required.">
        <option value="">Choose a role</option>
        <option value="admin">Admin</option>
        <option value="editor">Editor</option>
      </Select>
      <Select bind:value={plan} name="plan" label="Plan" disabled>
        <option value="free">Free</option>
      </Select>
    </div>
    ---
    import Select from "@/components/markas/Select.astro";
    ---
    
    <div class="grid gap-4">
      <Select name="city" label="City" hint="Choose your city.">
        <option value="jakarta">Jakarta</option>
        <option value="bandung" selected>Bandung</option>
        <option value="surabaya">Surabaya</option>
      </Select>
      <Select name="role" label="Role" error="Role is required.">
        <option value="">Choose a role</option>
        <option value="admin">Admin</option>
        <option value="editor">Editor</option>
      </Select>
      <Select name="plan" label="Plan" disabled>
        <option value="free">Free</option>
      </Select>
    </div>
    import { Component, signal } from "@angular/core";
    import { Select } from "./markas/select.component";
    
    @Component({
      selector: "markas-example",
      imports: [Select],
      template: `
        <div class="grid gap-4">
          <markas-select
            [(value)]="city"
            name="city"
            label="City"
            hint="Choose your city."
          >
            <option value="jakarta">Jakarta</option>
            <option value="bandung">Bandung</option>
            <option value="surabaya">Surabaya</option>
          </markas-select>
          <markas-select
            [(value)]="role"
            name="role"
            label="Role"
            error="Role is required."
          >
            <option value="">Choose a role</option>
            <option value="admin">Admin</option>
            <option value="editor">Editor</option>
          </markas-select>
          <markas-select [(value)]="plan" name="plan" label="Plan" disabled>
            <option value="free">Free</option>
          </markas-select>
        </div>
      `,
    })
    export default class SelectExample {
      readonly city = signal("bandung");
      readonly role = signal("");
      readonly plan = signal("free");
    }

    Examples

    Placeholder

    Used to calculate tax on your invoices.

    Choose the industry that fits best.

    Used to calculate tax on your invoices.

    Choose the industry that fits best.

    Used to calculate tax on your invoices.

    Choose the industry that fits best.

    Used to calculate tax on your invoices.

    Choose the industry that fits best.

    Used to calculate tax on your invoices.

    Choose the industry that fits best.

    Option groups

    Meeting times are shown in this time zone.

    Meeting times are shown in this time zone.

    Meeting times are shown in this time zone.

    Meeting times are shown in this time zone.

    Meeting times are shown in this time zone.

    With icon

    Side by side

    Date of birth
    Date of birth
    Date of birth
    Date of birth
    Date of birth

    Installation

    npx markasui@latest add select

    Usage

    <x-markas.select name="city" label="City" hint="Choose your city.">
        <option value="jakarta">Jakarta</option>
        <option value="bandung" @selected(old('city') === 'bandung')>Bandung</option>
    </x-markas.select>
    import { Select } from "@/components/markas/Select";
    
    <Select name="city" label="City" defaultValue="bandung">
      <option value="jakarta">Jakarta</option>
      <option value="bandung">Bandung</option>
    </Select>;
    <script setup lang="ts">
    import { ref } from "vue";
    import Select from "@/components/markas/Select.vue";
    
    const city = ref("bandung");
    </script>
    
    <template>
      <Select v-model="city" name="city" label="City">
        <option value="jakarta">Jakarta</option>
        <option value="bandung">Bandung</option>
      </Select>
    </template>
    <script lang="ts">
      import Select from "$lib/components/markas/Select.svelte";
    
      let city = $state("bandung");
    </script>
    
    <Select bind:value={city} name="city" label="City">
      <option value="jakarta">Jakarta</option>
      <option value="bandung">Bandung</option>
    </Select>
    ---
    import Select from "@/components/markas/Select.astro";
    ---
    
    <Select name="city" label="City">
      <option value="jakarta">Jakarta</option>
      <option value="bandung" selected>Bandung</option>
    </Select>

    No client script: the select is a native element.

    import { Component, signal } from "@angular/core";
    import { Select } from "./markas/select.component";
    
    @Component({
      selector: "app-address",
      imports: [Select],
      template: `
        <markas-select [(value)]="city" name="city" label="City">
          <option value="jakarta">Jakarta</option>
          <option value="bandung">Bandung</option>
        </markas-select>
      `,
    })
    export class Address {
      readonly city = signal("bandung");
    }
    • Extra attributes (name, required, multiple, class) go to the <select> element.
    • Without v-model, the Vue version selects the option marked selected, or the first option, just like Blade and React.
    • The component has no built-in text. Every visible string comes from your props and options, so translate them directly.

    Props

    NameTypeDefaultDescription
    labelstring-Label text linked to the select through for/id.
    hintstring-Hint text below the select. Hidden while an error is shown.
    errorstring-Error message. Turns on aria-invalid and the danger border.
    slot / children<option>-Native option (and optgroup) elements.
    value / defaultValue / v-model / bind:valuestring-Selected value. Blade and Astro use the selected attribute on an option, React value or defaultValue, Vue v-model, Svelte bind:value, Angular value or [(value)].
    idstringautoSelect id. Generated when empty.

    Accessibility

    • Uses the native select element, so keyboard and screen readers work without JavaScript.
    • The label is linked through for and id, the hint and error through aria-describedby.
    • The arrow icon is hidden from screen readers and does not catch clicks.

    Related components

    More form components with the same classes in every framework.