Dropdown

Pack name: seed-dropdown

Dropdown component pack for Seed

Contents

Install

npm install seed-dropdown --save

Dependencies


Bootstrap

Javascript

This component’s interactions are powered by Bootstrap. Refer to their dropdown documentation for Javascript usage.

CSS

This component does not require any of Bootstrap’s CSS for style. In fact, it is recommended that Bootstrap’s CSS are omitted for seed-dropdown to be styled properly.

Class names

In the markup examples (below), you will notice that for certain components there is a mixture of seed class names and Bootstrap class names. In order for dropdown’s to work properly, Bootstrap’s Javascript requires certain elements to have certain class names. seed-dropdown does not use any of these classes for styling.


Example

<div class="c-dropdown dropdown">
  <button class="c-button c-dropdown__toggle dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown button
  </button>
  <div class="c-card c-dropdown__menu c-dropdown__menu--truncate dropdown-menu" aria-labelledby="dropdownMenuButton">
    <div class="c-list">
      <a class="c-list__item dropdown-item" href="#">Action</a>
      <a class="c-list__item dropdown-item" href="#">Another action</a>
      <a class="c-list__item dropdown-item disabled" href="#">Something else here</a>
    </div>
  </div>
</div>

Headers and Dividers

<div class="c-dropdown dropdown">
  <button class="c-button c-dropdown__toggle dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown button
  </button>
  <div class="c-card c-dropdown__menu c-dropdown__menu--truncate dropdown-menu" aria-labelledby="dropdownMenuButton">
    <div class="c-list">
      <h5 class="c-dropdown__header">Dropdown header</h5>
      <a class="c-list__item dropdown-item" href="#">Action</a>
      <a class="c-list__item dropdown-item" href="#">Another action</a>
      <a class="c-list__item dropdown-item disabled" href="#">Something else here</a>
    </div>
    <div class="c-list">
      <h5 class="c-dropdown__header">Another header</h5>
      <a class="c-list__item dropdown-item" href="#">Action</a>
    </div>
  </div>
</div>

Directions

The dropdown menu’s direction can be modified by adding directional based modifications to .c-dropdown.

All of the following classes support responsive modifiers.

Class Dropdown direction
c-dropdown--up up
c-dropdown--down down
c-dropdown--left left
c-dropdown--right right

The following dropdown menu drops up and is positioned to the right.

<div class="c-dropdown c-dropdown--up c-dropdown--right dropdown">
  <button class="c-button c-dropdown__toggle dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown button
  </button>
  <div class="c-card c-dropdown__menu c-dropdown__menu--truncate dropdown-menu" aria-labelledby="dropdownMenuButton">
    <div class="c-list">
      <a class="c-list__item dropdown-item" href="#">Action</a>
    </div>
  </div>
</div>

Sizes

seed-dropdown uses seed-button as its dropdown toggle.

See seed-button’s size documentation for more details on sizes.

<div class="c-dropdown dropdown">
  <button class="c-button c-button--sm c-dropdown__toggle dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Small dropdown button
  </button>
  <div class="c-card c-dropdown__menu c-dropdown__menu--truncate dropdown-menu" aria-labelledby="dropdownMenuButton">
    <div class="c-list">
      <a class="c-list__item dropdown-item" href="#">Action</a>
    </div>
  </div>
</div>

States

seed-dropdown uses seed-button as its dropdown toggle.

See seed-button’s state documentation for more details on states.

<div class="c-dropdown dropdown">
  <button class="c-button is-success c-dropdown__toggle dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Success dropdown
  </button>
  <div class="c-card c-dropdown__menu c-dropdown__menu--truncate dropdown-menu" aria-labelledby="dropdownMenuButton">
    <div class="c-list">
      <a class="c-list__item dropdown-item" href="#">Action</a>
    </div>
  </div>
</div>

Control groups

The borders of the seed-dropdown toggles will automatically adjust when placed inside of a seed-control-group.

<div class="o-control-group">
  <button class="c-button">
    Button
  </button>
  <div class="c-dropdown dropdown">
    <button class="c-button c-dropdown__toggle dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Dropdown
    </button>
    <div class="c-card c-dropdown__menu c-dropdown__menu--truncate dropdown-menu" aria-labelledby="dropdownMenuButton">
      <div class="c-list">
        <a class="c-list__item dropdown-item" href="#">Action</a>
      </div>
    </div>
  </div>
</div>