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

Urmachiykuna

Contextual llanthukunata tikray t'inkikuna listakuna rikuchinapaq chaymanta aswan Bootstrap urayk'aq plugin kaqwan.

Hatun qhawariy

Urmachiykuna tikranapaq kanku, contextual llanthukuna t'inkikuna listakuna rikuchinapaq chaymanta aswan. Paykunaqa ruwasqa kanku interactivo kaqwan chaymanta Bootstrap urayk'aq JavaScript plugin kaqwan. Paykunaqa ñit’ispa t’ikrakunku, manataq kuyurichispachu; kayqa huk decisión intencional de diseño nisqa .

Urmachiykuna huk kimsa kaq biblioteca kaqpi ruwasqa kanku, Popper , mayqinchus kallpasapa churayta chaymanta qhaway punku tariyta qun. Aswan allinta popper.min.js kaqmanta churay manaraq Bootstrap JavaScript kaqmanta utaq bootstrap.bundle.min.js/ llamk'achiy bootstrap.bundle.jsmayqinchus Popper kaqwan kachkan. Popper mana llamk'achkanchu urquykunata navbars kaqpi churanapaq ichaqa imaynachus dinamico churay mana mañasqachu.

Accesibilidad nisqa

WAI ARIA kamachiy huk chiqa widget kaqmanta riqsichin , ichaqa kayqa ruwana-hina menúkuna ruwanapaq específico kaq mayqinkunachus ruwaykunata utaq ruwanakunata llamk'achinku. ARIA menúkuna menú elementokuna, cuadro de comprobación menú elementokuna, radio botón menú elementokuna, radio botón qutukuna chaymanta huch'uy menúkunalla kanman.role="menu"

Bootstrap kaqpa uraykachiyninkuna, wak ladumanta, ruwasqa kanku genérico kanankupaq chaymanta imaymana situacionkunaman chaymanta marka estructurakunaman ruwanapaq. Ejemplopaq, atikunmi ruwayta urayk'aqkuna mayqinkunachus yapa yaykuykunayuq chaymanta formulario kamachiykunayuq, maskana pampakuna utaq yaykuy formulariokuna hina. Kayrayku, Bootstrap mana suyanchu (nitaq kikinmanta yapanchu) mayqin rolechaymanta aria-atributokuna chiqa ARIA menúkunapaq mañasqa. Qillqaqkuna kikinku kay aswan específico atributokunata churananku kanqa.

Ichaqa, Bootstrap ruwasqa yanapakuyta yapan aswan estándar teclado menú tinkiykuna kaqpaq, kayhina sapalla .dropdown-itemelementokuna kuyuy atiy kay cursor llavekuna llamk'achispa chaymanta menú ESCllavewan wichq'ay.

Ejemplos

