Tɛmɛn ka taa kunnafoni kunbabaw la Tɛmɛn ka taa docs navigation kan
in English

Dropdowns (Donkiliw).

Toggle contextual overlays walasa ka jɛgɛnsira lisi jira ani fɛn wɛrɛw ni Bootstrap dropdown plugin ye.

Kuma bɛɛ lajɛlen

Dropdowns bɛ se ka wuli ka bɔ ɲɔgɔn na, contextual overlays walasa ka jɛgɛnsira lisi jira ani fɛn wɛrɛw. U bɛ Kɛ ɲɔgɔndan ye ni Bootstrap 'kɔnɔ JavaScript 'kɔnɔ. U bɛ toggle ni klikɛli ye, a tɛ kɛ ni hovering ye; nin ye dilancogo latigɛlen ye ni laɲini ye .

Dropdowns bɛ jɔ mɔgɔ sabanan ka gafemarayɔrɔ dɔ kan, Popper , min bɛ jɔyɔrɔko ni filɛlikɛyɔrɔw dɔnni fangama di. Aw ye aw jija ka popper.min.js don a kɔnɔ ka kɔn Bootstrap ka JavaScript ɲɛ walima ka baara kɛ ni bootstrap.bundle.min.js/ bootstrap.bundle.jsye min kɔnɔ Popper bɛ yen. Popper tɛ baara kɛ ka dropdowns jɔyɔrɔ sɔrɔ navbars kɔnɔ hali ni dynamic positioning tɛ wajibiya.

Seko ni dɔnko

WAI ARIA sariya bɛ role="menu"wideyo lakika dɔ ɲɛfɔ , nka o ye kɛrɛnkɛrɛnnenya la baarakɛminɛnw ye minnu bɛ kɛwalew walima baarakɛcogo dɔw daminɛ. ARIA menu kɔnɔ, menu kɔnɔfɛnw dɔrɔn de bɛ sɔrɔ, menu kɔnɔfɛnw, arajo butɔni menu kɔnɔfɛnw, arajo butɔni kuluw, ani menu fitininw.

Bootstrap ka dropdowns kɔni, u dabɔra ka kɛ fɛn bɛɛ ye ani ka baara kɛ ni ko suguya caman ye ani markup structures. Misali la, a bɛ se ka kɛ ka fɛnw dilan minnu kɔnɔ, donnakow ni sɛbɛnw maracogo wɛrɛw bɛ sɔrɔ, i n’a fɔ ɲininikɛyɔrɔw walima donsɛbɛnw. O de kama, Bootstrap tɛ makɔnɔni kɛ (wa a tɛ a yɛrɛma fara a kan) roleani fɛn dɔw la aria-minnu wajibiyalen don ARIA menu lakikaw la. Sɛbɛnnikɛlaw yɛrɛ bɛna o jogo kɛrɛnkɛrɛnnenw don a kɔnɔ.

Nka, Bootstrap bɛ dɛmɛ Dòn a kɔnɔ ka Fàra klaviyeti menu (klaviyeti) menu (klaviyeti) 'kɔnɔ-ɲɔgɔnna fanba kan, i n'a fɔ se min bɛ Se ka Taa .dropdown-itemfɛn kelen-kelen bɛɛ fɛ ni cursor (kɛrɛnkɛrɛnnenya) klaviyetiw ye ani ka menu (dakun) Dabɔ ni ESCkey (klaviyeti) ye.

Misaliw

Aw bɛ jiginɛ in ka toggle (i ka butɔni walima i ka jɛgɛn) ani jiginɛ menu siri .dropdown, walima fɛn wɛrɛ min bɛ declare position: relative;. Dropdowns bɛ se ka daminɛ ka bɔ <a>walima <button>elements walasa ka bɛn i magow ma minnu bɛ se ka kɛ. Misali minnu jiralen bɛ yan, olu bɛ baara Kɛ ni kɔrɔko- <ul>yɔrɔw ye yɔrɔ minnu na a bɛnnen dòn, nka ladamu-taamaʃyɛn bɛ Dɛmɛ.

Butɔn kelen

Single o kelen .btnbɛ Se ka Yɛlɛma ka Kɛ 'yɔrɔ ye min bɛ 'yɔrɔ la ni 'yɔrɔ dɔw ye minnu bɛ 'yɔrɔ caman 'kɔnɔ. Aw bɛ se k’u bila baara la ni <button>fɛn fila la kelen ye cogo min na, o filɛ nin ye:

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown button
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
    <li><a class="dropdown-item" href="#">Action</a></li>
    <li><a class="dropdown-item" href="#">Another action</a></li>
    <li><a class="dropdown-item" href="#">Something else here</a></li>
  </ul>
</div>

Ani ni <a>fɛnw ye:

