aboutsummaryrefslogtreecommitdiff
path: root/docs/components
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2017-04-21 23:36:24 -0700
committerMark Otto <[email protected]>2017-04-21 23:36:24 -0700
commit5463d8436b6404f5c647fb12e0cd0eafa4abf5e0 (patch)
treeada6f9b1f4990a182d829055ee079db9601dbf9b /docs/components
parent7efe4ddee499396efc40f53d1421b61fe5da328d (diff)
parent638b97f19c4df6f51475f8088555e3eefd2b986f (diff)
downloadbootstrap-5463d8436b6404f5c647fb12e0cd0eafa4abf5e0.tar.xz
bootstrap-5463d8436b6404f5c647fb12e0cd0eafa4abf5e0.zip
Merge branch 'v4-dev' into form-tweaks
Diffstat (limited to 'docs/components')
-rw-r--r--docs/components/button-group.md12
-rw-r--r--docs/components/carousel.md11
-rw-r--r--docs/components/collapse.md2
-rw-r--r--docs/components/dropdowns.md16
-rw-r--r--docs/components/input-group.md16
-rw-r--r--docs/components/navbar.md18
-rw-r--r--docs/components/navs.md10
7 files changed, 52 insertions, 33 deletions
diff --git a/docs/components/button-group.md b/docs/components/button-group.md
index 59a18e262..d2d5140ed 100644
--- a/docs/components/button-group.md
+++ b/docs/components/button-group.md
@@ -12,6 +12,14 @@ Group a series of buttons together on a single line with the button group. Add o
* Will be replaced with the ToC, excluding the "Contents" header
{:toc}
+{% callout warning %}
+## Ensure correct `role` and provide a label
+
+In order for assistive technologies (such as screen readers) to convey that a series of buttons is grouped, an appropriate `role` attribute needs to be provided. For button groups, this would be `role="group"`, while toolbars should have a `role="toolbar"`.
+
+In addition, groups and toolbars should be given an explicit label, as most assistive technologies will otherwise not announce them, despite the presence of the correct role attribute. In the examples provided here, we use `aria-label`, but alternatives such as `aria-labelledby` can also be used.
+{% endcallout %}
+
## Basic example
Wrap a series of buttons with `.btn` in `.btn-group`.
@@ -59,7 +67,7 @@ Feel free to mix input groups with button groups in your toolbars. Similar to th
</div>
<div class="input-group">
<span class="input-group-addon" id="btnGroupAddon">@</span>
- <input type="text" class="form-control" placeholder="Input group example" aria-describedby="btnGroupAddon">
+ <input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon">
</div>
</div>
@@ -72,7 +80,7 @@ Feel free to mix input groups with button groups in your toolbars. Similar to th
</div>
<div class="input-group">
<span class="input-group-addon" id="btnGroupAddon2">@</span>
- <input type="text" class="form-control" placeholder="Input group example" aria-describedby="btnGroupAddon2">
+ <input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon2">
</div>
</div>
{% endexample %}
diff --git a/docs/components/carousel.md b/docs/components/carousel.md
index e75484316..ab84bf460 100644
--- a/docs/components/carousel.md
+++ b/docs/components/carousel.md
@@ -28,7 +28,7 @@ Here's a carousel with slides only. Note the presence of the `.d-block` and `.im
{% example html %}
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
- <div class="carousel-inner" role="listbox">
+ <div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" data-src="holder.js/800x400?auto=yes&bg=777&fg=555&text=First slide" alt="First slide">
</div>
@@ -48,7 +48,7 @@ Adding in the previous and next controls:
{% example html %}
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
- <div class="carousel-inner" role="listbox">
+ <div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" data-src="holder.js/800x400?auto=yes&bg=777&fg=555&text=First slide" alt="First slide">
</div>
@@ -81,7 +81,7 @@ You can also add the indicators to the carousel, alongside the controls, too.
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
- <div class="carousel-inner" role="listbox">
+ <div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" data-src="holder.js/800x400?auto=yes&bg=777&fg=555&text=First slide" alt="First slide">
</div>
@@ -120,7 +120,7 @@ Add captions to your slides easily with the `.carousel-caption` element within a
<li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
</ol>
- <div class="carousel-inner" role="listbox">
+ <div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" data-src="holder.js/800x400?auto=yes&bg=777&fg=555&text=First slide" alt="First slide">
<div class="carousel-caption d-none d-md-block">
@@ -210,7 +210,8 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
<td>pause</td>
<td>string | boolean</td>
<td>"hover"</td>
- <td>If set to <code>"hover"</code>, pauses the cycling of the carousel on <code>mouseenter</code> and resumes the cycling of the carousel on <code>mouseleave</code>. If set to <code>false</code>, hovering over the carousel won't pause it.</td>
+ <td><p>If set to <code>"hover"</code>, pauses the cycling of the carousel on <code>mouseenter</code> and resumes the cycling of the carousel on <code>mouseleave</code>. If set to <code>false</code>, hovering over the carousel won't pause it.</p>
+ <p>On touch-enabled devices, when set to <code>"hover"</code>, cycling will pause on <code>touchend</code> (once the user finished interacting with the carousel) for two intervals, before automatically resuming. Note that this is in addition to the above mouse behavior.</p></td>
</tr>
<tr>
<td>ride</td>
diff --git a/docs/components/collapse.md b/docs/components/collapse.md
index 0a49db562..a86678ad1 100644
--- a/docs/components/collapse.md
+++ b/docs/components/collapse.md
@@ -119,7 +119,7 @@ You can also create accordions with custom markup. Add the `data-children` attri
## Accessibility
-Be sure to add `aria-expanded` to the control element. This attribute explicitly defines the current state of the collapsible element to screen readers and similar assistive technologies. If the collapsible element is closed by default, it should have a value of `aria-expanded="false"`. If you've set the collapsible element to be open by default using the `show` class, set `aria-expanded="true"` on the control instead. The plugin will automatically toggle this attribute based on whether or not the collapsible element has been opened or closed.
+Be sure to add `aria-expanded` to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of `aria-expanded="false"`. If you've set the collapsible element to be open by default using the `show` class, set `aria-expanded="true"` on the control instead. The plugin will automatically toggle this attribute on the control based on whether or not the collapsible element has been opened or closed (via JavaScript, or because the user triggered another control element also tied to the same collapsbile element).
Additionally, if your control element is targeting a single collapsible element – i.e. the `data-target` attribute is pointing to an `id` selector – you may add an additional `aria-controls` attribute to the control element, containing the `id` of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
diff --git a/docs/components/dropdowns.md b/docs/components/dropdowns.md
index 3c68f9453..4da232b7d 100644
--- a/docs/components/dropdowns.md
+++ b/docs/components/dropdowns.md
@@ -16,6 +16,16 @@ Dropdowns are toggleable, contextual overlays for displaying lists of links and
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.
+{% callout info %}
+### Dropdown menu accessibility
+
+The [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr>](https://www.w3.org/TR/wai-aria/) standard defines an actual [`role="menu"` widget](https://www.w3.org/TR/wai-aria/roles#menu), but this is specific to application-like menus which trigger actions or functions. <abbr title="Accessible Rich Internet Applications">ARIA</abbr> menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus.
+
+Bootstrap's dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create dropdowns that contain additional inputs and form controls, such as search fields or login forms. For this reason, Bootstrap does not expect (nor automatically add) any of the `role` and `aria-` attributes required for true <abbr title="Accessible Rich Internet Applications">ARIA</abbr> menus. Authors will have to include these more specific attributes themselves.
+
+However, Bootstrap does add built-in support for most standard keyboard menu interactions, such as the ability to move through individual `.dropdown-item` elements using the cursor keys and close the menu with the <kbd>ESC</kbd> key.
+{% endcallout %}
+
### Single button dropdowns
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:
@@ -37,7 +47,7 @@ And with `<a>` elements:
{% example html %}
<div class="dropdown show">
- <a class="btn btn-secondary dropdown-toggle" href="https://example.com" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
@@ -480,7 +490,9 @@ Add `.disabled` to items in the dropdown to **style them as disabled**.
Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the `.show` class on the parent list item.
-On mobile devices, opening a dropdown adds a `.dropdown-backdrop` as a tap area for closing dropdown menus when tapping outside the menu, a requirement for proper iOS support. **This means that switching from an open dropdown menu to a different dropdown menu requires an extra tap on mobile.**
+{% callout info %}
+On touch-enabled devices, opening a dropdown adds empty (`$.noop`) `mouseover` handlers to the immediate children of the `<body>` element. This admittedly ugly hack is necessary to work around a [quirk in iOS' event delegation](https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html), which would otherwise prevent a tap anywhere outside of the dropdown from triggering the code that closes the dropdown. Once the dropdown is closed, these additional empty `mouseover` handlers are removed.
+{% endcallout %}
Note: The `data-toggle="dropdown"` attribute is relied on for closing dropdown menus at an application level, so it's a good idea to always use it.
diff --git a/docs/components/input-group.md b/docs/components/input-group.md
index 0869b70e7..f84cb2453 100644
--- a/docs/components/input-group.md
+++ b/docs/components/input-group.md
@@ -19,11 +19,11 @@ Place one add-on or button on either side of an input. You may also place one on
{% example html %}
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">@</span>
- <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
+ <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
</div>
<br>
<div class="input-group">
- <input type="text" class="form-control" placeholder="Recipient's username" aria-describedby="basic-addon2">
+ <input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
<span class="input-group-addon" id="basic-addon2">@example.com</span>
</div>
<br>
@@ -53,12 +53,12 @@ Add the relative form sizing classes to the `.input-group` itself and contents w
{% example html %}
<div class="input-group input-group-lg">
<span class="input-group-addon" id="sizing-addon1">@</span>
- <input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon1">
+ <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="sizing-addon1">
</div>
<br>
<div class="input-group">
<span class="input-group-addon" id="sizing-addon2">@</span>
- <input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon2">
+ <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="sizing-addon2">
</div>
{% endexample %}
@@ -124,12 +124,12 @@ Buttons in input groups must wrapped in a `.input-group-btn` for proper alignmen
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">Go!</button>
</span>
- <input type="text" class="form-control" placeholder="Search for...">
+ <input type="text" class="form-control" placeholder="Search for..." aria-label="Search for...">
</div>
</div>
<div class="col-lg-6">
<div class="input-group">
- <input type="text" class="form-control" placeholder="Search for...">
+ <input type="text" class="form-control" placeholder="Search for..." aria-label="Search for...>
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">Go!</button>
</span>
@@ -143,7 +143,7 @@ Buttons in input groups must wrapped in a `.input-group-btn` for proper alignmen
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">Hate it</button>
</span>
- <input type="text" class="form-control" placeholder="Product name">
+ <input type="text" class="form-control" placeholder="Product name" aria-label="Product name">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">Love it</button>
</span>
@@ -240,4 +240,4 @@ Buttons in input groups must wrapped in a `.input-group-btn` for proper alignmen
Screen readers will have trouble with your forms if you don't include a label for every input. For these input groups, ensure that any additional label or functionality is conveyed to assistive technologies.
-The exact technique to be used (`<label>` elements hidden using the `.sr-only` class, or use of the `aria-label`, `aria-labelledby`, `aria-describedby`, `title` or `placeholder` attribute) and what additional information will need to be conveyed will vary depending on the exact type of interface widget you're implementing. The examples in this section provide a few suggested, case-specific approaches.
+The exact technique to be used (`<label>` elements hidden using the `.sr-only` class, or use of the `aria-label` and `aria-labelledby` attributes, possibly in combination with `aria-describedby`) and what additional information will need to be conveyed will vary depending on the exact type of interface widget you're implementing. The examples in this section provide a few suggested, case-specific approaches.
diff --git a/docs/components/navbar.md b/docs/components/navbar.md
index 1aa83ae1c..0891d2327 100644
--- a/docs/components/navbar.md
+++ b/docs/components/navbar.md
@@ -57,7 +57,7 @@ Here's an example of all the sub-components included in a responsive light-theme
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
- <input class="form-control mr-sm-2" type="text" placeholder="Search">
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
@@ -192,7 +192,7 @@ Place various form controls and components within a navbar with `.form-inline`.
{% example html %}
<nav class="navbar navbar-light bg-faded">
<form class="form-inline">
- <input class="form-control mr-sm-2" type="text" placeholder="Search">
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
@@ -204,7 +204,7 @@ Align the contents of your inline forms with utilities as needed.
<nav class="navbar navbar-light bg-faded justify-content-between">
<a class="navbar-brand">Navbar</a>
<form class="form-inline">
- <input class="form-control mr-sm-2" type="text" placeholder="Search">
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
@@ -217,7 +217,7 @@ Input groups work, too:
<form class="form-inline">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">@</span>
- <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
+ <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
</div>
</form>
</nav>
@@ -300,7 +300,7 @@ Theming the navbar has never been easier thanks to the combination of theming cl
</li>
</ul>
<form class="form-inline">
- <input class="form-control mr-sm-2" type="text" placeholder="Search">
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-info my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
@@ -328,7 +328,7 @@ Theming the navbar has never been easier thanks to the combination of theming cl
</li>
</ul>
<form class="form-inline">
- <input class="form-control mr-sm-2" type="text" placeholder="Search">
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-secondary my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
@@ -356,7 +356,7 @@ Theming the navbar has never been easier thanks to the combination of theming cl
</li>
</ul>
<form class="form-inline">
- <input class="form-control mr-sm-2" type="text" placeholder="Search">
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-primary my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
@@ -458,7 +458,7 @@ With no `.navbar-brand` shown in lowest breakpoint:
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
- <input class="form-control mr-sm-2" type="text" placeholder="Search">
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
@@ -516,7 +516,7 @@ With a toggler on the left and brand name on the right:
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
- <input class="form-control mr-sm-2" type="text" placeholder="Search">
+ <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
diff --git a/docs/components/navs.md b/docs/components/navs.md
index fec61ef5d..9ab2535ed 100644
--- a/docs/components/navs.md
+++ b/docs/components/navs.md
@@ -295,7 +295,7 @@ Add dropdown menus with a little extra HTML and the [dropdowns JavaScript plugin
Use the tab JavaScript plugin—include it individually or through the compiled `bootstrap.js` file—to extend our navigational tabs and pills to create tabbable panes of local content, even via dropdown menus.
-<div class="bd-example bd-example-tabs" role="tabpanel">
+<div class="bd-example bd-example-tabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-expanded="true">Home</a>
@@ -357,7 +357,7 @@ Use the tab JavaScript plugin—include it individually or through the compiled
To help fit your needs, this works with `<ul>`-based markup, as shown above, as well as `<nav>`-based markup shown below.
-<div class="bd-example bd-example-tabs" role="tabpanel">
+<div class="bd-example bd-example-tabs">
<nav class="nav nav-tabs" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="home" aria-expanded="true">Home</a>
<a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="profile">Profile</a>
@@ -411,7 +411,7 @@ To help fit your needs, this works with `<ul>`-based markup, as shown above, as
The tabs plugin also works with pills.
-<div class="bd-example bd-example-tabs" role="tabpanel">
+<div class="bd-example bd-example-tabs">
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-expanded="true">Home</a>
@@ -469,7 +469,7 @@ The tabs plugin also works with pills.
And with vertical pills.
-<div class="bd-example bd-example-tabs" role="tabpanel">
+<div class="bd-example bd-example-tabs">
<div class="row">
<div class="col-3">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist">
@@ -517,7 +517,6 @@ And with vertical pills.
You can activate a tab or pill navigation without writing any JavaScript by simply specifying `data-toggle="tab"` or `data-toggle="pill"` on an element. Use these data attributes on `.nav-tabs` or `.nav-pills`.
-<div role="tabpanel">
{% highlight html %}
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="myTab" role="tablist">
@@ -543,7 +542,6 @@ You can activate a tab or pill navigation without writing any JavaScript by simp
<div class="tab-pane" id="settings" role="tabpanel">...</div>
</div>
{% endhighlight %}
-</div>
### Via JavaScript