Uraykaqpa tikrayninta (botonniyki utaq t'inkiyki) chaymanta urayk'aq menú ukhupi .dropdown, utaq huk elemento willaq position: relative;. Dropdowns kaqmanta <a>utaq <button>elementokunamanta llamk'achisqa kanman aswan allinta tupananpaq atikuq necesidadniykiman. Kaypi rikuchisqa rikch'anakuna <ul>maypichus allin kanman chaypi elementos semánticos nisqakunata llamk'achinku, ichaqa sapanchasqa markachay yanapasqa kachkan.

Huklla botón

Ima .btnsapallapas huk urayk'aq tikrayman tikray atikun wakin marka tikraykunawan. Kaypi imaynatachus mayqin <button>elementokunawanpas llamk'achiyta atinki:

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown button
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
    <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>

Y con <a>elementos:

<div class="dropdown">
  <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown link
  </a>

  <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
    <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>

Aswan allin kaqninqa kayta ruwayta atinki mayqin botón variante kaqwanpas, chaymanta:

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

Botón rakiy

Kikillantataq, rakisqa botón urayk'aqkunata ruway yaqa kikin markawan huklla botón urayk'aqkunawan, ichaqa yapasqawan .dropdown-toggle-splitallin espaciamientopaq urayk'aq caret muyuriqpi.

Kay yapasqa claseta llamk'achiyku horizontalta paddingiskaynin lado caret kaqpi 25% pisiyachinaykupaq chaymanta chaymanta chay margin-leftyapasqa sapa kuti botón urayk'achiqkunapaq hurquyku. Chay yapasqa tikraykunaqa caretta rakisqa botón kaqpi chawpichasqata waqaychanku chaymanta huk aswan allin sayayniyuq tupachiy áreata qun hatun botón kaqpa ladunpi.

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

Tamaño

Botón urayk'achiqkuna tukuy sayayniyuq botones kaqwan llamk'anku, ñawpaqmanta chaymanta rakisqa urayk'aq botones kaqwan.

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

Tutayaq urmaykuna

Aswan yana urayk'aqkunaman akllay huk yana navbar utaq sapanchasqa estilowan tupanaykipaq .dropdown-menu-darkhuk kachkaq kaqman yapaspa .dropdown-menu. Mana ima tikraypas kanchu urayk'aq kaqkunapi.

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown button
  </button>
  <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="dropdownMenuButton2">
    <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>

Y ponerlo para usar en una navbar:

<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="#" id="navbarDarkDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Dropdown
          </a>
          <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="navbarDarkDropdownMenuLink">
            <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>

Direcciones

RTL nisqa

Direcciones espejo kaqpi kanku mayk'aq Bootstrap RTL kaqpi llamk'achkan, niyta munan .dropstartpaña ladopi rikukunqa.

Dropup

Tayta elementoman yapaspa elementokuna hawapi urayk'aq menúkunata .dropupllamk'achiy.

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

Derecho de gota

Tayta elementoman yapaspa elementokunap paña larunpi urayk'aq menúkunata llamk'achiy .dropend.

<!-- Default dropend button -->
<div class="btn-group dropend">
  <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
    Dropright
  </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 Dropright</span>
  </button>
  <ul class="dropdown-menu">
    <!-- Dropdown menu links -->
  </ul>
</div>

Gota

Tayta elementoman yapaspa elementokunap lluq'inpi urayk'aq menúkunata llamk'achiy .dropstart.

<!-- 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">
  <div class="btn-group dropstart" role="group">
    <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>
  </div>
  <button type="button" class="btn btn-secondary">
    Split dropstart
  </button>
</div>

<a>O <button>elementokunata urayk'achiq hina llamk'achiyta atinki .

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
    <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>

Mana tinkisqa urayk'achiqkunatapas ruwayta atinki .dropdown-item-text. Mana manchakuspa aswan estilo ruwaypaq ruwasqa CSS utaq qillqa yanapakuykunawan.

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

Kawsaq

.activeUraykachiypi kaq imakunaman yapay ruwasqa hina estilochanaykipaq . Yanapakuq tecnologiakunaman ruwana estadota apachinaykipaq, aria-currentlaya llamk'achiy — pagekunan p'anqapaq chanin llamk'achispa, utaq truekunan kaq imapaq huk huñupi.

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

Wañuchisqa

Mana atisqa hina estilochanaykipaq.disabled urayk'achiqpi kaq imakunaman yapay .

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

Ñawpaqmanta, huk urayk'aq menú kikinmanta churasqa 100% patamanta chaymanta tayta-mamanpa paña ladonpi. Kayta direccional .drop*clasekunawan tikrayta atikunki, ichaqa huk tikraq clasekunawanpas kamachiyta atikunki.

Hukman yapay .dropdown-menu-endpañaman .dropdown-menuurayk’aq menú nisqapi chiqanchay. Direcciones espejo kaqpi kanku mayk'aq Bootstrap RTL kaqpi llamk'achkan, niyta munan .dropdown-menu-endpaña ladopi rikukunqa.

¡Umakuna wichayman! Dropdowns nisqakunaqa Popper nisqaman gracias nispa churasqa kanku salvo huk navbar nisqapi kaptinku.
<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>

Alineación respuesta

Sichus kutichiq chiqanchayta llamk'achiyta munanki, mana llamk'achiy dinámico churayta atributota yapaspa data-bs-display="static"chaymanta kutichiq variación clasekunata llamk'achiy.

Pañaman urayk'aq menúta qusqa rakiywan utaq aswan hatunwan tupachinaykipaq, yapay.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>

Lluq'i urayk'aq menú qusqa rakiywan utaq aswan hatunwan chiqanchanaykipaq, yapay .dropdown-menu-endchaymanta .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>

Reparay mana huk data-bs-display="static"atributota yapanaykichu tiyan navbars kaqpi urayk'aq ñit'inakunaman, Popper mana navbars kaqpi llamk'achisqa kasqanrayku.

Akllanakuna alineación

Yaqa llapan akllanakuna hawapi rikuchisqa hapispa, kaypi huk uchuy cocina lavabo demo imaymana urayk'aq alineación akllanakuna huk kitipi.

<div class="btn-group">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    <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>

Umakuna

Ima urayk'aq menú kaqpipas ruwanakuna t'aqakunata etiquetananpaq huk umalliqta yapay.

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

Rakiqkuna

Huk rakiqwan tupaq menú nisqapi kaq huñukunata t'aqay.

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

Qillqa

Ima mana qullqiyuq qillqatapas huk urayk'aq menú ukhupi qillqawan churay chaymanta espaciamiento yanapakuykunata llamk'achiy . Reparay, yaqapaschá huk hatun sayay estilokunata necesitanki menú anchota hark'anaykipaq.

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

Formas

Huk formulariota huk urayk'aq menú ukhupi churay, utaq huk urayk'aq menú kaqman ruway, chaymanta margen utaq relleno yanapakuykunata llamk'achiy mana allin espaciota qunaykipaq munasqaykita.

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

Chayta servichikuy data-bs-offsetmaypi data-bs-referencekasqanmanta cambianaykipaq.

<div class="d-flex">
  <div class="dropdown me-1">
    <button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuOffset" data-bs-toggle="dropdown" aria-expanded="false" data-bs-offset="10,20">
      Offset
    </button>
    <ul class="dropdown-menu" aria-labelledby="dropdownMenuOffset">
      <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" id="dropdownMenuReference" data-bs-toggle="dropdown" aria-expanded="false" data-bs-reference="parent">
      <span class="visually-hidden">Toggle Dropdown</span>
    </button>
    <ul class="dropdown-menu" aria-labelledby="dropdownMenuReference">
      <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 wisq’ay ruway

Ñawpaqmanta, urayk'aq menú wichq'asqa kachkan urayk'aq menú ukhupi utaq hawapi ñit'ispa. Akllanata llamk'achiy atikunki autoClosekay urayk'aqpa ruwayninta tikranaykipaq.

<div class="btn-group">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="defaultDropdown" data-bs-toggle="dropdown" data-bs-auto-close="true" aria-expanded="false">
    Default dropdown
  </button>
  <ul class="dropdown-menu" aria-labelledby="defaultDropdown">
    <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" id="dropdownMenuClickableOutside" data-bs-toggle="dropdown" data-bs-auto-close="inside" aria-expanded="false">
    Clickable outside
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuClickableOutside">
    <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" id="dropdownMenuClickableInside" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
    Clickable inside
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuClickableInside">
    <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" id="dropdownMenuClickable" data-bs-toggle="dropdown" data-bs-auto-close="false" aria-expanded="false">
    Manual close
  </button>
  <ul class="dropdown-menu" aria-labelledby="dropdownMenuClickable">
    <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>

Sass

Variables nisqakuna

Llapan urayk'achiqkunapaq tikrakuqkuna:

$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:             rgba($black, .15);
$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:           $dropdown-padding-y $dropdown-item-padding-x;

Tutayaq urayk'aqpaq variables :

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

CSS-pi ruwasqa carets kaqpaq tikraqkuna mayqinkunachus huk urayk'aqpa interactividadninta rikuchinku:

$caret-width:                 .3em;
$caret-vertical-align:        $caret-width * .85;
$caret-spacing:               $caret-width * .85;

Mixinkuna

Mixinkuna CSS-manta ruwasqa caretkuna ruwanapaq llamk'achisqa kanku chaymanta kaypi tarikunman 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;
    }
  }
}