<div class="dropdown">
  <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown link
  </a>

  <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
    <li><a class="dropdown-item" href="#">Action</a></li>
    <li><a class="dropdown-item" href="#">Another action</a></li>
    <li><a class="dropdown-item" href="#">Something else here</a></li>
  </ul>
</div>

A ka fisa ni bɛɛ ye aw bɛ se ka nin kɛ ni butɔni suguya o suguya ye, aw fana:

<!-- Example single danger button -->
<div class="btn-group">
  <button type="button" class="btn btn-danger dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Action
  </button>
  <ul class="dropdown-menu">
    <li><a class="dropdown-item" href="#">Action</a></li>
    <li><a class="dropdown-item" href="#">Another action</a></li>
    <li><a class="dropdown-item" href="#">Something else here</a></li>
    <li><hr class="dropdown-divider"></li>
    <li><a class="dropdown-item" href="#">Separated link</a></li>
  </ul>
</div>

Butɔn tila-tila

O cogo kelen na, aw bɛ butɔni tila-tilalenw dabɔ ni taamasiyɛn kelen ye ni butɔni kelen-kelenw ye, nka ni farali ye .dropdown-toggle-splitwalasa ka yɔrɔjan sɔrɔ ka ɲɛ karɛti lamini na.

An bɛ baara Kɛ ni nin kalasi wɛrɛ ye walasa ka kari paddingfàn fla bɛɛ ka horizontal (yɔrɔjan) Dɔgɔya ni 25% ye ani ka margin-leftthat's added for regular button dropdowns (butɔni bɔgɔlanw) Bɔ. O fɛn wɛrɛw bɛ kɛ ka karɛti bila cɛmancɛ la butɔni tilalen na ani ka butɔni belebele kɛrɛ fɛ min bonya bɛ bɛn a ma.

<!-- Example split danger button -->
<div class="btn-group">
  <button type="button" class="btn btn-danger">Action</button>
  <button type="button" class="btn btn-danger dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
    <span class="visually-hidden">Toggle Dropdown</span>
  </button>
  <ul class="dropdown-menu">
    <li><a class="dropdown-item" href="#">Action</a></li>
    <li><a class="dropdown-item" href="#">Another action</a></li>
    <li><a class="dropdown-item" href="#">Something else here</a></li>
    <li><hr class="dropdown-divider"></li>
    <li><a class="dropdown-item" href="#">Separated link</a></li>
  </ul>
</div>

Sizing (Sizing) kɛ

Butɔnw bɛ baara kɛ ni butɔni hakɛ bɛɛ ye, hali butɔni minnu bɛ bɔ duguma ani minnu tilalen don.

<!-- Large button groups (default and split) -->
<div class="btn-group">
  <button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
    Large button
  </button>
  <ul class="dropdown-menu">
    ...
  </ul>
</div>
<div class="btn-group">
  <button class="btn btn-secondary btn-lg" type="button">
    Large split button
  </button>
  <button type="button" class="btn btn-lg btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
    <span class="visually-hidden">Toggle Dropdown</span>
  </button>
  <ul class="dropdown-menu">
    ...
  </ul>
</div>
<div class="btn-group">
  <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
    Small button
  </button>
  <ul class="dropdown-menu">
    ...
  </ul>
</div>
<div class="btn-group">
  <button class="btn btn-secondary btn-sm" type="button">
    Small split button
  </button>
  <button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
    <span class="visually-hidden">Toggle Dropdown</span>
  </button>
  <ul class="dropdown-menu">
    ...
  </ul>
</div>

Dibi la, fɛn minnu bɛ jigin

aw bɛ sugandi ka don dibi la , walasa ka bɛn dibi navbar walima ladamu cogoya ma ni aw ye dɔ fara a .dropdown-menu-darkkan min bɛ yen .dropdown-menu. Yɛlɛma si man kan ka kɛ fɛnw na minnu bɛ bɔ yɔrɔ la.

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown button
  </button>
  <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="dropdownMenuButton2">
    <li><a class="dropdown-item active" href="#">Action</a></li>
    <li><a class="dropdown-item" href="#">Another action</a></li>
    <li><a class="dropdown-item" href="#">Something else here</a></li>
    <li><hr class="dropdown-divider"></li>
    <li><a class="dropdown-item" href="#">Separated link</a></li>
  </ul>
</div>

Ani k’a bila baara la navbar kɔnɔ:

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDarkDropdown" aria-controls="navbarNavDarkDropdown" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNavDarkDropdown">
      <ul class="navbar-nav">
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDarkDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Dropdown
          </a>
          <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="navbarDarkDropdownMenuLink">
            <li><a class="dropdown-item" href="#">Action</a></li>
            <li><a class="dropdown-item" href="#">Another action</a></li>
            <li><a class="dropdown-item" href="#">Something else here</a></li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</nav>

