Gå til indhold

Komponenter

Kombinationsboks

Et tekstfelt, der filtrerer en liste over valgmuligheder, mens du skriver.

Brug

Grundlæggende

HTML
<bs:bsui-combobox placeholder="Pick a framework">
  <bs:bsui-combobox-input />
  <bs:bsui-combobox-popup>
    <bs:bsui-combobox-option value="wordpress" label="WordPress" />
    <bs:bsui-combobox-option value="astro" label="Astro" />
    <bs:bsui-combobox-option value="laravel" label="Laravel" />
  </bs:bsui-combobox-popup>
</bs:bsui-combobox>

Lang liste

Indtastning filtrerer valgmulighederne, hvilket er fordelen ved en kombinationsboks sammenlignet med en rullemenu.

HTML
<bs:bsui-combobox name="timezone" placeholder="Search time zones">
  <bs:bsui-combobox-input />
  <bs:bsui-combobox-popup>
    <bs:bsui-combobox-option value="lisbon" label="Lisbon" />
    <bs:bsui-combobox-option value="london" label="London" />
    <bs:bsui-combobox-option value="berlin" label="Berlin" />
    <bs:bsui-combobox-option value="helsinki" label="Helsinki" />
    <bs:bsui-combobox-option value="istanbul" label="Istanbul" />
    <bs:bsui-combobox-option value="dubai" label="Dubai" />
    <bs:bsui-combobox-option value="singapore" label="Singapore" />
    <bs:bsui-combobox-option value="tokyo" label="Tokyo" />
    <bs:bsui-combobox-option value="sydney" label="Sydney" />
  </bs:bsui-combobox-popup>
</bs:bsui-combobox>

I et felt

Et name indsender den valgte værdi, mens den synlige tekst forbliver etiketten.

Only people with access to this project are listed.
HTML
<bs:bsui-field>
  <bs:bsui-field-label text="Assignee" />
  <bs:bsui-combobox name="assignee" placeholder="Search teammates">
    <bs:bsui-combobox-input />
    <bs:bsui-combobox-popup>
      <bs:bsui-combobox-option value="ada" label="Ada Lovelace" />
      <bs:bsui-combobox-option value="grace" label="Grace Hopper" />
      <bs:bsui-combobox-option value="alan" label="Alan Turing" />
    </bs:bsui-combobox-popup>
  </bs:bsui-combobox>
  <bs:bsui-field-description text="Only people with access to this project are listed." />
</bs:bsui-field>

Opbygning

Kombinationsboks består af blokkene nedenfor. Hver enkelt er en separat blok, der kun gengives inde i sin overordnede blok.

  • bsui/combobox
  • bsui/combobox-input
  • bsui/combobox-popup
  • bsui/combobox-option

Attributter

AttributTypeStandard
placeholder text Search...
name text —

bsui/combobox-input

Denne blok har ingen attributter.

bsui/combobox-popup

Denne blok har ingen attributter.

bsui/combobox-option

AttributTypeStandard
value text —
label text —