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

Tuñiy

Huk pisi clasekunawan chaymanta JavaScript pluginsniykuwan tukuy proyectoykipi contenidopa rikuyninta tikray.

Imayna llamkan

JavaScript urmachiy plugin llamk'achisqa kachkan rikuchiypaq chaymanta pakaypaq. Botonkuna utaq anclakuna gatillokuna hina llamk'achkanku chaymanta elementokuna específicos kaqman mapeasqa kanku mayqinkunatachus tikranki. Huk elementota urmachispaqa heightkunan chanimanta 0. Imayna CSS kawsachiykunata hap'in chayta qusqa, mana paddinghuk .collapseelemento kaqpi llamk'achiy atikunkichu. Aswanpas, claseta huk sapanchasqa p'istu elemento hina llamk'achiy.

Kay componentepa animación efectonqa prefers-reduced-motionmedios tapuymanta hapirin. Yaykuna qillqaykumanta pisiyachisqa kuyuy t'aqapi qhaway .

Qatina

Uraypi kaq ñit'inakunata ñit'iy huk elementota rikuchinaykipaq chaymanta pakanaykipaq clase tikraykunawan:

  • .collapsecontenidota pakan
  • .collapsingtransiciones nisqapi churakun
  • .collapse.showcontenido nisqatam qawachin

Generalmente, huk ñit'inata data-bs-targetatributowan llamk'achiyta yuyaychayku. Mana semántico qhawaymanta yuyaychasqa kaptinpas, huk t'inkitapas llamk'achiy atikunki hrefatributowan (hinallataq huk role="button"). Iskayninpipas, chay data-bs-toggle="collapse"nisqa kamachisqa kachkan.

Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
html nisqapi
<p>
  <a class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
    Link with href
  </a>
  <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
    Button with data-bs-target
  </button>
</p>
<div class="collapse" id="collapseExample">
  <div class="card card-body">
    Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
  </div>
</div>

Kinranpa

Urmachiy pluginpas horizontal urmachiyta yanapan. Yanapakuq .collapse-horizontalclaseta yapay chaymanta tikraypaq widthchaymanta heightchuray widthchaymanta chaylla wawa elemento kaqpi. Ama hina kaspa kikiyki ruwasqa Sass qillqanaykipaq, chiru ukhupi estilokuna llamk'achiy, utaq ancho yanapakuyniyku llamk'achiy .

Ama hina kaspa, kay urapi kaq rikch'ana huk min-heighthuñuyuq kaptinpas, docsniykupi mana llumpay musuqmanta pinturakuna kananpaq, kayqa manam sut'imantachu mañasqa. Wawapi kaq widthelementollatam mañakun.

This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.
html nisqapi
<p>
  <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseWidthExample" aria-expanded="false" aria-controls="collapseWidthExample">
    Toggle width collapse
  </button>
</p>
<div style="min-height: 120px;">
  <div class="collapse collapse-horizontal" id="collapseWidthExample">
    <div class="card card-body" style="width: 300px;">
      This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.
    </div>
  </div>
</div>

Achka metakuna

A <button>icha <a>achka elementokunata rikuchiyta, pakayta atin, shuk akllakwan paypak hreficha data-bs-targetatributo nishkapi rikuchishpa. Achka <button>utaq <a>huk elementota rikuchiyta chaymanta pakayta atin sichus sapankanku paykunap hrefutaq data-bs-targetatributowan referencianku

Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
html nisqapi
<p>
  <a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
  <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
  <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
</p>
<div class="row">
  <div class="col">
    <div class="collapse multi-collapse" id="multiCollapseExample1">
      <div class="card card-body">
        Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
      </div>
    </div>
  </div>
  <div class="col">
    <div class="collapse multi-collapse" id="multiCollapseExample2">
      <div class="card card-body">
        Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
      </div>
    </div>
  </div>
</div>

Accesibilidad nisqa