Yɔrɔ jiracogo

RTL ye

Siraw bɛ miiri ni Bootstrap ye RTL kɔnɔ, kɔrɔ .dropstartbɛna jira kinin fɛ.

Dropup (Donkilidala).

A’ ye fɛnw daminɛ minnu bɛ fɛnw sanfɛ ni fɛn dɔw farali .dropupye bangebaga fɛn kan.

<!-- Default dropup button -->
<div class="btn-group dropup">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Dropup
  </button>
  <ul class="dropdown-menu">
    <!-- Dropdown menu links -->
  </ul>
</div>

<!-- Split dropup button -->
<div class="btn-group dropup">
  <button type="button" class="btn btn-secondary">
    Split dropup
  </button>
  <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
    <span class="visually-hidden">Toggle Dropdown</span>
  </button>
  <ul class="dropdown-menu">
    <!-- Dropdown menu links -->
  </ul>
</div>

Dropright (Dropright) ye

A’ ye fɛnw daminɛ minnu bɛ fɛnw kinin fɛ ni fɛn dɔw farali .dropendye bangebaga fɛn kan.

<!-- Default dropend button -->
<div class="btn-group dropend">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Dropright
  </button>
  <ul class="dropdown-menu">
    <!-- Dropdown menu links -->
  </ul>
</div>

<!-- Split dropend button -->
<div class="btn-group dropend">
  <button type="button" class="btn btn-secondary">
    Split dropend
  </button>
  <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
    <span class="visually-hidden">Toggle Dropright</span>
  </button>
  <ul class="dropdown-menu">
    <!-- Dropdown menu links -->
  </ul>
</div>

Dropleft (Dropleft) ye

Meniw minnu bɛ fɛnw jiginni na, olu daminɛ fɛnw kinin fɛ ni farali .dropstartye fɛn bangebaga kan.

<!-- Default dropstart button -->
<div class="btn-group dropstart">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Dropstart
  </button>
  <ul class="dropdown-menu">
    <!-- Dropdown menu links -->
  </ul>
</div>

<!-- Split dropstart button -->
<div class="btn-group">
  <div class="btn-group dropstart" role="group">
    <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
      <span class="visually-hidden">Toggle Dropstart</span>
    </button>
    <ul class="dropdown-menu">
      <!-- Dropdown menu links -->
    </ul>
  </div>
  <button type="button" class="btn btn-secondary">
    Split dropstart
  </button>
</div>

Aw bɛ se ka baara kɛ ni <a>walima <button>fɛnw ye i n’a fɔ fɛnw minnu bɛ jigin.

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
    <li><button class="dropdown-item" type="button">Action</button></li>
    <li><button class="dropdown-item" type="button">Another action</button></li>
    <li><button class="dropdown-item" type="button">Something else here</button></li>
  </ul>
</div>

Aw bɛ se fana ka fɛnw dilan minnu tɛ ɲɔgɔn sɔrɔ ni .dropdown-item-text. Aw kana siga ka style kɛ ka taa a fɛ ni CSS walima sɛbɛnni nafamafɛnw ye minnu bɛ kɛ ka kɛɲɛ ni aw sago ye.

<ul class="dropdown-menu">
  <li><span class="dropdown-item-text">Dropdown item text</span></li>
  <li><a class="dropdown-item" href="#">Action</a></li>
  <li><a class="dropdown-item" href="#">Another action</a></li>
  <li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>

Walawalalen

fara .activefɛnw kan minnu bɛ jiralan kɔnɔ walasa k ' u cogoya kɛ i n' a fɔ baarakɛtaw . Walasa ka cogoya waleyali lase dɛmɛni fɛɛrɛw ma, baara kɛ ni fɛn aria-currentye — ka baara kɛ ni pagenafa ye ɲɛ min bɛ yen sisan, walima truefɛn min bɛ sen na sisan kulu dɔ kɔnɔ.

<ul class="dropdown-menu">
  <li><a class="dropdown-item" href="#">Regular link</a></li>
  <li><a class="dropdown-item active" href="#" aria-current="true">Active link</a></li>
  <li><a class="dropdown-item" href="#">Another link</a></li>
</ul>

A jɔ la

aw bɛ fɛn dɔw fara .disabledɲɔgɔn kan , minnu bɛ sɔrɔ yɔrɔ la , walasa k ' u cogoya kɛ i n' a fɔ fɛn minnu tɛ se ka baara kɛ .

<ul class="dropdown-menu">
  <li><a class="dropdown-item" href="#">Regular link</a></li>
  <li><a class="dropdown-item disabled" href="#" tabindex="-1" aria-disabled="true">Disabled link</a></li>
  <li><a class="dropdown-item" href="#">Another link</a></li>