Uso

Willay atributokuna utaq JavaScript kaqnintakama, urayk'aq plugin pakasqa willayta (urquq menúkuna) tikran .showtayta kaqpi claseta tikraspa .dropdown-menu. Atributo data-bs-toggle="dropdown"huk ruwana patapi urayk'aq menúkuna wichq'anapaq hapipakun, chayrayku allin yuyay sapa kuti llamk'achinapaq.

Llachpanapaq atichisqa dispositivokunapi, huk urayk'achiq kichayqa ch'usaq hapiqkunata elementopa mouseoverchaylla wawankunaman yapan. <body>Kay admitisqa millay hack necesario llamk'anapaq muyuriqpi huk quirk kaqpi iOS' evento delegación , mayqinchus wakhina hark'anman huk grifo maypipas hawa urayk'aqmanta kay código llamk'achiyta chaymanta chay urayk'ayta wichq'an. Huk kuti urayk'achiq wichq'asqa kaqtin, kay yapasqa ch'usaq mouseoverhap'iqkuna hurqusqa kanku.

Atributos de datos nisqawan

data-bs-toggle="dropdown"Huk t'inkiman utaq ñit'inaman yapay huk urayk'achiqta tikranaykipaq.

<div class="dropdown">
  <button id="dLabel" type="button" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown trigger
  </button>
  <ul class="dropdown-menu" aria-labelledby="dLabel">
    ...
  </ul>
