aboutsummaryrefslogtreecommitdiff
path: root/docs/4.0/components/dropdowns.md
diff options
context:
space:
mode:
authorlucascono <[email protected]>2017-10-04 05:33:17 -0300
committerlucascono <[email protected]>2017-10-04 05:33:17 -0300
commit8c04a74c8c7f0174ea08bc02fa3762f49bf615a3 (patch)
treedb9d6923c082243d765c57885992db8dd26a70b5 /docs/4.0/components/dropdowns.md
parent9aff890efa3798f831b714c41794c9fee0684bae (diff)
parentb29b1e155880ac953899889c9cbb67f7f7df0529 (diff)
downloadbootstrap-8c04a74c8c7f0174ea08bc02fa3762f49bf615a3.tar.xz
bootstrap-8c04a74c8c7f0174ea08bc02fa3762f49bf615a3.zip
Merge remote-tracking branch 'refs/remotes/twbs/v4-dev' into v4-dev
Diffstat (limited to 'docs/4.0/components/dropdowns.md')
-rw-r--r--docs/4.0/components/dropdowns.md71
1 files changed, 57 insertions, 14 deletions
diff --git a/docs/4.0/components/dropdowns.md b/docs/4.0/components/dropdowns.md
index 9170b7162..d38b410c7 100644
--- a/docs/4.0/components/dropdowns.md
+++ b/docs/4.0/components/dropdowns.md
@@ -10,7 +10,9 @@ toc: true
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown JavaScript plugin. They're toggled by clicking, not by hovering; this is [an intentional design decision.](http://markdotto.com/2012/02/27/bootstrap-explained-dropdowns/)
-Dropdowns are built on a third party library, [Popper.js](https://popper.js.org), which provides dynamic positioning and viewport detection. Be sure to include [popper.min.js](https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js) before Bootstrap's JavaScript.
+Dropdowns are built on a third party library, [Popper.js](https://popper.js.org/), which provides dynamic positioning and viewport detection. Be sure to include [popper.min.js]({{ site.cdn.popper }}) before Bootstrap's JavaScript or use `bootstrap.bundle.min.js` / `bootstrap.bundle.js` which contains Popper.js.
+
+If you're building our JS from source, it [requires `util.js`]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#util).
## Accessibility
@@ -314,7 +316,7 @@ Button dropdowns work with buttons of all sizes, including default and split dro
</div>
</div>
<div class="btn-group">
- <button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ <button class="btn btn-secondary btn-lg" type="button">
Large button
</button>
<button type="button" class="btn btn-lg btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@@ -335,7 +337,7 @@ Button dropdowns work with buttons of all sizes, including default and split dro
</div>
</div>
<div class="btn-group">
- <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ <button class="btn btn-secondary btn-sm" type="button">
Small button
</button>
<button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@@ -430,7 +432,7 @@ Historically dropdown menu contents *had* to be links, but that's no longer the
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.
{% callout info %}
-**Heads up!** Dropdowns are positioned only with CSS and may need some additional styles for exact alignment.
+**Heads up!** Dropdowns are positioned thanks to Popper.js (except when they are contained in a navbar).
{% endcallout %}
{% example html %}
@@ -472,6 +474,55 @@ Separate groups of related menu items with a divider.
</div>
{% endexample %}
+## Menu 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.
+
+{% example html %}
+<div class="dropdown-menu">
+ <form class="px-4 py-3">
+ <div class="form-group">
+ <label for="exampleDropdownFormEmail1">Email address</label>
+ <input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="[email protected]">
+ </div>
+ <div class="form-group">
+ <label for="exampleDropdownFormPassword1">Password</label>
+ <input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
+ </div>
+ <div class="form-check">
+ <label class="form-check-label">
+ <input type="checkbox" class="form-check-input">
+ Remember me
+ </label>
+ </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>
+{% endexample %}
+
+{% example html %}
+<form class="dropdown-menu p-4">
+ <div class="form-group">
+ <label for="exampleDropdownFormEmail2">Email address</label>
+ <input type="email" class="form-control" id="exampleDropdownFormEmail2" placeholder="[email protected]">
+ </div>
+ <div class="form-group">
+ <label for="exampleDropdownFormPassword2">Password</label>
+ <input type="password" class="form-control" id="exampleDropdownFormPassword2" placeholder="Password">
+ </div>
+ <div class="form-check">
+ <label class="form-check-label">
+ <input type="checkbox" class="form-check-input">
+ Remember me
+ </label>
+ </div>
+ <button type="submit" class="btn btn-primary">Sign in</button>
+</form>
+{% endexample %}
+
## Disabled menu items
Add `.disabled` to items in the dropdown to **style them as disabled**.
@@ -523,7 +574,7 @@ Regardless of whether you call your dropdown via JavaScript or instead use the d
### Options
-Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-placement=""`.
+Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-offset=""`.
<table class="table table-bordered table-striped table-responsive">
<thead>
@@ -536,16 +587,8 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
</thead>
<tbody>
<tr>
- <td>placement</td>
- <td>string</td>
- <td>'bottom'</td>
- <td>
- <p>How to position the popover - top | bottom.</p>
- </td>
- </tr>
- <tr>
<td>offset</td>
- <td>number | string</td>
+ <td>number | string | function</td>
<td>0</td>
<td>Offset of the dropdown relative to its target. For more information refer to Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..offset.offset">offset docs</a>.</td>
</tr>