</ul>

O cogo la, fɛn dɔ bɛ Dòn a yɛrɛ la 100% ka Bɔ sanfɛ ani a bangebaga kinin fɛ. Aw bɛ se k’o Changé ni direction .drop*classes ye, nka aw bɛ se fana k’u mara ni modifier classes wɛrɛw ye.

A fara a kan .dropdown-menu-endka .dropdown-menutaa kinin fɛ, i ka menu (yɔrɔ) labɛn. Siraw bɛ miiri ni Bootstrap ye RTL kɔnɔ, kɔrɔ .dropdown-menu-endbɛna jira kinin fɛ.

Kungolow bɛ wuli! Dropdowns bɛ jɔyɔrɔ la Popper sababu la fo n'u bɛ navbar dɔ kɔnɔ.
<div class="btn-group">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Right-aligned menu example
  </button>
  <ul class="dropdown-menu dropdown-menu-end">
    <li><button class="dropdown-item" type="button">Action</button></li>
    <li><button class="dropdown-item" type="button">Another action</button></li>
    <li><button class="dropdown-item" type="button">Something else here</button></li>
  </ul>
</div>

Alignment min bɛ jaabi di

N’i ​​b’a fɛ ka baara kɛ ni jaabi-labɛnni ye, i ka dynamique positionnement bali ni data-bs-display="static"attribut farali ye ani ka baara kɛ ni responsive variation classes ye.

Walasa ka menu (yɔrɔ) min bɛ jira, o bɛ bɛn kinin fɛ ni breakpoint dilen ye walima min ka bon, i ka fara .dropdown-menu{-sm|-md|-lg|-xl|-xxl}-end.

<div class="btn-group">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
    Left-aligned but right aligned when large screen
  </button>
  <ul class="dropdown-menu dropdown-menu-lg-end">
    <li><button class="dropdown-item" type="button">Action</button></li>
    <li><button class="dropdown-item" type="button">Another action</button></li>
    <li><button class="dropdown-item" type="button">Something else here</button></li>
  </ul>
</div>

Walasa ka menu (yɔrɔ) min bɛ bɔ kinin fɛ , o ni breakpoint dilen walima min ka bon ni o ye, i ka fara a kan .dropdown-menu-endani .dropdown-menu{-sm|-md|-lg|-xl|-xxl}-start.

<div class="btn-group">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
    Right-aligned but left aligned when large screen
  </button>
  <ul class="dropdown-menu dropdown-menu-end dropdown-menu-lg-start">
    <li><button class="dropdown-item" type="button">Action</button></li>
    <li><button class="dropdown-item" type="button">Another action</button></li>
    <li><button class="dropdown-item" type="button">Something else here</button></li>
  </ul>
</div>

A kɔlɔsi ko i mago t’a la ka fɛn dɔ Fàra data-bs-display="static"butɔni dɔw kan navbarw kɔnɔ, bawo Popper tɛ baara Kɛ navbarw kɔnɔ.

Alignment sugandiliw

Ni an ye sugandiliw fanba ta minnu jiralen bɛ sanfɛ, nin ye cuisini jisigiyɔrɔ demo fitinin ye min bɛ sugandili suguya caman jira minnu bɛ fɛnw bila ɲɔgɔn na yɔrɔ kelen na.

<div class="btn-group">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

<div class="btn-group">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Right-aligned menu
  </button>
  <ul class="dropdown-menu dropdown-menu-end">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

<div class="btn-group">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
    Left-aligned, right-aligned lg
  </button>
  <ul class="dropdown-menu dropdown-menu-lg-end">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

<div class="btn-group">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
    Right-aligned, left-aligned lg
  </button>
  <ul class="dropdown-menu dropdown-menu-end dropdown-menu-lg-start">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

<div class="btn-group dropstart">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Dropstart
  </button>
  <ul class="dropdown-menu">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

<div class="btn-group dropend">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Dropend
  </button>
  <ul class="dropdown-menu">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

<div class="btn-group dropup">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Dropup
  </button>
  <ul class="dropdown-menu">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

Kungolodilanw

Aw bɛ kuncɛ dɔ fara a kan walasa ka walew yɔrɔw tɔgɔ sɛbɛn minnu bɛ sɔrɔ yɔrɔ o yɔrɔ la.

<ul class="dropdown-menu">
  <li><h6 class="dropdown-header">Dropdown header</h6></li>
  <li><a class="dropdown-item" href="#">Action</a></li>
  <li><a class="dropdown-item" href="#">Another action</a></li>
</ul>

Tila-tilabagaw

Meniw kɔnɔfɛnw minnu bɛ tali kɛ ɲɔgɔn na, olu kuluw faranfasi ni tilayɔrɔba ye.