</div>

JavaScript nisqawan

JavaScript nisqawan urayk'achiqkunata waqyay:

var dropdownElementList = [].slice.call(document.querySelectorAll('.dropdown-toggle'))
var dropdownList = dropdownElementList.map(function (dropdownToggleEl) {
  return new bootstrap.Dropdown(dropdownToggleEl)
})
data-bs-toggle="dropdown"kunankamapas mañasqaraqmi kachkan

Imayna kaptinpas sichus JavaScript kaqnintakama urayk'achisqayki waqyanki utaq aswanpas data-api kaqwan llamk'achkanki, data-bs-toggle="dropdown"sapa kuti urayk'aqpa elemento desencadenante kaqpi kanan tiyan.

Akllanakuna

Akllanakuna willay layakuna utaq JavaScript kaqnintakama pasayta atikun. Willayta layakunapaq, akllana sutita yapay data-bs-, imaynachus data-bs-offset="". Aswan allinta qhaway akllana sutipa caso laya camelCase kaqmanta kebab-case kaqman tikrayta mayk'aq akllanakunata willay atributokuna kaqninta pasanki. Ejemplopaq data-bs-autoClose="false", utilizanaykimantaqa data-bs-auto-close="false".

Suti Niraq Ñawpaqchasqa Willay
boundary q'aytu | imakuna 'clippingParents' Uraykaq menúpa desbordamiento hark'ay linderon (Popperpa preventOverflow tikraqninmanlla ruwakun). Ñawpaqmanta 'clippingParents'huk HTMLElement willayta chaskiyta atin chaymanta (JavaScript kaqlla kaqnintakama). Aswan willakuypaq qhaway Popperpa detectOverflow docs .
reference q'aytu | elemento | ima 'toggle' Elemento de referencia del menú desplegable nisqamanta. 'toggle', 'parent', huk HTMLElement riqsichiy utaq huk quq imayaypa chanikunata chaskikun getBoundingClientRect. Aswan willakuypaq qhaway Popperpa ruwaq qillqakuna chaymanta virtual elemento qillqakuna .
display qaytu 'dynamic' Ñawpaqmanta, Popper llamk'achiyku dinamico churaypaq. Kayta mana llamk'achiychu static.
offset matriz | q'aytu | ruway [0, 2]

Desplazamiento de la desplegable relativo a su meta. Huk watiqata willay layakunapi chikuwan t'aqasqa chanikunawan kayhinata pasayta atinki:data-bs-offset="10,20"

Huk llamk'ayta offset nisqa riqsinapaq llamk'achisqa kaqtinqa, huk imayaywanmi waqyakun, chaypiqa popper churana, referencia, popper rects nisqakuna ñawpaq argumenton hina. Chay elemento desencadenante DOM nodo iskay kaq argumento hina pasakun. Rurayqa iskay yupayniyuq matriztam kutichinan: .[skidding, distance]

