Saltar al contenido principal Salta a docs navegación
in English

Navs y pestañas

Qillqakuna chaymanta ejemplokuna imayna Bootstrap kaqpa churasqa puriy componentekuna llamk'achinapaq.

Base nav

Navegación Bootstrap kaqpi tarikuq general marcayta chaymanta estilokuna qunakuy, base .navclasemanta ruwasqa chaymanta mana atisqa estadokunaman. Sapa estilopura tikranapaq tikraq clasekunata tikray.

Componente base .navflexbox kaqwan ruwasqa chaymanta huk sinchi cimientota qun tukuy laya componentes de navegación ruwanapaq. Wakin estilo llallichiykunata (listakunawan llamk'anapaq), wakin t'inki hunt'achiyta aswan hatun tupachiy áreas kaqpaq, chaymanta sapsi mana atichisqa estilota yapan.

Componente base .navnisqapiqa manam ima .activeestadotapas churanchu. Kay qatiq ejemplokunan claseta churanku, aswantaqa kay clase particular mana ima estilo especialtapas llank’achisqanmanta rikuchinapaq.

Yanapakuq tecnologiakunaman ruwana estadota apachinapaq, aria-currentlaya llamk'achiy — pagekunan p'anqapaq chanin llamk'achispa, utaq truekunan kaq imapaq huk huñupi.

<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>

Clases tukuyninpi llamk'achisqa kanku, chayrayku marcasqayki super flexible kanman. Utilizar <ul>s como arriba, <ol>si el orden de tus artículos es importante, o rollo tu propio con un <nav>elemento. Imaraykuchus chay .navllamk'achiykuna display: flex, nav t'inkikuna kikinta purinku imaynachus nav elementokuna ruwanku, ichaqa mana chay yapasqa markawan.

<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>

Estilos disponibles

Cambiar el estilo de .navs componente con modificadores y utilidades. Necesitasqaykiman hina chaqruspa tupachiy, utaq qampaq ruway.

Alineación horizontal nisqa

Nav kaqniykipa horizontal chiqanchayta flexbox yanapakuykunawan tikray . Ñawpaqmanta, navs lluq'iman chiqanchasqa kanku, ichataq chawpiman icha pañaman chiqanchasqaman mana sasachakuspa tikrayta atinki.

Chawpichasqa kaykunawan .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>

Paña-allichasqa kaywan .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>

Sayanpa

.flex-columnNavegaciónniyki pilay flex elemento direccionta utilidadwan tikraspa . ¿Necesitas apilarlos en algunos puertos de vistas pero no otros? Kutichiq layakunata llamk'achiy (kayhina, .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>

Sapa kuti hina, sayaq puriyqa atikunmi mana <ul>s nisqawanpas.

<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>

Pestañas

Hawamanta nav básica kaqmanta hapin chaymanta .nav-tabsclaseta yapan huk tabbed interfaz ruwanapaq. Chaykunata llamk'achiy tablakuna ruwanapaq tabla JavaScript plugin nisqaykuwan .

<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>

Pastillas

Chay kikin HTML nisqallata hap'iy, ichataq .nav-pillschaypa rantinpi llamk'achiy:

<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>

Llenar y justificar

Kallpanchay qampaq .nav's contenidokuna hunt'asqa tarikuq anchota huk iskay tikraq clasekunamanta mast'arinanpaq. Llapan kaq espaciota .nav-items nisqaykiwan proporcionalmente hunt’anaykipaqqa .nav-fill. Reparay llapa horizontal espacio ocupasqa kasqanmanta, ichaqa manan sapa nav elemento kaqlla anchoyoqchu.

<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>

-manta ruwasqa puriyta llamk'achkaspa <nav>, mana manchakuspa saqiyta atikunki imaynachus elementokuna estilopaq .nav-itemsapalla .nav-linkmañakun hina .<a>

<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>

Igual anchoyuq elementokunapaqqa .nav-justified. Llapan horizontal espacio nav t'inkikunawan hap'isqa kanqa, ichataq mana .nav-fillhawapi hinachu, sapa nav elemento kaqlla anchoyuq kanqa.

<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>

-based navigation .nav-fillllamk'achispa ejemploman rikch'akuq .<nav>

<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>

Flex utilidadkunawan llamk’ay

Sichus kutichiq nav variaciones kaqmanta necesitanki, huk serie flexbox yanapakuykunata llamk'achiyta yuyaykuy . Aswan verbose kaqtinpas, kay yanapakuykuna aswan hatun ruwayta qunku tukuy kutichiq p'akiykunapi. Uraypi kaq rikch'anapi, navniyku aswan pisi p'akiypi pilasqa kanqa, chaymanta huk horizontal churayman adaptakunqa mayqinchus tarikuq anchota hunt'achin huch'uy p'akiymanta qallarispa.

<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>

Accesibilidad nisqamanta

Sichus navs llamk'achkanki huk purina barra qunapaq, ama hina kaspa huk role="navigation"aswan lógico tayta waqaychanaman yapay chaymanta <ul>, utaq huk <nav>elementota tukuy puriypa muyuriqninpi p'istuy. Ama ruwayta <ul>kikinman yapaychu, kayqa hark'anmanmi yanapaq tecnologiakuna chiqap lista hina willasqa kananpaq.

Reparay puriy barrakuna, qhawaypi estiloyuq kaptinpas .nav-tabsclasewan tablakuna hina, mana qusqachu kanan tiyan , role="tablist"utaq role="tab"atributos role="tabpanel". Kaykunaqa interfazkuna tablayuq dinamico kaqpaqlla allin kanku, imaynachus WAI ARIA Qillqana Ruwaykunapi willasqa kachkan . Rikuy JavaScript ruwayta huk rikch'anapaq kay t'aqapi dinamico tabbed interfaces kaqpaq. Atributo mana necesariochu interfaces dinámicas tablado kaqpi JavaScriptniyku akllasqa estadota ruwan ruwaq tablapi aria-currentyapaspa .aria-selected="true"

Utilizando los desplegables

Yanapakuy urayk'aq menúkuna huk pisi yapasqa HTML kaqwan chaymanta urayk'aq JavaScript plugin kaqwan .

Pestañas con desplegables

<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>

Pastillas con caídas

<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>

Sass

Variables nisqakuna

$nav-link-padding-y:                .5rem;
$nav-link-padding-x:                1rem;
$nav-link-font-size:                null;
$nav-link-font-weight:              null;
$nav-link-color:                    $link-color;
$nav-link-hover-color:              $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;

JavaScript nisqap ruwaynin

JavaScript plugin tablata llamk'achiy —sapallan utaq huñusqa bootstrap.jswillañiqi kaqnintakama churay— purina tablakunayku chaymanta pastillakunayku mast'ariypaq tablakuna ruwanakuna kitipi kaqmanta ruwanapaq.

Interfaces de pestañas dinámicas, imaynachus WAI ARIA Autorización Ruwaykunapirole="tablist" willasqa , , role="tab", role="tabpanel", chaymanta yapa atributokuna mañanku chaymanta aria-estructurankuta, ruwanankuta chaymanta kunan estadonkuta yanapakuq tecnologiakuna (pantalla ñawiriqkuna hina) ruwaqkunaman apachinankupaq. Aswan allin ruway hina, <button>elementokuna tablakuna kaqpaq llamk'achiyta yuyaychayku, imaynachus kay kamachiykuna huk tikray tikrayta llamk'achinku, aswan t'inkikuna musuq p'anqaman utaq kitiman puriq.

Reparay kay interfazkuna tablayuq dinamico kaqpi mana urayk'aq menúkunayuq kananku tiyan, kay iskaynin llamk'anapaq chaymanta yaykuy atiy sasachakuykunata ruwan. Huk llamk'achiy qhawaymanta, kunan rikuchisqa tablamanta llamk'achiq elemento mana chaylla rikukuq kasqan (imaynachus wichq'asqa urayk'aq menú ukhupi kachkan) pantayta ruwanman. Huk yaykuy atiymanta qhawaymanta, kunan pacha mana kanchu yuyayniyuq ñan kay laya ruwayta huk WAI ARIA patrón estándar kaqman mapa ruwanapaq, niyta munan mana facilta ruwayta atikunmanchu yanapakuq tecnologiakuna llamk'aqkunaman entiendenapaq.

Kayqa wakin tiyanayuq willaymi chay Wasi ñiqipa tinkisqa willaynin. Huk tabla ñit'iyqa kaypa rikuyninta qatiqpaq tikranqa. JavaScript tabla clasekunata t'inkin, contenido rikuy chaymanta estilo kamachiypaq. Chayta llamk'achiy atikunki tablakunawan, pastillakunawan, chaymanta ima wak .nav-wan kallpachasqa puriywanpas.

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.

<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="contact-tab" data-bs-toggle="tab" data-bs-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Contact</button>
  </li>
</ul>
<div class="tab-content" id="myTabContent">
  <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
  <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
  <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
</div>

Yanapanapaq necesidadniykiman hina, kayqa llamkan <ul>-sapanchasqa markawan, imaynachus patamanta rikuchisqa, utaq mayqin munasqa “kikiykipaq rollo” markawan. Reparay sichus , llamk'achkanki <nav>, mana chiqamanta yapanaykichu tiyan role="tablist", kayqa elementopa nativo ruwayninta puriypa señalnin hina llallichinman. Aswanpas, huk elemento alternativo nisqaman tikray (urapi ejemplopi, huk simple <div>) hinaspa <nav>muyuriqninpi p'istuy.

<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>
  </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">...</div>
  <div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">...</div>
  <div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">...</div>
</div>

Tabs pluginpas pastillakunawan llamk’an.

Kayqa wakin tiyanayuq willaymi chay Wasi ñiqipa tinkisqa willaynin. Huk tabla ñit'iyqa kaypa rikuyninta qatiqpaq tikranqa. JavaScript tabla clasekunata t'inkin, contenido rikuy chaymanta estilo kamachiypaq. Chayta llamk'achiy atikunki tablakunawan, pastillakunawan, chaymanta ima wak .nav-wan kallpachasqa puriywanpas.

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.

<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>
</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">...</div>
  <div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">...</div>
  <div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">...</div>
</div>

Y con pastillas verticales.

Kayqa wakin tiyanayuq willaymi chay Wasi ñiqipa tinkisqa willaynin. Huk tabla ñit'iyqa kaypa rikuyninta qatiqpaq tikranqa. JavaScript tabla clasekunata t'inkin, contenido rikuy chaymanta estilo kamachiypaq. Chayta llamk'achiy atikunki tablakunawan, pastillakunawan, chaymanta ima wak .nav-wan kallpachasqa puriywanpas.

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 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-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">...</div>
    <div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
    <div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
    <div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
  </div>
</div>

Atributos de datos nisqawan yanapachikuspa

Huk tabla utaq pastilla puriyta mana ima JavaScript qillqaspa llamk'achiyta atikunki huk elemento kaqpi willaylla data-bs-toggle="tab"utaq data-bs-toggle="pill"huk elemento kaqpi. Kay willay layakunata .nav-tabsutaq kaqpi llamk'achiy .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">...</div>
  <div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
  <div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
  <div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>

JavaScript nisqawan

JavaScript kaqnintakama tablakuna ruwanakuna atichiy (sapa tablakuna sapalla llamk'achinan tiyan):

var triggerTabList = [].slice.call(document.querySelectorAll('#myTab button'))
triggerTabList.forEach(function (triggerEl) {
  var tabTrigger = new bootstrap.Tab(triggerEl)

  triggerEl.addEventListener('click', function (event) {
    event.preventDefault()
    tabTrigger.show()
  })
})

Sapa tablakunata achka ruwaykunapi llamk'achiyta atikunki:

var triggerEl = document.querySelector('#myTab button[data-bs-target="#profile"]')
bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name

var triggerFirstTabEl = document.querySelector('#myTab li:first-child button')
bootstrap.Tab.getInstance(triggerFirstTabEl).show() // Select first tab

Efecto de desvanecer

Pestañakuna chinkananpaqqa, .fadesapakamaman yapay .tab-pane. Ñawpaq kaq tabla panelpas .showqallariy contenido rikukuq kananpaq kanan tiyan.

<div class="tab-content">
  <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
  <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
  <div class="tab-pane fade" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
  <div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>

Métodos

Métodos y transiciones asíncronas

Llapan API ruwanakuna mana sink'uyuq kanku chaymanta huk tikrayta qallarinku . Paykunaqa kutinku waqyaqman chaylla transición qallarisqa ichaqa manaraq tukukuchkaptin . Chaymantapas, huk tikray componente kaqpi huk método waqyay mana qhawasqachu kanqa .

Aswan willakuypaq JavaScript qillqaykuta qhaway .

constructor

Huk elemento de pestaña chaymanta contenido waqaychanata llamk'achin. Tab huk data-bs-targetutaq, huk tinkiyta llamk'achkanki, huk hrefatributoyuq kanan tiyan, huk waqaychana nodo DOM kaqpi targeting.

<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>

<div class="tab-content">
  <div class="tab-pane active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
  <div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
  <div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
  <div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>

<script>
  var firstTabEl = document.querySelector('#myTab li:last-child button')
  var firstTab = new bootstrap.Tab(firstTabEl)

  firstTab.show()
</script>

show

Qusqa tablata akllan chaymanta tinkisqa panelninta rikuchin. Ima huk tablapas ñawpaq akllasqa karqan mana akllasqaman tukun chaymanta tinkisqa panelnin pakasqa. Llamaqman kutimun manaraq tabla panel chiqamanta rikuchisqa kachkaptin (icha manaraq shown.bs.tabruway ruwakuchkaptin).

  var someTabTriggerEl = document.querySelector('#someTabTrigger')
  var tab = new bootstrap.Tab(someTabTriggerEl)

  tab.show()

dispose

Huk elementopa tablanta chinkachin.

getInstance

Método estático mayqinchus huk DOM elementowan tinkisqa tabla instanciata jap'iyta atikun

var triggerEl = document.querySelector('#trigger')
var tab = bootstrap.Tab.getInstance(triggerEl) // Returns a Bootstrap tab instance

getOrCreateInstance

Método estático mayqinchus huk DOM elementowan tinkisqa tab instanciata hap'iyta atikun, utaq musuq ruwayta sichus mana qallarisqachu karqa

var triggerEl = document.querySelector('#trigger')
var tab = bootstrap.Tab.getOrCreateInstance(triggerEl) // Returns a Bootstrap tab instance

Events

Musuq tablata rikuchispa, sucesokuna kay ordenpi ninawan:

  1. hide.bs.tab(kunan llamk'aq tablapi)
  2. show.bs.tab(qhawanapaq kaq tablapi)
  3. hidden.bs.tab(ñawpaq ruwaq tablapi, kikin hide.bs.tabruwaypaq)
  4. shown.bs.tab(musuq-ruray chayraq rikuchisqa ñiqipi, kikin show.bs.tabruwaypaq)

Sichus mana mayqin tablapas ruwasqañachu karqan, chaymanta hide.bs.tabchaymanta hidden.bs.tabruwaykuna mana llamk'achisqachu kanqa.

Tipo de evento Willay
show.bs.tab Kay ruwayqa tabla rikuchiypi ninawan, ichaqa manaraq musuq tabla rikuchisqa kachkaptin. Utilizar event.targety event.relatedTargetpara target a la pestaña activa y la pestaña activo anterior (si está disponible) respectivamente.
shown.bs.tab Kay ruwayqa tabla rikuchiypi ninawan huk tabla rikuchisqa kaptin. Utilizar event.targety event.relatedTargetpara target a la pestaña activa y la pestaña activo anterior (si está disponible) respectivamente.
hide.bs.tab Kay suceso ninawan mayk'aq huk musuq tabla rikuchisqa kanan tiyan (hinallataq chayhina ñawpaq ruwaq tabla pakasqa kanan tiyan). Utilizar event.targetchaymanta event.relatedTargetkunan ruwasqa tablata chaymanta musuq chaylla llamk'achiq tablata, sapakama.
hidden.bs.tab Kay ruwayqa musuq tabla rikuchisqa kaptin (hinallataq chayhina ñawpaq ruwaq tabla pakasqa kachkan). Utilizar event.targetchaymanta event.relatedTargetñawpaq ruwasqa tablata chaymanta musuq ruwaq tablata targetta ruwanapaq, chaymanta.
var tabEl = document.querySelector('button[data-bs-toggle="tab"]')
tabEl.addEventListener('shown.bs.tab', function (event) {
  event.target // newly activated tab
  event.relatedTarget // previous active tab
})