<ul class="dropdown-menu">
  <li><a class="dropdown-item" href="#">Action</a></li>
  <li><a class="dropdown-item" href="#">Another action</a></li>
  <li><a class="dropdown-item" href="#">Something else here</a></li>
  <li><hr class="dropdown-divider"></li>
  <li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>

Masalabolo

sɛbɛn hɔrɔnyalen o sɛbɛn hɔrɔnyalen bila menu kɔnɔ ni sɛbɛnni ye ani ka baara kɛ ni yɔrɔjan nafamafɛnw ye . A kɔlɔsi ko a ka c’a la, i mago bɛna kɛ bonyacogo wɛrɛw la walasa ka menu bonya bali.

<div class="dropdown-menu p-4 text-muted" style="max-width: 200px;">
  <p>
    Some example text that's free-flowing within the dropdown menu.
  </p>
  <p class="mb-0">
    And this is more example text.
  </p>
</div>

Sɛbɛnw

I ka sɛbɛn dɔ bila fɛn dɔ kɔnɔ min bɛ jira, walima k’a kɛ fɛn dɔ ye min bɛ fɛnw jira, ani ka baara kɛ ni margin walima padding utilities ye walasa ka yɔrɔ jugu di a ma i mago bɛ min na.

<div class="dropdown-menu">
  <form class="px-4 py-3">
    <div class="mb-3">
      <label for="exampleDropdownFormEmail1" class="form-label">Email address</label>
      <input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="[email protected]">
    </div>
    <div class="mb-3">
      <label for="exampleDropdownFormPassword1" class="form-label">Password</label>
      <input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
    </div>
    <div class="mb-3">
      <div class="form-check">
        <input type="checkbox" class="form-check-input" id="dropdownCheck">
        <label class="form-check-label" for="dropdownCheck">
          Remember me
        </label>
      </div>
    </div>
    <button type="submit" class="btn btn-primary">Sign in</button>
  </form>
  <div class="dropdown-divider"></div>
  <a class="dropdown-item" href="#">New around here? Sign up</a>
  <a class="dropdown-item" href="#">Forgot password?</a>
</div>
<form class="dropdown-menu p-4">
  <div class="mb-3">
    <label for="exampleDropdownFormEmail2" class="form-label">Email address</label>
    <input type="email" class="form-control" id="exampleDropdownFormEmail2" placeholder="[email protected]">
  </div>
  <div class="mb-3">
    <label for="exampleDropdownFormPassword2" class="form-label">Password</label>
    <input type="password" class="form-control" id="exampleDropdownFormPassword2" placeholder="Password">
  </div>
  <div class="mb-3">
    <div class="form-check">
      <input type="checkbox" class="form-check-input" id="dropdownCheck2">
      <label class="form-check-label" for="dropdownCheck2">
        Remember me
      </label>
    </div>
  </div>
  <button type="submit" class="btn btn-primary">Sign in</button>
</form>

Baara kɛ ni data-bs-offsetwala data-bs-referenceye walasa ka yɔrɔ caman Changer.

<div class="d-flex">
  <div class="dropdown me-1">
    <button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuOffset" data-bs-toggle="dropdown" aria-expanded="false" data-bs-offset="10,20">
      Offset
    </button>
    <ul class="dropdown-menu" aria-labelledby="dropdownMenuOffset">
      <li><a class="dropdown-item" href="#">Action</a></li>
      <li><a class="dropdown-item" href="#">Another action</a></li>
      <li><a class="dropdown-item" href="#">Something else here</a></li>
    </ul>
  </div>
  <div class="btn-group">
    <button type="button" class="btn btn-secondary">Reference</button>
    <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" id="dropdownMenuReference" data-bs-toggle="dropdown" aria-expanded="false" data-bs-reference="parent">
      <span class="visually-hidden">Toggle Dropdown</span>
    </button>
    <ul class="dropdown-menu" aria-labelledby="dropdownMenuReference">
      <li><a class="dropdown-item" href="#">Action</a></li>
      <li><a class="dropdown-item" href="#">Another action</a></li>
      <li><a class="dropdown-item" href="#">Something else here</a></li>
      <li><hr class="dropdown-divider"></li>
      <li><a class="dropdown-item" href="#">Separated link</a></li>
    </ul>
  </div>
</div>

Auto close kɛcogo

Ka da a kan, fɛn min bɛ jira, o bɛ da tugu ni i bɛ digi yɔrɔ kɔnɔ walima a kɔkan. Aw bɛ se ka baara kɛ ni autoClosesugandi ye walasa ka nin kɛcogo in Changer de la dropdown.

<div class="btn-group">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="defaultDropdown" data-bs-toggle="dropdown" data-bs-auto-close="true" aria-expanded="false">
    Default dropdown
  </button>
  <ul class="dropdown-menu" aria-labelledby="defaultDropdown">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

