in English

Collapse

Toggle the visibility of content across your project with a few classes and our JavaScript plugins.

Quomodo facitur

In ruina JavaScript plugin demonstrare et abscondere contentus adhibetur. Bullae vel ancorae adhibentur ut triggers quae provisa sunt ad elementa specifica quae te toggle. heightCollapsa elementum a currente ad valorem animabit 0. paddingDatum quomodo CSS animationes tractat, in .collapseelemento uti non potes . Sed classe utere ut elementum involuti independenter.

Effectus animationis huius componentis dependet ex prefers-reduced-motioninterrogatione instrumentorum. Videre motum sectionem accessibilitatis nostrae documentationis reductam .

Exemplum

Preme tesserae infra monstrant et celant aliud elementum per mutationes ordinis:

  • .collapsecelat content
  • .collapsingapplicatur in transitus
  • .collapse.showostendit content

In universum commendamus utendo puga cum data-targetattributo. Cum ex semantica sententia non commendatur, nexum cum hrefattributo (et a role="button") uti potes. Utroque, opus data-toggle="collapse"est.

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

Horizontal

Plugin ruinae etiam ruinam horizontalem sustinet. Adde quod .widthdeterminatum genus ad transitum widthpro heightet pone widthin immediato infantis elemento. Libenter sentias scribere propriam consuetudinem Sass, stylis lineis utere, vel amplitudine nostra utere utilitates .

Nota quaeso quod exemplum infra min-heightstatutum est ad vitandum nimiam repa- menta nostra, hoc expresse non requiritur. Vestibulum elementum gravida nisi in egestas .width

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

Multa scuta

A <button>vel <a>elementa multa monstrare et occultare possunt, ea referendo cum electore JQuery in suo hrefvel data-targetattributo. Multiplex <button>vel <a>demonstrare et abscondere elementum potest, si unumquemque referat cum suo hrefvel data-targetattributo

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.
<p>
  <a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
  <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
  <button class="btn btn-primary" type="button" data-toggle="collapse" data-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>

Accordion example

Utens charta componente, mores ruinae defaltae extendere potes ad concordiam creandam. Accordion stylum apte assequi, fac uti .accordionpro fascia.

Quidam placeholder contentum tabulae primae tabs. Haec decuria ostenditur per defaltam, propter .showclassium.

Some placeholder content for the second accordion panel. This panel is hidden by default.

And lastly, the placeholder content for the third and final accordion panel. This panel is hidden by default.
<div class="accordion" id="accordionExample">
  <div class="card">
    <div class="card-header" id="headingOne">
      <h2 class="mb-0">
        <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </button>
      </h2>
    </div>

    <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
      <div class="card-body">
        Some placeholder content for the first accordion panel. This panel is shown by default, thanks to the <code>.show</code> class.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" id="headingTwo">
      <h2 class="mb-0">
        <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
          Collapsible Group Item #2
        </button>
      </h2>
    </div>
    <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
      <div class="card-body">
        Some placeholder content for the second accordion panel. This panel is hidden by default.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" id="headingThree">
      <h2 class="mb-0">
        <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
          Collapsible Group Item #3
        </button>
      </h2>
    </div>
    <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample">
      <div class="card-body">
        And lastly, the placeholder content for the third and final accordion panel. This panel is hidden by default.
      </div>
    </div>
  </div>
</div>

Accessibility

Vide ut aria-expandedelementum ad imperium addere. Hoc attributum explicite significat praesentem statum collapsibilis elementi ligatum ad potestatem legentium protegendi et similes technologias adiuvandas. Si elementum collapsibile clauditur per defaltam, attributum in elementi potestate valorem habere debet aria-expanded="false". Si elementum collapsibile posueris ut pateat per defaltam utens showclassium, aria-expanded="true"in dicione pones. Plugin sponte toggle hoc attributum in potestate fundatur utrum elementum collapsibile vel non apertum vel clausum (per JavaScript, vel quia utens utitur alia potestate elementi etiam ad idem collapsibile elementum ligatum). Si elementum HTML elementi potestate non est felis (exempli gratia, an <a>vel <div>) attributumrole="button"addatur elemento.