aria-expandedAswan allinta qhaway elemento de control nisqaman yapayta . Kay atributo explícitamente kunan estadota elemento colapsible controlman watasqa pantalla ñawiriqkunaman chaymanta rikch'aq yanapakuy tecnologiakunaman apachin. Sichus t'inkisqa elemento ñawpaqmanta wichq'asqa kachkan, kamachiy elementopi atributo chaniyuq kanan tiyan aria-expanded="false". Sichus t'inkisqa elementota kichasqa kananpaq churarqanki ñawpaqmanta showclase kaqwan, aria-expanded="true"kamachiypi churay chaymanta ranti. Plugin kikinmanta kay atributota kamachiypi tikranqa sichus utaq mana llañu elemento kichasqa utaq wichqasqa (JavaScript kaqninta, utaq imaraykuchus llamk'achiq huk kamachiy elementota llamk'achirqa chaymanta kikin llañu elementoman watasqa). Sichus kamachiq elementopa HTML elementon mana huk ñit'inachu (kayhina, huk <a>icha <div>), layarole="button"chay elementoman yapakunan tiyan.

Sichus kamachiy elementoyki huk sapalla ñit'iy atikuq elementota maskachkan – chaymanta data-bs-targetatributo huk akllaqman rikuchichkan – atributota kamachiy elementoman idyapanayki tiyan , chaymanta chay de collapsible elemento kaqmanta. Kunan pantalla ñawiriqkuna chaymanta rikch'aq yanapakuy tecnologiakuna kay atributota llamk'achinku ruwaqkunaman yapa llalliq ñankuna qunankupaq chiqalla purinankupaq kikin elemento collapsible kaqman.aria-controlsid

Reparay Bootstrap kunan ruwaynin mana imaymana akllana teclado tinkiykuna ARIA Qillqana Ruwaykuna Guía acordeón patrón kaqpi willasqa llanthunchu - kaykunata qam kikiyki JavaScript ruwasqawan churanayki tiyan.

Sass

Variables nisqakuna

$transition-collapse:         height .35s ease;
$transition-collapse-width:   width .35s ease;

Clases

Collapse transición clasekuna tarikunman kaypi scss/_transitions.scsskaykuna achka componentekuna (collapse chaymanta acordeón) kaqpi rakisqa kasqankurayku.

.collapse {
  &:not(.show) {
    display: none;
  }
}

.collapsing {
  height: 0;
  overflow: hidden;
  @include transition($transition-collapse);

  &.collapse-horizontal {
    width: 0;
    height: auto;
    @include transition($transition-collapse-width);
  }
}

Uso

Urmachiy plugin huk pisi clasekunata llamk'achin llasa hoqariyta llamk'achinapaq:

  • .collapsechaypi kaqta pakaykun
  • .collapse.showchaypi kaqta rikuchin
  • .collapsingtikray qallariptin yapasqa, tukuptintaq hurqusqa

Kay clasekunataqa tarinki _transitions.scss.

Atributos de datos nisqawan

Yanapakuylla data-bs-toggle="collapse"chaymanta huk data-bs-targetelementoman kikillanmanta huk utaq achka elementokuna collapsiblekuna kamachiyta churanapaq. Atributo data-bs-targethuk CSS akllanata chaskikun chayman urmachiyta churanapaq. Aswan allinta yapay chay claseta collapsechay elemento collapsible nisqaman. Sichus ñawpaqmanta kichasqa kananta munanki, yapasqa claseta yapay show.

Acordeón hina huñu kamachiyta huk p'istuy kitiman yapanaykipaq, willay laya yapay data-bs-parent="#selector". Astawan yachanaykipaq qhaway acordeón nisqa p’anqata .

JavaScript nisqawan

Makiwan atichiy kaykunawan:

const collapseElementList = document.querySelectorAll('.collapse')
const collapseList = [...collapseElementList].map(collapseEl => new bootstrap.Collapse(collapseEl))

Akllanakuna

Imaynachus akllanakuna willay layakuna utaq JavaScript kaqninta pasayta atikun, huk akllana sutita yapayta atikunki kayman data-bs-, imaynachus data-bs-animation="{value}". Aseguray akllana sutimanta caso laya “ camelCase ” kaqmanta “ kebab-case ” kaqman tikrayta mayk’aq akllanakunata atributos de datos kaqninta pasaspa. Ejemplopaq data-bs-custom-class="beautifier", data-bs-customClass="beautifier".

