Source

Knop groep

Groepearje in searje knoppen tegearre op ien rigel mei de knopgroep, en superpower se mei JavaScript.

Basis foarbyld

Wrap in rige fan knoppen mei .btnyn .btn-group. Foegje opsjoneel JavaScript-radio- en karfakjestylgedrach ta mei ús knopplugin .

<div class="btn-group" role="group" aria-label="Basic example">
  <button type="button" class="btn btn-secondary">Left</button>
  <button type="button" class="btn btn-secondary">Middle</button>
  <button type="button" class="btn btn-secondary">Right</button>
</div>
Fersekerje korrekt roleen jouwe in label

Om helptechnologyen (lykas skermlêzers) oer te bringen dat in searje knoppen groepearre is, rolemoat in passend attribút oanbean wurde. Foar knopgroepen soe dit wêze role="group", wylst arkbalken in role="toolbar".

Dêrneist moatte groepen en arkbalken in eksplisyt label krije, om't de measte assistive technologyen se oars net oankundigje, nettsjinsteande de oanwêzigens fan it juste rolkenmerk. Yn 'e hjirre levere foarbylden brûke wy aria-label, mar alternativen lykas aria-labelledbykinne ek brûkt wurde.

Knop arkbalke

Kombinearje sets fan knop groepen yn knop arkbalken foar mear komplekse komponinten. Brûk nutklassen as nedich om groepen, knoppen en mear romte te jaan.

<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
  <div class="btn-group mr-2" role="group" aria-label="First group">
    <button type="button" class="btn btn-secondary">1</button>
    <button type="button" class="btn btn-secondary">2</button>
    <button type="button" class="btn btn-secondary">3</button>
    <button type="button" class="btn btn-secondary">4</button>
  </div>
  <div class="btn-group mr-2" role="group" aria-label="Second group">
    <button type="button" class="btn btn-secondary">5</button>
    <button type="button" class="btn btn-secondary">6</button>
    <button type="button" class="btn btn-secondary">7</button>
  </div>
  <div class="btn-group" role="group" aria-label="Third group">
    <button type="button" class="btn btn-secondary">8</button>
  </div>
</div>

Fiel jo frij om ynfiergroepen te mingjen mei knopgroepen yn jo arkbalken. Fergelykber mei it foarbyld hjirboppe, sille jo wierskynlik wat nutsbedriuwen nedich hawwe om dingen goed te romte.

<div class="btn-toolbar mb-3" role="toolbar" aria-label="Toolbar with button groups">
  <div class="btn-group mr-2" role="group" aria-label="First group">
    <button type="button" class="btn btn-secondary">1</button>
    <button type="button" class="btn btn-secondary">2</button>
    <button type="button" class="btn btn-secondary">3</button>
    <button type="button" class="btn btn-secondary">4</button>
  </div>
  <div class="input-group">
    <div class="input-group-prepend">
      <div class="input-group-text" id="btnGroupAddon">@</div>
    </div>
    <input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon">
  </div>
</div>

<div class="btn-toolbar justify-content-between" role="toolbar" aria-label="Toolbar with button groups">
  <div class="btn-group" role="group" aria-label="First group">
    <button type="button" class="btn btn-secondary">1</button>
    <button type="button" class="btn btn-secondary">2</button>
    <button type="button" class="btn btn-secondary">3</button>
    <button type="button" class="btn btn-secondary">4</button>
  </div>
  <div class="input-group">
    <div class="input-group-prepend">
      <div class="input-group-text" id="btnGroupAddon2">@</div>
    </div>
    <input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon2">
  </div>
</div>

Sizing

Yn stee fan it tapassen fan klassen foar knopgrutte op elke knop yn in groep, foegje jo gewoan ta .btn-group-*oan elk .btn-group, ynklusyf elk by it nesteljen fan meardere groepen.



<div class="btn-group btn-group-lg" role="group" aria-label="...">...</div>
<div class="btn-group" role="group" aria-label="...">...</div>
<div class="btn-group btn-group-sm" role="group" aria-label="...">...</div>

Nesting

Pleats in .btn-groupyn in oar .btn-groupas jo útklapmenu's wolle mingd mei in searje knoppen.

<div class="btn-group" role="group" aria-label="Button group with nested dropdown">
  <button type="button" class="btn btn-secondary">1</button>
  <button type="button" class="btn btn-secondary">2</button>

  <div class="btn-group" role="group">
    <button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Dropdown
    </button>
    <div class="dropdown-menu" aria-labelledby="btnGroupDrop1">
      <a class="dropdown-item" href="#">Dropdown link</a>
      <a class="dropdown-item" href="#">Dropdown link</a>
    </div>
  </div>
</div>

Fertikale fariaasje

Meitsje in set fan knoppen ferskine fertikaal steapele ynstee horizontaal. Dropdowns foar splitknop wurde hjir net stipe.

<div class="btn-group-vertical">
  ...
</div>