Si elementum imperium tuum unum elementum collapsibile oppugnat - id est data-targetattributum designat idelectoris - attributum debetis elementi temperantiae, elementi collapsibilis aria-controlscontinentis . idLectores screen moderni et similes technologiae adiuvantes hoc attributo utuntur ut usores cum brevibus additis praebeant ut directe navigant ad elementum ipsum collapsibile.

Nota quod Bootstrap exsecutio currentis non operit varias interationes claviaturas descriptas in ARIA Authoring Practices dux accordion exemplar - has te includere cum usu JavaScript.

Consuetudinem

In ruina plugin paucae classes adhibet ad tractandum elevatio gravis;

  • .collapsecelat contentus
  • .collapse.showostendit contentus
  • .collapsingadditur quando transitus incipit, et quando finitur removetur

Hae classes reperiuntur in _transitions.scss.

Via data attributa

Adde data-toggle="collapse"modo et data-targetelemento ut statim imperium unius vel plurium elementorum collabentium assignet. Attributum data-targetCSS electrix acceptat ut ruinam adhiberet. Adde genus collapseelementi collapsibili. Si vis aperta defaltam facere, additamentum classis adde show.

Accordion-similes coetus administrationem addere aream collapsibilem, data attributum addere data-parent="#selector". Hoc in actione refer ad demo.

Via JavaScript

Admitte cum manually:

$('.collapse').collapse()

Optiones

Optiones transigi possunt per data attributa vel JavaScript. Data enim attributa, adiungunt optionis nomen data-, ut in data-parent="".

Nomen Type Default Descriptio
parent selector | jQuery object | dom elementum falsus Si parens provideatur, omnia elementa collapsibilia sub parente praefinito claudentur, cum haec collapsibilis item demonstratur. (similis morum accordion traditio - hoc genus dependet card). Attributum in area scopo collapsibile apponendum est.
toggle Boolean verum Toggles collapsible elementum in invocatione

Methodi

Modi asynchronous et transitus

Omnes API modi asynchroni sunt et transitus committitur . Redeunt ad RECENS mox ut transitus incipiat sed antequam finiatur . Methodus praeterea in transitus transeuntis ignorabitur .

See our JavaScript documentation for more information .

.collapse(options)

Contentum actuat tuum ut collapsibile elementum. Acceptat optiones libitum object.

$('#myCollapsible').collapse({
  toggle: false
})

.collapse('toggle')

Toggles collapsibile elementum est ut vel absconditum ostendatur. RECENS, antequam elementum collapsibile redit, actu ostensum est vel absconditum (id est ante eventum shown.bs.collapsevel hidden.bs.collapseeventum).

.collapse('show')

Elementum collapsibile ostendit. RECENS redit ad elementum collapsibile antequam actu ostensum est (id est antequam shown.bs.collapseevenit).

.collapse('hide')

Cras lacinia elementum consequat. Recurrit ad RECENS antequam elementum collapsibile actu absconditum (id est antequam hidden.bs.collapseevenit).

.collapse('dispose')

Destruit elementum ruina.

Events

Classis ruina Bootstrap paucas eventus exponit pro hamo in ruina functionis.

Event Type Descriptio
show.bs.collapse Huius rei accendit statim cum showinstantia methodus appellatur.
shown.bs.collapse Eventus hic accensus est cum elementum ruinae usoris manifestatum est (exspectabit CSS transitus ad perficiendum).
hide.bs.collapse Ea res statim cum hidemodus vocatus est accenditur.
hidden.bs.collapse Eventus hic accensus est cum elementum ruinae ab utentis absconditum est (exspectabit CSS transitus ad perficiendum).
$('#myCollapsible').on('hidden.bs.collapse', function () {
  // do something...
})