<div class="btn-group">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuClickableOutside" data-bs-toggle="dropdown" data-bs-auto-close="inside" aria-expanded="false">
    Clickable outside
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuClickableOutside">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

<div class="btn-group">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuClickableInside" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
    Clickable inside
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuClickableInside">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

<div class="btn-group">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuClickable" data-bs-toggle="dropdown" data-bs-auto-close="false" aria-expanded="false">
    Manual close
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuClickable">
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
    <li><a class="dropdown-item" href="#">Menu item</a></li>
  </ul>
</div>

Sass ye

Yɛlɛma-yɛlɛmaw

Yɛlɛma minnu bɛ sɔrɔ fɛnw bɛɛ lajɛlen na:

$dropdown-min-width:                10rem;
$dropdown-padding-x:                0;
$dropdown-padding-y:                .5rem;
$dropdown-spacer:                   .125rem;
$dropdown-font-size:                $font-size-base;
$dropdown-color:                    $body-color;
$dropdown-bg:                       $white;
$dropdown-border-color:             rgba($black, .15);
$dropdown-border-radius:            $border-radius;
$dropdown-border-width:             $border-width;
$dropdown-inner-border-radius:      subtract($dropdown-border-radius, $dropdown-border-width);
$dropdown-divider-bg:               $dropdown-border-color;
$dropdown-divider-margin-y:         $spacer * .5;
$dropdown-box-shadow:               $box-shadow;

$dropdown-link-color:               $gray-900;
$dropdown-link-hover-color:         shade-color($gray-900, 10%);
$dropdown-link-hover-bg:            $gray-200;

$dropdown-link-active-color:        $component-active-color;
$dropdown-link-active-bg:           $component-active-bg;

$dropdown-link-disabled-color:      $gray-500;

$dropdown-item-padding-y:           $spacer * .25;
$dropdown-item-padding-x:           $spacer;

$dropdown-header-color:             $gray-600;
$dropdown-header-padding:           $dropdown-padding-y $dropdown-item-padding-x;

Yɛlɛma minnu bɛ kɛ dibi la jigincogo la :

$dropdown-dark-color:               $gray-300;
$dropdown-dark-bg:                  $gray-800;
$dropdown-dark-border-color:        $dropdown-border-color;
$dropdown-dark-divider-bg:          $dropdown-divider-bg;
$dropdown-dark-box-shadow:          null;
$dropdown-dark-link-color:          $dropdown-dark-color;
$dropdown-dark-link-hover-color:    $white;
$dropdown-dark-link-hover-bg:       rgba($white, .15);
$dropdown-dark-link-active-color:   $dropdown-link-active-color;
$dropdown-dark-link-active-bg:      $dropdown-link-active-bg;
$dropdown-dark-link-disabled-color: $gray-500;
$dropdown-dark-header-color:        $gray-500;

Yɛlɛma minnu bɛ CSS-based carets (karɛtiw) la minnu bɛ dropdown (dakun) dɔ ka jɛɲɔgɔnya jira:

$caret-width:                 .3em;
$caret-vertical-align:        $caret-width * .85;
$caret-spacing:               $caret-width * .85;

Mixinw (Mixins).

Mixinw bɛ kɛ ka CSS-based carets (karɛtiw) dilan ani u bɛ se ka sɔrɔ scss/mixins/_caret.scss.

@mixin caret-down {
  border-top: $caret-width solid;
  border-right: $caret-width solid transparent;
  border-bottom: 0;
  border-left: $caret-width solid transparent;
}

@mixin caret-up {
  border-top: 0;
  border-right: $caret-width solid transparent;
  border-bottom: $caret-width solid;
  border-left: $caret-width solid transparent;
}

@mixin caret-end {
  border-top: $caret-width solid transparent;
  border-right: 0;
  border-bottom: $caret-width solid transparent;
  border-left: $caret-width solid;
}

@mixin caret-start {
  border-top: $caret-width solid transparent;
  border-right: $caret-width solid;
  border-bottom: $caret-width solid transparent;
}

@mixin caret($direction: down) {
  @if $enable-caret {
    &::after {
      display: inline-block;
      margin-left: $caret-spacing;
      vertical-align: $caret-vertical-align;
      content: "";
      @if $direction == down {
        @include caret-down();
      } @else if $direction == up {
        @include caret-up();
      } @else if $direction == end {
        @include caret-end();
      }
    }

    @if $direction == start {
      &::after {
        display: none;
      }

      &::before {
        display: inline-block;
        margin-right: $caret-spacing;
        vertical-align: $caret-vertical-align;
        content: "";
        @include caret-start();
      }
    }

    &:empty::after {
      margin-left: 0;
    }
  }
}

