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.js
ye 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) role
ani 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-item
fɛ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 .btn
bɛ 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" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown button
</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>
</ul>
</div>
Ani ni <a>
fɛnw ye:
<div class="dropdown">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown link
</a>
<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>
</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-split
walasa ka yɔrɔjan sɔrɔ ka ɲɛ karɛti lamini na.
An bɛ baara Kɛ ni nin kalasi wɛrɛ ye walasa ka karitɔn padding
fan fla bɛɛ la jɛgɛncogo Dɔgɔya ni 25% ye ani ka o margin-left
min Fàrala butɔni 'kɔnɔ tuma bɛɛ kan, o Bɔ. O fɛn wɛrɛw bɛ kɛ ka karɛti bila cɛmancɛ la butɔni tilalen kɔnɔ ani ka butɔni belebele kɛrɛ fɛ, a bonya bɛnnen don.
<!-- 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-dark
kan 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" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown button
</button>
<ul class="dropdown-menu dropdown-menu-dark">
<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="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu dropdown-menu-dark">
<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
Cɛmancɛ la
Aw bɛ 'menu min bɛ 'yɔrɔ la min bɛ 'yɔrɔ la min bɛ 'yɔrɔ la min bɛ 'yɔrɔ la min bɛ .dropdown-center
'yɔrɔ la min bɛ 'yɔrɔ la.
<div class="dropdown-center">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Centered dropdown
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Action two</a></li>
<li><a class="dropdown-item" href="#">Action three</a></li>
</ul>
</div>
Dropup (Donkilidala).
A’ ye fɛnw daminɛ minnu bɛ fɛnw sanfɛ ni fɛn dɔw farali .dropup
ye 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>
Dropup cɛmancɛ la
Aw bɛ dropup menu kɛ cɛmancɛ la toggle sanfɛ ni .dropup-center
on the parent element.
<div class="dropup-center dropup">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Centered dropup
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Action two</a></li>
<li><a class="dropdown-item" href="#">Action three</a></li>
</ul>
</div>
Dropend (Dropend).
A’ ye fɛnw daminɛ minnu bɛ fɛnw kinin fɛ ni fɛn dɔw farali .dropend
ye 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">
Dropend
</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 Dropend</span>
</button>
<ul class="dropdown-menu">
<!-- Dropdown menu links -->
</ul>
</div>
Dropstart (Dropstart).
Meniw minnu bɛ fɛnw jiginni na, olu daminɛ fɛnw kinin fɛ ni farali .dropstart
ye 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 dropstart">
<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>
<button type="button" class="btn btn-secondary">
Split dropstart
</button>
</div>
Meniw kɔnɔfɛnw
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" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</button>
<ul class="dropdown-menu">
<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 .active
fɛ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-current
ye — ka baara kɛ ni page
nafa ye ɲɛ min bɛ yen sisan, walima true
fɛ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">Disabled link</a></li>
<li><a class="dropdown-item" href="#">Another link</a></li>
</ul>
Meniw labɛncogo
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-end
ka .dropdown-menu
taa kinin fɛ, i ka menu (yɔrɔ) labɛn. Siraw bɛ miiri ni Bootstrap ye RTL kɔnɔ, kɔrɔ .dropdown-menu-end
bɛna jira kinin fɛ.
<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-end
ani .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" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</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">
<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>
Meniw kɔnɔkow
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>
<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-auto-close="outside">
Dropdown form
</button>
<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>
</div>
Sugandili minnu bɛ kɛ ka jigin
Baara kɛ ni data-bs-offset
wala data-bs-reference
ye walasa ka yɔrɔ caman Changer.
<div class="d-flex">
<div class="dropdown me-1">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-offset="10,20">
Offset
</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>
</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" data-bs-toggle="dropdown" aria-expanded="false" data-bs-reference="parent">
<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>
</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 autoClose
sugandi ye walasa ka nin kɛcogo in Changer de la dropdown.
<div class="btn-group">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-auto-close="true" aria-expanded="false">
Default dropdown
</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">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-auto-close="inside" aria-expanded="false">
Clickable outside
</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">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
Clickable inside
</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">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-auto-close="false" aria-expanded="false">
Manual close
</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>
CSS ye
Yɛlɛma-yɛlɛmaw
A farala a kan v5.2.0 kɔnɔBootstrap ka CSS fɛn caman sɛgɛsɛgɛli fɛɛrɛ dɔ ye min bɛ ka wuli ka bɔ a nɔ na, sisan fɛnw bɛ baara kɛ ni sigida CSS fɛn caman sɛgɛsɛgɛli ye on .dropdown-menu
for for enhanced real-time customization. Nafa minnu bɛ CSS fɛn caman sɛgɛsɛgɛli la, olu bɛ sigi Sass fɛ, o la Sass ka ladamuni bɛ dɛmɛ hali bi, o fana.
--#{$prefix}dropdown-zindex: #{$zindex-dropdown};
--#{$prefix}dropdown-min-width: #{$dropdown-min-width};
--#{$prefix}dropdown-padding-x: #{$dropdown-padding-x};
--#{$prefix}dropdown-padding-y: #{$dropdown-padding-y};
--#{$prefix}dropdown-spacer: #{$dropdown-spacer};
@include rfs($dropdown-font-size, --#{$prefix}dropdown-font-size);
--#{$prefix}dropdown-color: #{$dropdown-color};
--#{$prefix}dropdown-bg: #{$dropdown-bg};
--#{$prefix}dropdown-border-color: #{$dropdown-border-color};
--#{$prefix}dropdown-border-radius: #{$dropdown-border-radius};
--#{$prefix}dropdown-border-width: #{$dropdown-border-width};
--#{$prefix}dropdown-inner-border-radius: #{$dropdown-inner-border-radius};
--#{$prefix}dropdown-divider-bg: #{$dropdown-divider-bg};
--#{$prefix}dropdown-divider-margin-y: #{$dropdown-divider-margin-y};
--#{$prefix}dropdown-box-shadow: #{$dropdown-box-shadow};
--#{$prefix}dropdown-link-color: #{$dropdown-link-color};
--#{$prefix}dropdown-link-hover-color: #{$dropdown-link-hover-color};
--#{$prefix}dropdown-link-hover-bg: #{$dropdown-link-hover-bg};
--#{$prefix}dropdown-link-active-color: #{$dropdown-link-active-color};
--#{$prefix}dropdown-link-active-bg: #{$dropdown-link-active-bg};
--#{$prefix}dropdown-link-disabled-color: #{$dropdown-link-disabled-color};
--#{$prefix}dropdown-item-padding-x: #{$dropdown-item-padding-x};
--#{$prefix}dropdown-item-padding-y: #{$dropdown-item-padding-y};
--#{$prefix}dropdown-header-color: #{$dropdown-header-color};
--#{$prefix}dropdown-header-padding-x: #{$dropdown-header-padding-x};
--#{$prefix}dropdown-header-padding-y: #{$dropdown-header-padding-y};
Customization through CSS variables bɛ se ka ye .dropdown-menu-dark
kalasi kan an bɛ nafa kɛrɛnkɛrɛnnenw wuli yɔrɔ min na k’a sɔrɔ an ma CSS sugandilan fila fara ɲɔgɔn kan.
--#{$prefix}dropdown-color: #{$dropdown-dark-color};
--#{$prefix}dropdown-bg: #{$dropdown-dark-bg};
--#{$prefix}dropdown-border-color: #{$dropdown-dark-border-color};
--#{$prefix}dropdown-box-shadow: #{$dropdown-dark-box-shadow};
--#{$prefix}dropdown-link-color: #{$dropdown-dark-link-color};
--#{$prefix}dropdown-link-hover-color: #{$dropdown-dark-link-hover-color};
--#{$prefix}dropdown-divider-bg: #{$dropdown-dark-divider-bg};
--#{$prefix}dropdown-link-hover-bg: #{$dropdown-dark-link-hover-bg};
--#{$prefix}dropdown-link-active-color: #{$dropdown-dark-link-active-color};
--#{$prefix}dropdown-link-active-bg: #{$dropdown-dark-link-active-bg};
--#{$prefix}dropdown-link-disabled-color: #{$dropdown-dark-link-disabled-color};
--#{$prefix}dropdown-header-color: #{$dropdown-dark-header-color};
Sass bεε bε bεn
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: var(--#{$prefix}border-color-translucent);
$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($dropdown-link-color, 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-x: $dropdown-item-padding-x;
$dropdown-header-padding-y: $dropdown-padding-y;
// fusv-disable
$dropdown-header-padding: $dropdown-header-padding-y $dropdown-header-padding-x; // Deprecated in v5.2.0
// fusv-enable
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 .show
kalan sɛgɛsɛgɛli ye bangebaga .dropdown-menu
kan . 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ɛɛ.
mouseover
in 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
mouseover
bɛ 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 type="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown trigger
</button>
<ul class="dropdown-menu">
...
</ul>
</div>
JavaScript fɛ
Aw bɛ fɛnw wele JavaScript fɛ:
const dropdownElementList = document.querySelectorAll('.dropdown-toggle')
const dropdownList = [...dropdownElementList].map(dropdownToggleEl => 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ɛ
I n’a fɔ sugandiliw bɛ se ka tɛmɛ data attributes walima JavaScript fɛ, i bɛ se ka sugandi tɔgɔ dɔ fara data-bs-
, i n’a fɔ a bɛ cogo min na data-bs-animation="{value}"
. 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, baara kɛ data-bs-custom-class="beautifier"
ni data-bs-customClass="beautifier"
.
Kabini Bootstrap 5.2.0, yɔrɔw bɛɛ bɛ dɛmɛ don kunnafoni- falen-falen-yɔrɔ-ko -kɛcogodata-bs-config
dɔ la min bɛ se ka yɔrɔw labɛncogo nɔgɔmanw bila i n’a fɔ JSON sɛrɛ. Ni fɛn dɔ bɛ data-bs-config='{"delay":0, "title":123}'
ni ni data-bs-title="456"
fɛnw ye, nafa laban title
bɛna kɛ 456
ani kunnafoni danfaralenw bɛna nafaw wuli minnu dira data-bs-config
. O tɛmɛnen 'kɔ, kunnafoni-falen-falen-minɛn minnu bɛ yen olu bɛ Se ka JSON nafaw Ladon i n'a fɔ data-bs-delay='{"show":0,"hide":150}'
.
Tɔ̀gɔ | Ka sɛbɛen masin na | Fɔlɔ | Cogojirali |
---|---|---|---|
autoClose |
boolean, juru | true |
A’ ye auto close kɛcogo labɛn ka ɲɛsin dropdown ma:
|
boundary |
juru, fɛn dɔ | '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ɛ . |
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, sɛrɛ, baarakɛcogo | [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ɛ . |
popperConfig |
null, fɛn, baara | 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 labɛnni fɛn dɔ kan Popper ye. |
reference |
juru, fɛn, fɛ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ɛ . |
Baara kɛ ni baarakɛcogo ye nipopperConfig
const dropdown = new bootstrap.Dropdown(element, {
popperConfig(defaultBsPopperConfig) {
// const newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Fɛɛrɛw
Kɛcogo | Cogojirali |
---|---|
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 la: 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) . |
hide |
A bɛ navbar walima navigation tabbed dilen dɔ ka menu dropdown dogo. |
show |
A bɛ navbar walima navigation tabbed dilen dɔ ka menu dropdown jira. |
toggle |
A bɛ navbar walima navigation tabbed dilen dɔ ka menu dropdown wuli. |
update |
A bɛ fɛn dɔ ka 'yɔrɔ kura ye. |
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.dropdown
ani hidden.bs.dropdown
ko kɛlenw bɛ ni clickEvent
nafolo 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.
Ko kɛlen suguya | Cogojirali |
---|---|
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. |
show.bs.dropdown |
A bɛ tasuma don o yɔrɔnin bɛɛ ni show misali 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. |
const myDropdown = document.getElementById('myDropdown')
myDropdown.addEventListener('show.bs.dropdown', event => {
// do something...
})