Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Combobox

    Text input with a filtered suggestion list in a popover, following the WAI-ARIA Combobox pattern with list autocomplete.

    • Australia
    • Indonesia
    • Japan
    • Malaysia
    • Philippines
    • Singapore
    • Thailand
    • Vietnam

    Start typing to filter the list.

    • Australia
    • Indonesia
    • Japan
    • Malaysia
    • Philippines
    • Singapore
    • Thailand
    • Vietnam

    Start typing to filter the list.

    • Australia
    • Indonesia
    • Japan
    • Malaysia
    • Philippines
    • Singapore
    • Thailand
    • Vietnam

    Start typing to filter the list.

    • Australia
    • Indonesia
    • Japan
    • Malaysia
    • Philippines
    • Singapore
    • Thailand
    • Vietnam

    Start typing to filter the list.

    • Australia
    • Indonesia
    • Japan
    • Malaysia
    • Philippines
    • Singapore
    • Thailand
    • Vietnam

    Start typing to filter the list.

    <x-markas.combobox
        name="country"
        label="Country"
        placeholder="Search countries"
        hint="Start typing to filter the list."
        :options="[
            ['value' => 'au', 'label' => 'Australia'],
            ['value' => 'id', 'label' => 'Indonesia'],
            ['value' => 'jp', 'label' => 'Japan'],
            ['value' => 'my', 'label' => 'Malaysia'],
            ['value' => 'ph', 'label' => 'Philippines'],
            ['value' => 'sg', 'label' => 'Singapore'],
            ['value' => 'th', 'label' => 'Thailand'],
            ['value' => 'vn', 'label' => 'Vietnam'],
        ]"
    />
    import { Combobox } from "@/components/markas/Combobox";
    
    const countries = [
      { value: "au", label: "Australia" },
      { value: "id", label: "Indonesia" },
      { value: "jp", label: "Japan" },
      { value: "my", label: "Malaysia" },
      { value: "ph", label: "Philippines" },
      { value: "sg", label: "Singapore" },
      { value: "th", label: "Thailand" },
      { value: "vn", label: "Vietnam" },
    ];
    
    export default function ComboboxExample() {
      return (
        <Combobox
          name="country"
          label="Country"
          placeholder="Search countries"
          hint="Start typing to filter the list."
          options={countries}
        />
      );
    }
    <script setup lang="ts">
    import { ref } from "vue";
    import Combobox from "@/components/markas/Combobox.vue";
    
    const countries = [
      { value: "au", label: "Australia" },
      { value: "id", label: "Indonesia" },
      { value: "jp", label: "Japan" },
      { value: "my", label: "Malaysia" },
      { value: "ph", label: "Philippines" },
      { value: "sg", label: "Singapore" },
      { value: "th", label: "Thailand" },
      { value: "vn", label: "Vietnam" },
    ];
    const country = ref("");
    </script>
    
    <template>
      <Combobox
        v-model="country"
        name="country"
        label="Country"
        placeholder="Search countries"
        hint="Start typing to filter the list."
        :options="countries"
      />
    </template>
    <script lang="ts">
      import Combobox from "$lib/components/markas/Combobox.svelte";
    
      const countries = [
        { value: "au", label: "Australia" },
        { value: "id", label: "Indonesia" },
        { value: "jp", label: "Japan" },
        { value: "my", label: "Malaysia" },
        { value: "ph", label: "Philippines" },
        { value: "sg", label: "Singapore" },
        { value: "th", label: "Thailand" },
        { value: "vn", label: "Vietnam" },
      ];
    </script>
    
    <Combobox
      name="country"
      label="Country"
      placeholder="Search countries"
      hint="Start typing to filter the list."
      options={countries}
    />
    ---
    import Combobox from "@/components/markas/Combobox.astro";
    
    const countries = [
      { value: "au", label: "Australia" },
      { value: "id", label: "Indonesia" },
      { value: "jp", label: "Japan" },
      { value: "my", label: "Malaysia" },
      { value: "ph", label: "Philippines" },
      { value: "sg", label: "Singapore" },
      { value: "th", label: "Thailand" },
      { value: "vn", label: "Vietnam" },
    ];
    ---
    
    <Combobox
      name="country"
      label="Country"
      placeholder="Search countries"
      hint="Start typing to filter the list."
      options={countries}
    />
    import { Component } from "@angular/core";
    import { Combobox } from "./markas/combobox.component";
    
    @Component({
      selector: "markas-example",
      imports: [Combobox],
      template: `
        <markas-combobox
          name="country"
          label="Country"
          placeholder="Search countries"
          hint="Start typing to filter the list."
          [options]="countries"
        />
      `,
    })
    export default class ComboboxExample {
      protected readonly countries = [
        { value: "au", label: "Australia" },
        { value: "id", label: "Indonesia" },
        { value: "jp", label: "Japan" },
        { value: "my", label: "Malaysia" },
        { value: "ph", label: "Philippines" },
        { value: "sg", label: "Singapore" },
        { value: "th", label: "Thailand" },
        { value: "vn", label: "Vietnam" },
      ];
    }

    Examples

    States

    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Only members of this project are listed.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Choose a reviewer before submitting.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari
    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Only members of this project are listed.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Choose a reviewer before submitting.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari
    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Only members of this project are listed.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Choose a reviewer before submitting.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari
    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Only members of this project are listed.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Choose a reviewer before submitting.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari
    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Only members of this project are listed.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Choose a reviewer before submitting.

    • Ana Putri
    • Budi Santoso
    • Citra Lestari

    Preselected value

    • Asia/Jakarta (UTC+7)
    • Asia/Makassar (UTC+8)
    • Asia/Jayapura (UTC+9)
    • Asia/Singapore (UTC+8)
    • Europe/London (UTC+0)
    • America/New_York (UTC-5)

    Used for reminders and report schedules.

    • Asia/Jakarta (UTC+7)
    • Asia/Makassar (UTC+8)
    • Asia/Jayapura (UTC+9)
    • Asia/Singapore (UTC+8)
    • Europe/London (UTC+0)
    • America/New_York (UTC-5)

    Used for reminders and report schedules.

    • Asia/Jakarta (UTC+7)
    • Asia/Makassar (UTC+8)
    • Asia/Jayapura (UTC+9)
    • Asia/Singapore (UTC+8)
    • Europe/London (UTC+0)
    • America/New_York (UTC-5)

    Used for reminders and report schedules.

    • Asia/Jakarta (UTC+7)
    • Asia/Makassar (UTC+8)
    • Asia/Jayapura (UTC+9)
    • Asia/Singapore (UTC+8)
    • Europe/London (UTC+0)
    • America/New_York (UTC-5)

    Used for reminders and report schedules.

    • Asia/Jakarta (UTC+7)
    • Asia/Makassar (UTC+8)
    • Asia/Jayapura (UTC+9)
    • Asia/Singapore (UTC+8)
    • Europe/London (UTC+0)
    • America/New_York (UTC-5)

    Used for reminders and report schedules.

    In a form

    Shipping address

    We deliver to most cities in Southeast Asia.

    • Bandung
    • Jakarta
    • Kuala Lumpur
    • Singapore
    • Surabaya

    Shipping address

    We deliver to most cities in Southeast Asia.

    • Bandung
    • Jakarta
    • Kuala Lumpur
    • Singapore
    • Surabaya

    Shipping address

    We deliver to most cities in Southeast Asia.

    • Bandung
    • Jakarta
    • Kuala Lumpur
    • Singapore
    • Surabaya

    Shipping address

    We deliver to most cities in Southeast Asia.

    • Bandung
    • Jakarta
    • Kuala Lumpur
    • Singapore
    • Surabaya

    Shipping address

    We deliver to most cities in Southeast Asia.

    • Bandung
    • Jakarta
    • Kuala Lumpur
    • Singapore
    • Surabaya

    Installation

    npx markasui@latest add combobox

    Usage

    <x-markas.combobox
        name="country"
        label="Country"
        placeholder="Search countries"
        :value="old('country', 'id')"
        :options="[
            ['value' => 'au', 'label' => 'Australia'],
            ['value' => 'id', 'label' => 'Indonesia'],
            ['value' => 'jp', 'label' => 'Japan'],
        ]"
        :error="$errors->first('country')"
        x-on:markas-change="console.log($event.detail)"
    />

    Needs Alpine.js. Changing the selection dispatches a markas-change event with the value in $event.detail (an empty string when cleared).

    Livewire

    <x-markas.combobox label="Country" wire:model.live="country" :options="$countries" />

    wire:model binds the selected value (not the typed text) through x-modelable. Setting the property on the server shows the matching label. .live sends a request only when an option is picked or cleared, not on every keystroke.

    import { useState } from "react";
    import { Combobox } from "@/components/markas/Combobox";
    
    const [country, setCountry] = useState("id");
    
    <Combobox
      name="country"
      label="Country"
      placeholder="Search countries"
      options={[
        { value: "au", label: "Australia" },
        { value: "id", label: "Indonesia" },
        { value: "jp", label: "Japan" },
      ]}
      value={country}
      onValueChange={setCountry}
    />;
    <script setup lang="ts">
    import { ref } from "vue";
    import Combobox from "@/components/markas/Combobox.vue";
    
    const country = ref("id");
    const countries = [
      { value: "au", label: "Australia" },
      { value: "id", label: "Indonesia" },
      { value: "jp", label: "Japan" },
    ];
    </script>
    
    <template>
      <Combobox
        v-model="country"
        name="country"
        label="Country"
        placeholder="Search countries"
        :options="countries"
      />
    </template>
    <script lang="ts">
      import Combobox from "$lib/components/markas/Combobox.svelte";
    
      let country = $state("id");
      const countries = [
        { value: "au", label: "Australia" },
        { value: "id", label: "Indonesia" },
        { value: "jp", label: "Japan" },
      ];
    </script>
    
    <Combobox
      bind:value={country}
      name="country"
      label="Country"
      placeholder="Search countries"
      options={countries}
    />
    ---
    import Combobox from "@/components/markas/Combobox.astro";
    
    const countries = [
      { value: "au", label: "Australia" },
      { value: "id", label: "Indonesia" },
      { value: "jp", label: "Japan" },
    ];
    ---
    
    <Combobox
      name="country"
      label="Country"
      placeholder="Search countries"
      value="id"
      options={countries}
    />

    Options render on the server. A small bundled script (one custom element per combobox) filters, highlights, and positions the list. Changing the selection dispatches a bubbling markas-change event with the value in event.detail.

    import { Component, signal } from "@angular/core";
    import { Combobox } from "./markas/combobox.component";
    
    @Component({
      selector: "app-address",
      imports: [Combobox],
      template: `
        <markas-combobox
          [(value)]="country"
          name="country"
          label="Country"
          placeholder="Search countries"
          [options]="countries"
        />
      `,
    })
    export class Address {
      readonly country = signal("id");
      readonly countries = [
        { value: "au", label: "Australia" },
        { value: "id", label: "Indonesia" },
        { value: "jp", label: "Japan" },
      ];
    }
    • Extra attributes (placeholder, required, disabled, class) go to the visible text input. name goes to a hidden input that holds the selected value, so the form sends country=id, not the label.
    • Typing filters options by label and clears the selected value until an option is picked again.
    • The list renders in the top layer through the Popover API, so a parent with overflow: hidden never clips it.
    • Translate the empty state with emptyLabel (default “No results”).

    Props

    NameTypeDefaultDescription
    options{ value: string, label: string }[][]Suggestions. Typing filters them by label, case insensitive.
    labelstring-Label text, linked to the input and used to name the listbox.
    hintstring-Hint text below the input. Hidden while an error is shown.
    errorstring-Error message. Turns on aria-invalid and the danger border.
    namestring-Name of the hidden input that holds the selected value for form submit.
    value / defaultValue / v-model / bind:valuestring""Selected option value. React accepts value with onValueChange or defaultValue; Vue uses v-model; Svelte bind:value; Angular value or [(value)]; Blade and Astro use value.
    onValueChange / onvaluechange / markas-change(value: string) => void-Called when the selected value changes, with an empty string when cleared (React onValueChange, Svelte onvaluechange). Blade and Astro dispatch a bubbling markas-change event; Angular emits valueChange.
    emptyLabelstringNo resultsText shown when no option matches.
    idstringautoInput id. The listbox and options use it as a prefix.

    Accessibility

    • The input has role=combobox, aria-autocomplete=list, aria-expanded, and aria-controls pointing to the role=listbox.
    • Arrow Down and Arrow Up open the list and move through matching options (wrapping at the ends); aria-activedescendant follows the highlighted option so focus stays in the input.
    • Enter selects the highlighted option and closes the list. Escape closes the list; a second Escape clears the input.
    • Clicking an option selects it. Leaving the input closes the list.

    Related components

    More form components with the same classes in every framework.