Baarakɛcogo

Donanw ka fɛnw walima JavaScript fɛ, o fɛn dogolenw bɛ fɛn dogolenw wuli (menuw) ni .showkalan sɛgɛsɛgɛli ye bangebaga .dropdown-menukan . O data-bs-toggle="dropdown"fɛnɲɛnɛma in bɛ Da a kan walasa ka 'sènfɛjuru-minɛnw Dabɔ application (application) hakɛ dɔ la, o la a ka ɲi ka baara Kɛ n'a ye tuma bɛɛ.

Minɛn minnu bɛ se ka maga u la, ni i ye fɛn dɔ da wuli, o bɛ fɛn lankolonw fara fɛn mouseoverin denw kan teliya la <body>. O admittedly ugly hack is necessary to work around a quirk in iOS’ event delegation , min n’o tɛ, o bɛna a bali ka tap dɔ kɛ yɔrɔ o yɔrɔ la ka bɔ dropdown kɔfɛ ka kode daminɛ min bɛ dropdown datugu. Ni jiginɛ datugulen don, o minɛn lankolon wɛrɛw mouseoverbɛ bɔ.

Donanw ka fɛnɲɛnɛmaw fɛ

A fara a kan data-bs-toggle="dropdown"ka kɛ yɔrɔ dɔ ye walima ka butɔni dɔ fara a kan walasa ka fɛn dɔ wuli ka bɔ a nɔ na.

<div class="dropdown">
  <button id="dLabel" type="button" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown trigger
  </button>
  <ul class="dropdown-menu" aria-labelledby="dLabel">
    ...
  </ul>
</div>

JavaScript fɛ

Aw bɛ fɛnw wele JavaScript fɛ:

var dropdownElementList = [].slice.call(document.querySelectorAll('.dropdown-toggle'))
var dropdownList = dropdownElementList.map(function (dropdownToggleEl) {
  return new bootstrap.Dropdown(dropdownToggleEl)
})
data-bs-toggle="dropdown"hali bi a wajibiyalen don

A mana Kɛ cogo o cogo n'i y'i ka 'dakun Weele JavaScript fɛ walima o nɔ na i bɛ baara Kɛ ni data-api ye, data-bs-toggle="dropdown"a wajibiyalen don tuma bɛɛ ka Kɛ 'sènfɛ-sɛbɛnni-minɛn in 'kɔnɔ.

Sugandili minnu bɛ kɛ

Sugandili bɛ se ka tɛmɛ data attributes walima JavaScript fɛ. Donanw cogoyaw kama, aw bɛ sugandi tɔgɔ fara data-bs-, i n’a fɔ a bɛ cogo min na data-bs-offset="". Aw ye aw jija ka sugandili tɔgɔ ka case suguya Changer ka bɔ camelCase la ka kɛ kebab-case ye ni aw bɛ sugandiliw tɛmɛ data attributes fɛ. Misali la, sanni i ka baara kɛ ni data-bs-autoClose="false", baara kɛ ni data-bs-auto-close="false".

Tɔ̀gɔ Ka sɛbɛen masin na Fɔlɔ Cogojirali
boundary juru | fɛn 'clippingParents' Overflow constraint boundary of the dropdown menu (a bɛ tali kɛ Popper ka preventOverflow modifier dɔrɔn de la). Ka da a kan a bɛ 'clippingParents'ani a bɛ Se ka Sɔn HTMLElement 'kɔnɔ (JavaScript dɔrɔn fɛ). Walasa ka kunnafoni wɛrɛw sɔrɔ, aw ye Popper ka detectOverflow docs lajɛ .
reference juru | element | minɛn 'toggle' Reference element min bɛ sɔrɔ menu kɔnɔ. a bɛ sɔn 'toggle', 'parent', HTMLElement ɲɛfɔli walima fɛn dɔ nafaw ma getBoundingClientRect. Walasa ka kunnafoni wɛrɛw sɔrɔ, aw ye Popper ka constructor docs ani virtual element docs lajɛ .
display gaari 'dynamic' Ka da a kan, an bɛ baara Kɛ ni Popper ye walasa ka jɔyɔrɔfalen-falen Kɛ. Nin baara in bali ni static.
offset array | juru | baarakunda [0, 2]

Offset ka dropdown ka kɛɲɛ n’a laɲini ye. Aw bɛ se ka sɛrɛ dɔ tɛmɛn data attributes kɔnɔ ni nafaw ye minnu faralen don ɲɔgɔn kan ni koma ye i n’a fɔ:data-bs-offset="10,20"