Aswan willakuypaq qhaway Popperpa offset docs .

autoClose boolean nisqa | qaytu true

Urmachiypa kikin wichq'ana ruwayninta wakichiy:

  • true- uraykachiyqa wisq’asqa kanqa hawapi utaq urayk’aq menú ukhupi ñit’ispa.
  • false- chay urayk'aq wichq'asqa kanqa ñit'ispa chaymanta makiwan waqyaspa hideutaq togglemétodo. (También no se cerrará con presionando esctecla)
  • 'inside'- urayk'achiq wichq'asqa kanqa (sapallan) urayk'aq menú ukhupi ñit'ispa.
  • 'outside'- urayk'achiq wichq'asqa kanqa (sapallan) urayk'aq menú hawapi ñit'ispa.
popperConfig nullq | objeto | ruway null

Bootstrap kaqpa ñawpaqmanta Popper wakichiyninta tikranaykipaq, qhaway Popperpa wakichiyninta .

Huk ruwana Popper ruwana ruwanapaq llamk'achisqa kaqtin, huk imayaywan waqyasqa mayqinchus Bootstrap ñawpaqmanta Popper ruwanayuq kachkan. Yanapasunki llamk'achiyta chaymanta hukllanapaq ñawpaqmanta ruwasqa kikin ruwanaykiwan. Ruwayqa Popperpaq huk wakichiy imayayta kutichinan tiyan.

Utilizar función conpopperConfig

var dropdown = new bootstrap.Dropdown(element, {
  popperConfig: function (defaultBsPopperConfig) {
    // var newPopperConfig = {...}
    // use defaultBsPopperConfig if needed...
    // return newPopperConfig
  }
})

Métodos

Imayna Willay
toggle Huk qusqa navbar utaq tablayuq puriypa urayk'aq menú kaqninta tikran.
show Huk qusqa navbar utaq tablayuq puriypa urayk'aq menú kaqninta rikuchin.
hide Huk qusqa navbar utaq tablayuq puriypa urayk'aq menú kaqninta pakan.
update Huk elementopa urayk'achiqpa maypi kayninta musuqchan.
dispose Huk elementopa uraykamuyninta chinkachin. (DOM elementopi waqaychasqa willayta hurqun)
getInstance Método estático mayqinchus huk DOM elementowan tinkisqa instancia desplegable kaqmanta jap'iyta atikun, kayhinata llamk'achiy atikunki:bootstrap.Dropdown.getInstance(element)
getOrCreateInstance Método estático mayqinchus huk DOM elementowan tinkisqa huk urayk'aq instanciata kutichin utaq musuq ruwan mana qallarisqa kaqtin. Chaytaqa kayhinatam servichikuwaq:bootstrap.Dropdown.getOrCreateInstance(element)

Eventos nisqakuna

Llapan urayk'aq ruwaykuna elemento toggling kaqpi disparasqa chaymanta burbujasqa. Chaymi chaymanta yapayta atikunki suceso uyariqkunata chaymanta .dropdown-menu's tayta elemento kaqpi. hide.bs.dropdownchaymanta hidden.bs.dropdownruwaykuna huk clickEventpropiedadniyuq kanku (ñawpaq Sucedimiento laya kaqtinlla click) chaymanta huk Sucedimiento Objeto ñit'iy ruwaypaq hap'in.

Imayna Willay
show.bs.dropdown Chaylla rawrarin mayk'aq rikuchiy instancia método waqyasqa.
shown.bs.dropdown Llamk'achisqa mayk'aq urayk'achiq ruwaqman rikukuq ruwasqa chaymanta CSS tikraykuna tukusqa.
hide.bs.dropdown Paka instancia ñan waqyasqa kaptin chaylla rawrarin.
hidden.bs.dropdown Llamk'achisqa mayk'aq urayk'achiq llamk'achiqmanta pakasqa kayta tukusqa chaymanta CSS tikraykuna tukusqa.
var myDropdown = document.getElementById('myDropdown')
myDropdown.addEventListener('show.bs.dropdown', function () {
  // do something...
})