Navs na ba onglets
Mikanda mpe bandakisa mpo na ndenge ya kosalela biloko ya mobembo oyo ezali na kati ya Bootstrap.
Base nav
Navigation oyo ezali na Bootstrap ekabolaka marquage général mpe ba styles, kobanda na .nav
classe ya base tii na ba états actifs mpe désactivés. Swap ba classes ya modificateur pona ko changer entre style moko na moko.
Composante ya base .nav
etongami na flexbox mpe epesaka fondation makasi mpo na kotonga ba composants ya navigation ya ndenge nionso. Ezali na mwa ba overrides ya style (mpo na kosala na ba liste), mwa padding ya lien mpo na ba zones ya hit ya minene, mpe styling ya base désactivé.
Composante ya base .nav
ezali na .active
état moko te. Ba exemples oyo elandi ezali na classe, surtout pona kolakisa que classe oyo particulière e déclencher ata styling moko ya spécial te.
Mpo na kopesa ezalela ya mosala na ba tekiniki ya lisalisi, salela aria-current
attribut — kosalela page
motuya mpo na lokasa ya lelo, to true
mpo na eloko ya lelo na ensemble.
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Ba classes esalemaka na mobimba, donc marquage na yo ekoki kozala super flexible. Salelá <ul>
s lokola oyo ezali likoló, <ol>
soki molongo ya biloko na yo ezali na ntina, to rouler oyo ya yo moko na <nav>
élément moko. Po ba .nav
usages display: flex
, ba liens nav ezo comporter ndenge moko na ba éléments nav elingaki, mais sans marquage supplémentaire.
<nav class="nav">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Ba styles oyo ezali
Bobongola style ya .nav
composant s na ba modificateurs na ba utilitaires. Sangisa mpe kosangisa soki esengeli, to tonga oyo ya yo moko.
Alignment ya horizontal
Bobongola alignment horizontal ya nav na yo na ba utilitaires flexbox . Par défaut, ba navs ezali aligné na gauche, kasi okoki ko changer yango facilement na aligné na centre to na droite.
Ezali na centre na .justify-content-center
:
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Ezali na boyokani na lobɔkɔ ya mobali na .justify-content-end
:
<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Ya kotelema
Stack navigation na yo na ko changer direction ya flex item na .flex-column
utilitaire. Besoin ya ko empiler bango na ba viewports mosusu mais misusu te? Salelá ba versions oyo ezo répondre (par exemple, .flex-sm-column
).
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Comme toujours, navigation verticale ezali possible sans <ul>
s, trop.
<nav class="nav flex-column">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Ba onglets
Azuaka nav ya base na likolo pe abakisi .nav-tabs
classe pona ko produire interface ya onglet. Salelá yango mpo na kosala ba régions ya ba tabbables na plugin na biso ya JavaScript ya tab .
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Ba pilili
Zwá kaka HTML yango, kasi salelá .nav-pills
na esika na yango:
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Tondisa mpe kolongisa
Forcer .nav
ba contenus ya yo 's pona ko extend largeur mobimba oyo ezali moko ya ba classes mibale ya modificateur. Mpo na kotondisa na ndenge oyo ebongi bisika nyonso oyo ezali na .nav-item
s na yo, salelá .nav-fill
. Simbá ete esika nyonso ya horizontal ezali occupé, kasi eloko nyonso ya nav ezali na bonene ndenge moko te.
<ul class="nav nav-pills nav-fill">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Much longer nav link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Ntango ozali kosalela <nav>
navigation -based, okoki kotika na kimia .nav-item
lokola kaka .nav-link
esengeli mpo na ba <a>
éléments ya styling.
<nav class="nav nav-pills nav-fill">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Much longer nav link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Mpo na biloko oyo ezali na bonene ekokani, salelá .nav-justified
. Espace horizontal nionso ekozala occupé na ba liens nav, mais contrairement na oyo ya .nav-fill
likolo, eloko nionso ya nav ekozala na largeur moko.
<ul class="nav nav-pills nav-justified">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Much longer nav link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Ndenge moko na .nav-fill
ndakisa oyo esalelaka <nav>
navigation oyo esalemi na -.
<nav class="nav nav-pills nav-justified">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Much longer nav link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Kosala na ba utilitaires flex
Soki ozali na mposa ya ba variations nav oyo ezo répondre, kanisá kosalela série ya ba utilitaires ya flexbox . Atako ezali verbose mingi, ba utilitaires oyo epesaka personnalisation monene na kati ya ba points de rupture oyo ezo répondre. Na ndakisa oyo ezali awa na nse, nav na biso ekozala ebele na point de rupture ya nse, sima ko adapter na disposition horizontale oyo etondisaka largeur oyo ezali kobanda na point de rupture ya moke.
<nav class="nav nav-pills flex-column flex-sm-row">
<a class="flex-sm-fill text-sm-center nav-link active" aria-current="page" href="#">Active</a>
<a class="flex-sm-fill text-sm-center nav-link" href="#">Longer nav link</a>
<a class="flex-sm-fill text-sm-center nav-link" href="#">Link</a>
<a class="flex-sm-fill text-sm-center nav-link disabled">Disabled</a>
</nav>
Na oyo etali accessibilité
Soki ozali kosalela navs mpo na kopesa barre ya navigation, sala makasi obakisa a role="navigation"
na conteneur parent oyo ezali na logique mingi ya <ul>
, to envelopper <nav>
élément moko zingazinga ya navigation mobimba. Kobakisa te rôle na <ul>
yango moko, mpo yango ekopekisa yango esakolama lokola liste ya solosolo na ba technologies ya kosunga.
Yeba ete ba barres ya navigation, ata soki esalemi na ndenge ya komona lokola ba onglets na .nav-tabs
classe, esengeli te kopesama role="tablist"
, role="tab"
to role="tabpanel"
ba attributs. Yango ebongi kaka mpo na ba interfaces ya ba onglets dynamiques, ndenge elobami na modèle ya ba onglets ya Guide ya Mimeseno ya Bokomi ya ARIA . Tala bizaleli ya JavaScript mpo na ba interfaces ya ba onglets dynamiques na eteni oyo mpo na ndakisa. Attribut aria-current
ezali na ntina te na ba interfaces onglet dynamique puisque JavaScript na biso esimbaka état oyo eponami na kobakisa aria-selected="true"
na onglet actif.
Kosalela ba dropdowns
Bakisa ba menu oyo ezali kokita na mwa HTML ya kobakisa mpe ba plugin ya JavaScript oyo ezali kokita .
Ba onglets na ba dropdowns
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</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>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Ba pilili na ba dropdowns
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</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>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
CSS
Ba variables oyo ezali
Ebakisami na v5.2.0Lokola eteni ya approche ya ba variables CSS oyo ezali ko évoluer ya Bootstrap, ba navs basalelaka sikoyo ba variables CSS locales na .nav
, .nav-tabs
, mpe .nav-pills
mpo na personnalisation ya temps réel oyo ematisami. Ba valeurs pona ba variables ya CSS etiamaki na nzela ya Sass, yango wana personnalisation ya Sass ezali kaka kosungama, pe.
Na .nav
kelasi ya base:
--#{$prefix}nav-link-padding-x: #{$nav-link-padding-x};
--#{$prefix}nav-link-padding-y: #{$nav-link-padding-y};
@include rfs($nav-link-font-size, --#{$prefix}nav-link-font-size);
--#{$prefix}nav-link-font-weight: #{$nav-link-font-weight};
--#{$prefix}nav-link-color: #{$nav-link-color};
--#{$prefix}nav-link-hover-color: #{$nav-link-hover-color};
--#{$prefix}nav-link-disabled-color: #{$nav-link-disabled-color};
Na .nav-tabs
kelasi ya modificateur:
--#{$prefix}nav-tabs-border-width: #{$nav-tabs-border-width};
--#{$prefix}nav-tabs-border-color: #{$nav-tabs-border-color};
--#{$prefix}nav-tabs-border-radius: #{$nav-tabs-border-radius};
--#{$prefix}nav-tabs-link-hover-border-color: #{$nav-tabs-link-hover-border-color};
--#{$prefix}nav-tabs-link-active-color: #{$nav-tabs-link-active-color};
--#{$prefix}nav-tabs-link-active-bg: #{$nav-tabs-link-active-bg};
--#{$prefix}nav-tabs-link-active-border-color: #{$nav-tabs-link-active-border-color};
Na .nav-pills
kelasi ya modificateur:
--#{$prefix}nav-pills-border-radius: #{$nav-pills-border-radius};
--#{$prefix}nav-pills-link-active-color: #{$nav-pills-link-active-color};
--#{$prefix}nav-pills-link-active-bg: #{$nav-pills-link-active-bg};
Ba variables ya Sass
$nav-link-padding-y: .5rem;
$nav-link-padding-x: 1rem;
$nav-link-font-size: null;
$nav-link-font-weight: null;
$nav-link-color: var(--#{$prefix}link-color);
$nav-link-hover-color: var(--#{$prefix}link-hover-color);
$nav-link-transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out;
$nav-link-disabled-color: $gray-600;
$nav-tabs-border-color: $gray-300;
$nav-tabs-border-width: $border-width;
$nav-tabs-border-radius: $border-radius;
$nav-tabs-link-hover-border-color: $gray-200 $gray-200 $nav-tabs-border-color;
$nav-tabs-link-active-color: $gray-700;
$nav-tabs-link-active-bg: $body-bg;
$nav-tabs-link-active-border-color: $gray-300 $gray-300 $nav-tabs-link-active-bg;
$nav-pills-border-radius: $border-radius;
$nav-pills-link-active-color: $component-active-color;
$nav-pills-link-active-bg: $component-active-bg;
Etamboli ya JavaScript
Salelá onglet plugin JavaScript —kotia yango mokomoko to na nzela ya bootstrap.js
fisyé oyo esangisi —mpo na koyeisa monene ba onglets mpe ba pilili na biso ya navigation mpo na kosala ba panneaux ya tabbable ya makambo ya esika.
Oyo ezali mwa makambo ya esika ya kofanda oyo ezali na boyokani na onglet Ndako . Kofina tab mosusu ekobongola visibilité ya oyo mpo na oyo elandi. Onglet JavaScript ezo swap ba classes pona ko contrôler visibilité ya contenus na styling. Okoki kosalela yango na ba onglets, ba pilili, mpe na navigation mosusu nyonso oyo .nav
esalaka -powered.
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Contact tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Disabled tab's associated content.
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home-tab-pane" type="button" role="tab" aria-controls="home-tab-pane" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile-tab-pane" type="button" role="tab" aria-controls="profile-tab-pane" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact-tab-pane" type="button" role="tab" aria-controls="contact-tab-pane" aria-selected="false">Contact</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="disabled-tab" data-bs-toggle="tab" data-bs-target="#disabled-tab-pane" type="button" role="tab" aria-controls="disabled-tab-pane" aria-selected="false" disabled>Disabled</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel" aria-labelledby="home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="profile-tab-pane" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="contact-tab-pane" role="tabpanel" aria-labelledby="contact-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="disabled-tab-pane" role="tabpanel" aria-labelledby="disabled-tab" tabindex="0">...</div>
</div>
Mpo na kosalisa na kokokana na bamposa na yo, yango esalaka na <ul>
-basé na bilembo, lokola emonisami awa na likoló, to na bilembo nyonso ya “kobalusa ya yo moko” oyo esalemi na ndenge ya arbitraire. Yeba ete soki ozali kosalela <nav>
, osengeli te kobakisa role="tablist"
mbala moko na yango, mpamba te yango ekolongola mokumba ya mboka ya eleman lokola elembo ya botali. Na esika ya kosala bongo, bongola na eloko mosusu (na ndakisa oyo ezali awa na nse, eloko moko ya pɛtɛɛ <div>
) mpe zingá yango <nav>
zingazinga na yango.
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button class="nav-link active" id="nav-home-tab" data-bs-toggle="tab" data-bs-target="#nav-home" type="button" role="tab" aria-controls="nav-home" aria-selected="true">Home</button>
<button class="nav-link" id="nav-profile-tab" data-bs-toggle="tab" data-bs-target="#nav-profile" type="button" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</button>
<button class="nav-link" id="nav-contact-tab" data-bs-toggle="tab" data-bs-target="#nav-contact" type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Contact</button>
<button class="nav-link" id="nav-disabled-tab" data-bs-toggle="tab" data-bs-target="#nav-disabled" type="button" role="tab" aria-controls="nav-disabled" aria-selected="false" disabled>Disabled</button>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="nav-disabled" role="tabpanel" aria-labelledby="nav-disabled-tab" tabindex="0">...</div>
</div>
Plugin ya ba onglets esalaka pe na ba pilili.
Oyo ezali mwa makambo ya esika ya kofanda oyo ezali na boyokani na onglet Ndako . Kofina tab mosusu ekobongola visibilité ya oyo mpo na oyo elandi. Onglet JavaScript ezo swap ba classes pona ko contrôler visibilité ya contenus na styling. Okoki kosalela yango na ba onglets, ba pilili, mpe na navigation mosusu nyonso oyo .nav
esalaka -powered.
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Contact tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Disabled tab's associated content.
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="pills-home-tab" data-bs-toggle="pill" data-bs-target="#pills-home" type="button" role="tab" aria-controls="pills-home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-profile-tab" data-bs-toggle="pill" data-bs-target="#pills-profile" type="button" role="tab" aria-controls="pills-profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-contact-tab" data-bs-toggle="pill" data-bs-target="#pills-contact" type="button" role="tab" aria-controls="pills-contact" aria-selected="false">Contact</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-disabled-tab" data-bs-toggle="pill" data-bs-target="#pills-disabled" type="button" role="tab" aria-controls="pills-disabled" aria-selected="false" disabled>Disabled</button>
</li>
</ul>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="pills-disabled" role="tabpanel" aria-labelledby="pills-disabled-tab" tabindex="0">...</div>
</div>
Mpe na bankisi oyo ezali semba. Na lolenge ya malamu, mpo na ba onglets verticales, osengeli mpe kobakisa aria-orientation="vertical"
na récipient ya liste ya ba onglets.
Oyo ezali mwa makambo ya esika ya kofanda oyo ezali na boyokani na onglet Ndako . Kofina tab mosusu ekobongola visibilité ya oyo mpo na oyo elandi. Onglet JavaScript ezo swap ba classes pona ko contrôler visibilité ya contenus na styling. Okoki kosalela yango na ba onglets, ba pilili, mpe na navigation mosusu nyonso oyo .nav
esalaka -powered.
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Disabled tab's associated content.
This is some placeholder content the Messages tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Settings tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
<div class="d-flex align-items-start">
<div class="nav flex-column nav-pills me-3" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<button class="nav-link active" id="v-pills-home-tab" data-bs-toggle="pill" data-bs-target="#v-pills-home" type="button" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</button>
<button class="nav-link" id="v-pills-profile-tab" data-bs-toggle="pill" data-bs-target="#v-pills-profile" type="button" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</button>
<button class="nav-link" id="v-pills-disabled-tab" data-bs-toggle="pill" data-bs-target="#v-pills-disabled" type="button" role="tab" aria-controls="v-pills-disabled" aria-selected="false" disabled>Disabled</button>
<button class="nav-link" id="v-pills-messages-tab" data-bs-toggle="pill" data-bs-target="#v-pills-messages" type="button" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</button>
<button class="nav-link" id="v-pills-settings-tab" data-bs-toggle="pill" data-bs-target="#v-pills-settings" type="button" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</button>
</div>
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="v-pills-disabled" role="tabpanel" aria-labelledby="v-pills-disabled-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab" tabindex="0">...</div>
</div>
</div>
Kozala na makoki ya kozwa yango
Ba interfaces ya ba onglets dynamiques, ndenge elobami na modèle ya ba onglets ya Guide des pratiques d’auteur ya ARIA , esengaka role="tablist"
, role="tab"
, role="tabpanel"
, mpe ba aria-
attributs ya kobakisa mpo na kopesa structure na yango, fonctionnalité, mpe état ya lelo na basaleli ya ba technologies ya lisungi (lokola ba lecteurs d’écran). Lokola momeseno malamu, tozali kopesa toli ya kosalela <button>
biloko mpo na ba onglets, lokola yango ezali ba contrôles oyo e déclencher changement dynamique, na esika ya ba liens oyo ezo naviguer na page to esika ya sika.
Na molongo na motindo ya ARIA Authoring Practices, kaka onglet oyo ezali kosala lelo oyo nde ezwa focus ya clavier. Tango plugin ya JavaScript ebandi, ekozala tabindex="-1"
na ba contrôles nionso ya onglet inactif. Soki onglet oyo ezali kosala sikoyo ezali na focus, ba touches ya curseur e activaka onglet ya liboso/oyo elandi, na plugin oyo ezali kobongola rovingtabindex
na kolanda yango. Kasi, yebá ete plugin ya JavaScript ekesenisaka te ba liste ya ba onglets horizontales mpe verticales soki etali ba interactions ya ba touches ya curseur: ata soki liste ya ba onglets ezali ndenge nini, curseur ya likolo mpe ya gauche ekendaka na onglet oyo eleki, mpe curseur ya se mpe ya droite ekendaka na tab oyo elandi.
tabindex="0"
na kati ya bilembo na yo.
Kosalela ba attributs ya ba données
Okoki ko activer navigation ya onglet to ya pilili sans kokoma JavaScript moko te na ko préciser kaka data-bs-toggle="tab"
to data-bs-toggle="pill"
na élément moko. Salelá bizaleli oyo ya ba données na .nav-tabs
to .nav-pills
.
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="messages-tab" data-bs-toggle="tab" data-bs-target="#messages" type="button" role="tab" aria-controls="messages" aria-selected="false">Messages</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings" type="button" role="tab" aria-controls="settings" aria-selected="false">Settings</button>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel" aria-labelledby="home-tab" tabindex="0">...</div>
<div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">...</div>
<div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab" tabindex="0">...</div>
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab" tabindex="0">...</div>
</div>
Na nzela ya JavaScript
Activer ba onglets ya ba tabbables na nzela ya JavaScript (onglet moko na moko esengeli ko activer yango moko):
const triggerTabList = document.querySelectorAll('#myTab button')
triggerTabList.forEach(triggerEl => {
const tabTrigger = new bootstrap.Tab(triggerEl)
triggerEl.addEventListener('click', event => {
event.preventDefault()
tabTrigger.show()
})
})
Okoki ko activer ba onglets moko moko na ba façons ebele:
const triggerEl = document.querySelector('#myTab button[data-bs-target="#profile"]')
bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name
const triggerFirstTabEl = document.querySelector('#myTab li:first-child button')
bootstrap.Tab.getInstance(triggerFirstTabEl).show() // Select first tab
Effet ya kosila
Mpo na kosala ete ba onglets esila, bakisá .fade
na mokomoko na yango .tab-pane
. Panneau ya onglet ya liboso esengeli mpe kozala .show
na kosala ete makambo ya ebandeli emonanaka.
<div class="tab-content">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="messages" role="tabpanel" aria-labelledby="messages-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="settings-tab" tabindex="0">...</div>
</div>
Ba méthodes ya kosala
Ba méthodes asynchrones na ba transitions
Ba méthodes nionso ya API ezali asynchrone mpe ebandi transition . Bazongaka epai ya moto oyo abengi ntango kaka mbongwana ebandi kasi liboso ete esila . En plus, appel ya méthode na composante ya transition ekozala ignorée .
Tala mikanda na biso ya JavaScript mpo na koyeba makambo mosusu .
Ezali ko activer contenus na yo lokola élément ya onglet.
Okoki kosala instance ya tab na constructeur, ndakisa:
const bsTab = new bootstrap.Tab('#myTab')
Metode | Ndimbola |
---|---|
dispose |
Ebebisaka tab ya élément moko. |
getInstance |
Méthode statique oyo e permettre yo ozua instance ya onglet associé na élément DOM, okoki kosalela yango boye: bootstrap.Tab.getInstance(element) . |
getOrCreateInstance |
Méthode statique oyo ezongisaka instance ya onglet oyo ezo sangana na élément DOM to ezo sala ya sika au cas où ezalaki initialisé te. Okoki kosalela yango boye: bootstrap.Tab.getOrCreateInstance(element) . |
show |
Pona tab oyo epesami mpe elakisaka panneau na yango oyo esangisi yango. Onglet mosusu nyonso oyo eponami liboso ekómaka oyo eponami te mpe etanda na yango oyo esangisi yango ebombami. Ezongi na mobengi yambo ete esika ya tab elakisama mpenza (elingi koloba liboso ete shown.bs.tab likambo esalema). |
Makambo oyo esalemaki
Ntango ozali kolakisa tab ya sika, makambo yango ekobeta na molɔngɔ oyo elandi:
hide.bs.tab
(na tab oyo ezali kosala lelo)show.bs.tab
(na tab oyo esengeli kolakisa)hidden.bs.tab
(na onglet actif ya liboso, ndenge moko na oyo yahide.bs.tab
événement)shown.bs.tab
(na tab oyo euti kolakisa sika oyo ezali kosala sika, ndenge moko na oyo yashow.bs.tab
likambo yango)
Soki onglet moko te ezalaki déjà activé, alors ba événements hide.bs.tab
mpe hidden.bs.tab
ekobeta te.
Lolenge ya likambo | Ndimbola |
---|---|
hide.bs.tab |
Evenement oyo ezo beta tango onglet ya sika esengeli kolakisa (et donc onglet actif ya kala esengeli kobombama). Salelá event.target mpe event.relatedTarget mpo na kopesa motuya na tab oyo ezali kosala sikoyo mpe onglet ya sika oyo ekosalema kala mingi te, na kolanda. |
hidden.bs.tab |
Evenement oyo ezo beta sima ya onglet ya sika elakisami (mpe bongo onglet actif ya kala ebombami). Salelá event.target mpe mpo na event.relatedTarget ko cibler onglet active ya kala mpe onglet active ya sika, respectivement. |
show.bs.tab |
Evenement oyo ezo beta na tab show, mais avant onglet ya sika elakisama. Salelá event.target mpe mpo na event.relatedTarget ko cibler onglet active mpe onglet active ya kala (soki ezali) respectivement. |
shown.bs.tab |
Evenement oyo ezo beta na tab show sima ya tab moko elakisama. Salelá event.target mpe mpo na event.relatedTarget ko cibler onglet active mpe onglet active ya kala (soki ezali) respectivement. |
const tabEl = document.querySelector('button[data-bs-toggle="tab"]')
tabEl.addEventListener('shown.bs.tab', event => {
event.target // newly activated tab
event.relatedTarget // previous active tab
})