Ni baarakɛcogo dɔ bɛ Kɛ ka offset (fɔcogo) dɔn, a bɛ Weele ni fɛn dɔ ye min kɔnɔ popper (poper) bilali, a ka 'reference (fɔlikan) ani popper rects (popper rects) bɛ min na i n'a fɔ a ka argument (fɔlikan) fɔlɔ. Triggering element DOM node bɛ tɛmɛ i n’a fɔ argument filanan. Baarakɛcogo ka kan ka segin sɛrɛkili dɔ kan ni jateden fila ye: .[skidding, distance]

Walasa ka kunnafoni wɛrɛw sɔrɔ, aw ye Popper ka offset docs lajɛ .

autoClose boolean ka | gaari true

A’ ye auto close kɛcogo labɛn ka ɲɛsin dropdown ma:

  • true- bεnkansεbεn in bεna da ni bεnkansεbεn kɛnɛma walima a kɔnɔna digilen ye .
  • false- bεnkansεbεn in bεna Da ni bεnkansεbεn digilen ye ani ka bololabaara hidewalima togglefεεrε wele. (Fanan a tɛna da tugu ni i ye butɔni digi esc)
  • 'inside'- bεnkansεbεn in bεna da (dɔrɔn) ni bεnkansεbεn kɔnɔna digilen ye .
  • 'outside'- bεnkansεbεn in bεna da (dɔrɔn) ni i ye bεnkansεbεn kɔkanna digi.
popperConfig null ka | fɛn min bɛ kɛ | baarakunda null

Walasa ka Bootstrap ka Popper config default Changer, aw ye Popper ka configuration lajɛ .

Ni baarakɛcogo dɔ bɛ Kɛ ka Popper labɛncogo Dabɔ, a bɛ Weele ni fɛn dɔ ye min kɔnɔ Bootstrap ka Popper labɛncogo kɔrɔ bɛ yen. A b’i dɛmɛ ka baara kɛ ni default ye ani k’a fara ɲɔgɔn kan ni i yɛrɛ ka configuration ye. Baarakɛcogo ka kan ka segin Popper ka labɛnni fɛn dɔ kan.

Baara kɛ ni baarakɛcogo ye nipopperConfig

var dropdown = new bootstrap.Dropdown(element, {
  popperConfig: function (defaultBsPopperConfig) {
    // var newPopperConfig = {...}
    // use defaultBsPopperConfig if needed...
    // return newPopperConfig
  }
})

Fɛɛrɛw

Kɛcogo Cogojirali
toggle A bɛ navbar walima navigation tabbed dilen dɔ ka menu dropdown wuli.
show A bɛ navbar walima navigation tabbed dilen dɔ ka menu dropdown jira.
hide A bɛ navbar walima navigation tabbed dilen dɔ ka menu dropdown dogo.
update A bɛ fɛn dɔ ka 'yɔrɔ kura ye.
dispose A bɛ element dɔ ka dropdown tiɲɛ. (A bɛ kunnafoni maralenw bɔ DOM element kan)
getInstance Static method min b’a To i bɛ se ka dropdown instance sɔrɔ min bɛ tali Kɛ DOM element dɔ la, i bɛ Se ka baara Kɛ n’a ye nin cogo in na:bootstrap.Dropdown.getInstance(element)
getOrCreateInstance Fɛɛrɛ jɔlen min bɛ segin 'yɔrɔ la min bɛ tali Kɛ DOM yɔrɔ dɔ la walima ka kura Dabɔ n'a ma Daminɛ. Aw bɛ se ka baara kɛ n’a ye nin cogo la:bootstrap.Dropdown.getOrCreateInstance(element)

Ko minnu kɛra

Dropdown events bɛɛ bɛ fiyɛ toggling element kan ka sɔrɔ ka bubble up. O la aw bɛ se fana ka ko kɛlen lamɛnbagaw fara .dropdown-menu's parent element kan. hide.bs.dropdownani hidden.bs.dropdownko kɛlenw bɛ ni clickEventnafolo ye (dɔrɔn ni Ko suguya fɔlɔ ye click) min kɔnɔ Ko kɛlen Fɛn dɔ bɛ yen min bɛ kɛ ka ɲɛsin klikɛli ko kɛlen ma.

Kɛcogo Cogojirali
show.bs.dropdown A bɛ tasuma don o yɔrɔnin bɛɛ ni show instance fɛɛrɛ welelen don.
shown.bs.dropdown Fired ni dropdown kɛra fɛn ye min bɛ ye baarakɛla fɛ ani CSS transitions dafara.
hide.bs.dropdown A bɛ tasuma don o yɔrɔnin bɛɛ ni hide instance fɛɛrɛ welelen don.
hidden.bs.dropdown Fired ni dropdown (dakun) dogolen banna baarakɛla la ani CSS transitions (CSS transitions) dafara.
var myDropdown = document.getElementById('myDropdown')
myDropdown.addEventListener('show.bs.dropdown', function () {
  // do something...
})