Bootstrap 5.2.0 kaqmanta, llapa componentakuna huk experimental waqaychasqa willay laya yanapakuyta yanapakunku data-bs-configmayqinchus JSON watiqa hina sanu componente ruwayta wasichayta atin. Huk elemento data-bs-config='{"delay":0, "title":123}'chaymanta data-bs-title="456"layakunayuq kaqtin, qhipa titlechanin kanqa 456chaymanta sapaq willay layakuna qusqa chanikunata llallichinqa data-bs-config. Chaymanta, kunan kaq willay layakuna JSON chanikunata wasichayta atinku kayhina data-bs-delay='{"show":0,"hide":150}'.

Suti Niraq Ñawpaqchasqa Willay
parent akllaq, DOM nisqa elemento null Sichus tayta mama qusqa, chaymanta llapa t'inkisqa elementokuna nisqa tayta mamap urapi wichq'asqa kanqa mayk'aq kay t'inkisqa imayay rikuchisqa. card(ñawpamanta pacha acordeón ruwayman rikch'akuq - kayqa clasemanta dependen ). Atributoqa churasqa kanan tiyan chay meta collapsible nisqapi.
toggle boolean nisqa true Invocacionpi colapsible elementota tikran.

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 .

Contenidoykita huk elemento collapsible hina activan. Huk akllana akllanakunata chaskikun object.

Ruraqwan huk urmachiy instanciata ruwayta atinki, ahinataq:

const bsCollapse = new bootstrap.Collapse('#myCollapse', {
  toggle: false
})
Imayna Willay
dispose Huk elementopa urmayninta chinkachin. (DOM elementopi waqaychasqa willayta hurqun)
getInstance Método estático mayqinchus huk DOM elementowan tinkisqa instanciata urmachiyta jap'iyta atikun, kayhinata llamk'achiy atikunki: bootstrap.Collapse.getInstance(element).
getOrCreateInstance Método estático mayqinchus huk DOM elementowan tinkisqa llalliy instanciata kutichin utaq musuq ruwan mana qallarisqa kaqtin. Chaytaqa kayhinatam servichikuwaq: bootstrap.Collapse.getOrCreateInstance(element).
hide Huk llalliq elementota pakan. Llamaqman kutimun manaraq t'uqyakuq elemento chiqamanta pakasqa kachkaptin (kayhina, manaraq hidden.bs.collapseruway ruwakuchkaptin).
show Huk llalliq elementota rikuchin. Llamaqman kutimun manaraq t'inkisqa elemento chiqamanta rikuchisqa kachkaptin (kayhina, manaraq shown.bs.collapseruway ruwakuchkaptin).
toggle Huk ñit'isqa elementota rikuchisqaman icha pakasqaman tikran. Llamaqman kutimun manaraq llalliq elemento chiqamanta rikuchisqa utaq pakasqa kachkaptin (icha manaraq shown.bs.collapseutaq hidden.bs.collapseruway ruwakuchkaptin).

Eventos nisqakuna

Bootstrap kaqpa urmachiy clase huk pisi ruwaykunata riqsichin urmachiy ruwanaman enganche kaqpaq.

Tipo de evento Willay
hide.bs.collapse Kay ruwayqa chaylla llamk'achisqa kachkan mayk'aqchus hidemétodo waqyasqa kachkan.
hidden.bs.collapse Kay ruwayqa llamk'achiqmanta huk urmachiy elemento pakasqa kaptin llamk'achisqa (CSS tikraykunata tukunanta suyanqa).
show.bs.collapse Kay ruwayqa chaylla rawrarin mayk'aq showinstancia método waqyasqa.
shown.bs.collapse Kay ruwayqa llamk'achisqa huk urmachiy elemento ruwaqman rikukuq ruwasqa kaqtin (CSS tikraykunata tukunanta suyanqa).
const myCollapsible = document.getElementById('myCollapsible')
myCollapsible.addEventListener('hidden.bs.collapse', event => {
  // do something...
})