Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.1: Add .dropdown-item-text #22965

Merged
merged 6 commits into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 62 additions & 33 deletions docs/4.0/components/dropdowns.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ However, Bootstrap does add built-in support for most standard keyboard menu int

Wrap the dropdown's toggle (your button or link) and the dropdown menu within `.dropdown`, or another element that declares `position: relative;`. Dropdowns can be triggered from `<a>` or `<button>` elements to better fit your potential needs.

### Single button dropdowns
### Single button

Any single `.btn` can be turned into a dropdown toggle with some markup changes. Here's how you can put them to work with either `<button>` elements:

Expand Down Expand Up @@ -140,7 +140,7 @@ The best part is you can do this with any button variant, too:
</div>
{% endhighlight %}

### Split button dropdowns
### Split button

Similarly, create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of `.dropdown-toggle-split` for proper spacing around the dropdown caret.

Expand Down Expand Up @@ -349,7 +349,9 @@ Button dropdowns work with buttons of all sizes, including default and split dro
</div>
{% endhighlight %}

## Dropup variation
## Directions

### Dropup

Trigger dropdown menus above elements by adding `.dropup` to the parent element.

Expand Down Expand Up @@ -409,7 +411,7 @@ Trigger dropdown menus above elements by adding `.dropup` to the parent element.
</div>
{% endhighlight %}

## Dropright variation
### Dropright

Trigger dropdown menus at the right of the elements by adding `.dropright` to the parent element.

Expand Down Expand Up @@ -469,7 +471,7 @@ Trigger dropdown menus at the right of the elements by adding `.dropright` to th
</div>
{% endhighlight %}

## Dropleft variation
### Dropleft

Trigger dropdown menus at the left of the elements by adding `.dropleft` to the parent element.

Expand Down Expand Up @@ -533,7 +535,6 @@ Trigger dropdown menus at the left of the elements by adding `.dropleft` to the
</div>
{% endhighlight %}


## Menu items

Historically dropdown menu contents *had* to be links, but that's no longer the case with v4. Now you can optionally use `<button>` elements in your dropdowns instead of just `<a>`s.
Expand All @@ -551,6 +552,41 @@ Historically dropdown menu contents *had* to be links, but that's no longer the
</div>
{% endexample %}

You can also create non-interactive dropdown items with `.dropdown-item-text`. Feel free to style further with custom CSS or text utilities.

{% example html %}
<div class="dropdown-menu">
<span class="dropdown-item-text">Dropdown item text</span>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
{% endexample %}

### Active

Add `.active` to items in the dropdown to **style them as active**.

{% example html %}
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Regular link</a>
<a class="dropdown-item active" href="#">Active link</a>
<a class="dropdown-item" href="#">Another link</a>
</div>
{% endexample %}

### Disabled

Add `.disabled` to items in the dropdown to **style them as disabled**.

{% example html %}
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Regular link</a>
<a class="dropdown-item disabled" href="#">Disabled link</a>
<a class="dropdown-item" href="#">Another link</a>
</div>
{% endexample %}

## Menu alignment

By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. Add `.dropdown-menu-right` to a `.dropdown-menu` to right align the dropdown menu.
Expand All @@ -572,7 +608,9 @@ By default, a dropdown menu is automatically positioned 100% from the top and al
</div>
{% endexample %}

## Menu headers
## Menu content

### Headers

Add a header to label sections of actions in any dropdown menu.

Expand All @@ -584,7 +622,7 @@ Add a header to label sections of actions in any dropdown menu.
</div>
{% endexample %}

## Menu dividers
### Dividers

Separate groups of related menu items with a divider.

Expand All @@ -598,7 +636,22 @@ Separate groups of related menu items with a divider.
</div>
{% endexample %}

## Menu forms
### Text

Place any freeform text within a dropdown menu with text and use [spacing utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/). Note that you'll likely need additional sizing styles to constrain the menu width.

{% example html %}
<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>
{% endexample %}

### Forms

Put a form within a dropdown menu, or make it into a dropdown menu, and use [margin or padding utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/) to give it the negative space you require.

Expand Down Expand Up @@ -647,30 +700,6 @@ Put a form within a dropdown menu, or make it into a dropdown menu, and use [mar
</form>
{% endexample %}

## Active menu items

Add `.active` to items in the dropdown to **style them as active**.

{% example html %}
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Regular link</a>
<a class="dropdown-item active" href="#">Active link</a>
<a class="dropdown-item" href="#">Another link</a>
</div>
{% endexample %}

## Disabled menu items

Add `.disabled` to items in the dropdown to **style them as disabled**.

{% example html %}
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Regular link</a>
<a class="dropdown-item disabled" href="#">Disabled link</a>
<a class="dropdown-item" href="#">Another link</a>
</div>
{% endexample %}

## Dropdown options

Use `data-offset` or `data-reference` to change the location of the dropdown.
Expand Down
7 changes: 7 additions & 0 deletions scss/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,10 @@
color: $dropdown-header-color;
white-space: nowrap; // as with > li > a
}

// Dropdown text
.dropdown-item-text {
display: block;
padding: $dropdown-item-padding-y $dropdown-item-padding-x;
color: $dropdown-link-color;
}