mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
Merge pull request #15009 from patrickhlauke/glyphicon-accessibility-tweaks
Glyphicon accessibility tweaks
This commit is contained in:
commit
5339f7c8d5
2 changed files with 42 additions and 14 deletions
|
@ -7,7 +7,7 @@
|
|||
<ul class="bs-glyphicons-list">
|
||||
{% for iconClassName in site.data.glyphicons %}
|
||||
<li>
|
||||
<span class="glyphicon {{ iconClassName }}"></span>
|
||||
<span class="glyphicon {{ iconClassName }}" aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">glyphicon {{ iconClassName }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
@ -35,8 +35,14 @@
|
|||
</ul>
|
||||
<p>Use whatever option best suits your specific development setup.</p>
|
||||
</div>
|
||||
<div class="bs-callout bs-callout-warning">
|
||||
<h4>Accessible icons</h4>
|
||||
<p>Modern versions of assistive technologies will announce CSS generated content, as well as specific Unicode characters. To avoid unintended and confusing output in screen readers (particularly when icons are used purely for decoration), we hide them with the <code>aria-hidden="true"</code> attribute.</p>
|
||||
<p>If you're using an icon to convey meaning (rather than only as a decorative element), ensure that this meaning is also conveyed to assistive technologies – for instance, include additional content, visually hidden with the <code>.sr-only</code> class.</p>
|
||||
<p>If you're creating controls with no other text (such as a <code><button></code> that only contains an icon), you should always provide alternative content to identify the purpose of the control, so that it will make sense to users of assistive technologies. In this case, you could add an <code>aria-label</code> attribute on the control itself.</p>
|
||||
</div>
|
||||
{% highlight html %}
|
||||
<span class="glyphicon glyphicon-search"></span>
|
||||
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
|
@ -45,22 +51,41 @@
|
|||
<div class="bs-example">
|
||||
<div class="btn-toolbar" role="toolbar">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-align-left"></span> <span class="sr-only">Left Align</span></button>
|
||||
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-align-center"></span> <span class="sr-only">Center Align</span></button>
|
||||
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-align-right"></span> <span class="sr-only">Right Align</span></button>
|
||||
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-align-justify"></span> <span class="sr-only">Justify</span></button>
|
||||
<button type="button" class="btn btn-default" aria-label="Left Align"><span class="glyphicon glyphicon-align-left" aria-hidden="true"></span></button>
|
||||
<button type="button" class="btn btn-default" aria-label="Center Align"><span class="glyphicon glyphicon-align-center" aria-hidden="true"></span></button>
|
||||
<button type="button" class="btn btn-default" aria-label="Right Align"><span class="glyphicon glyphicon-align-right" aria-hidden="true"></span></button>
|
||||
<button type="button" class="btn btn-default" aria-label="Justify"><span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-toolbar" role="toolbar">
|
||||
<button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-star"></span> Star</button>
|
||||
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-star"></span> Star</button>
|
||||
<button type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-star"></span> Star</button>
|
||||
<button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-star"></span> Star</button>
|
||||
<button type="button" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
|
||||
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
|
||||
<button type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
|
||||
<button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star</button>
|
||||
</div>
|
||||
</div>
|
||||
{% highlight html %}
|
||||
<button type="button" class="btn btn-default" aria-label="Left Align">
|
||||
<span class="glyphicon glyphicon-align-left" aria-hidden="true"></span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="btn btn-default btn-lg">
|
||||
<span class="glyphicon glyphicon-star"></span> Star
|
||||
<span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star
|
||||
</button>
|
||||
{% endhighlight %}
|
||||
<p>An icon used in an <a href="#alerts">alert</a> to convey that it's an error message, with additional <code>.sr-only</code> text to convey this hint to users of assistive technologies.</p>
|
||||
<div class="bs-example">
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
||||
<span class="sr-only">Error:</span>
|
||||
Enter a valid email address
|
||||
</div>
|
||||
</div>
|
||||
{% highlight html %}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
||||
<span class="sr-only">Error:</span>
|
||||
Enter a valid email address
|
||||
</div>
|
||||
{% endhighlight %}
|
||||
</div>
|
||||
|
|
|
@ -99,15 +99,18 @@ lead: "Learn about the project's history, meet the maintaining teams, and find o
|
|||
<div class="bs-brand-logos">
|
||||
<div class="bs-brand-item">
|
||||
<h3>Bootstrap</h3>
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
|
||||
<span class="sr-only">(correct)</span>
|
||||
</div>
|
||||
<div class="bs-brand-item">
|
||||
<h3 class="text-muted">BootStrap</h3>
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
|
||||
<span class="sr-only">(incorrect)</span>
|
||||
</div>
|
||||
<div class="bs-brand-item">
|
||||
<h3 class="text-muted">Twitter Bootstrap</h3>
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
|
||||
<span class="sr-only">(incorrect)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue