mirror of
https://github.com/Chalarangelo/mini.css.git
synced 2025-07-31 02:50:26 +02:00
Checkbox and radio button documentation
This commit is contained in:
@@ -303,29 +303,83 @@
|
||||
</div>
|
||||
<div class="section row">
|
||||
<div class="col-sm-12 col-sm-last col-lg-4 col-lg-normal">
|
||||
<!-- sample -->
|
||||
<div class="box-centered">
|
||||
<br>
|
||||
<div class="input-group">
|
||||
<input type="checkbox" id="chk1" tabindex="0" autocomplete="off"> <label for="chk1"> Checkbox</label>
|
||||
</div>
|
||||
<br><br>
|
||||
<div class="input-group">
|
||||
<input type="radio" name="radios" value="r1" id="r1" tabindex="0" autocomplete="off" checked> <label for="r1"> Value 1</label> <br>
|
||||
<input type="radio" name="radios" value="r2" id="r2" tabindex="0" autocomplete="off"> <label for="r2"> Value 2</label> <br>
|
||||
<input type="radio" name="radios" value="r3" id="r3" tabindex="0" autocomplete="off"> <label for="r3"> Value 3</label> <br>
|
||||
</div>
|
||||
<br><br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-sm-first col-lg-8 col-lg-normal">
|
||||
<p></p>
|
||||
<p>Checkboxes and radio buttons come pre-styled, using the <a href="https://css-tricks.com/the-checkbox-hack/">checkbox hack</a>, while remaining fully accessible. To create a checkbox or radio button, start using a <code><div></code> that implements the <code>.input-group</code> class, and then add a proper <code><input></code> inside it (<code>checkbox</code> or <code>radio</code>), followed immediately by a <code><label></code> linking to it. Remember to add <code><span class="fore-secondary">tabindex</span>=<span class="fore-primary">"0"</span></code> to your <code><input></code>, so that it will register properly for screen readers.</p>
|
||||
<h3>Sample code</h3>
|
||||
<pre></pre>
|
||||
<pre><div class="input-group">
|
||||
<input type="checkbox" id="check1" tabindex="0">
|
||||
<label for="check1">Checkbox</label>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="radio" id="rad1" tabindex="0" name="radio-group-1">
|
||||
<label for="rad1">Radio</label>
|
||||
</div></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3>Notes</h3>
|
||||
<ul>
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li>Checkboxes and radio buttons are fully accessible. However, if not provided with a label, they are not visible to users, but only to screen readers.</li>
|
||||
</ul>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-6 col-lg-4">
|
||||
<pre><!-- do code --></pre>
|
||||
<p class="do"><mark class="tertiary">Do:</mark> </p>
|
||||
<pre><div class="input-group">
|
||||
<input type="radio" id="rad1" tabindex="0" name="radio-group-1">
|
||||
<label for="rad1">Value 1</label>
|
||||
<input type="radio" id="rad2" tabindex="0" name="radio-group-1">
|
||||
<label for="rad2">Value 2</label>
|
||||
</div></pre>
|
||||
<p class="do"><mark class="tertiary">Do:</mark> You can add multiple <code>radio</code> buttons inside one <code>.input-group</code>, as long as they follow the syntax shown above. In fact, we strongly recommend grouping controls that are relevant to each other in this manner.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-6 col-sm-last col-md-normal col-lg-4 col-lg-last">
|
||||
<pre><!-- don't code --></pre>
|
||||
<p class="dont"><mark class="secondary">Don't:</mark> </p>
|
||||
<pre><input type="checkbox" id="check1" tabindex="0">
|
||||
<label for="check1">Checkbox</label></pre>
|
||||
<p class="dont"><mark class="secondary">Don't:</mark> Always use an <code>.input-group</code> for your checkboxes and radio buttons. Not doing so will cause the checkbox or radio button to not display properly.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-6 col-sm-last col-md-normal col-lg-4 col-lg-last">
|
||||
<pre><div class="input-group">
|
||||
<input type="checkbox" id="check1"
|
||||
<label for="check1">Checkbox</label>
|
||||
</div></pre>
|
||||
<p class="dont"><mark class="secondary">Don't:</mark> Remember to add <code><span class="fore-secondary">tabindex</span>=<span class="fore-primary">"0"</span></code> to all your checkboxes and radio buttons to make them accessible.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-6 col-sm-last col-md-normal col-lg-4 col-lg-last">
|
||||
<pre><div class="input-group">
|
||||
<label for="check1">Checkbox</label>
|
||||
<input type="checkbox" id="check1" tabindex="0">
|
||||
</div></pre>
|
||||
<p class="dont"><mark class="secondary">Don't:</mark> The structure of checkboxes and radio buttons is very strict, meaning that the <code><label></code> should always be after the <code><input></code> and never before, otherwise the checkbox or radio button will not display properly.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-6 col-sm-last col-md-normal col-lg-4 col-lg-last">
|
||||
<pre><div class="input-group">
|
||||
<input type="radio" id="rad1" tabindex="0" name="radio-group-1">
|
||||
<input type="radio" id="rad2" tabindex="0" name="radio-group-1">
|
||||
<label for="rad2">Value 2</label>
|
||||
<label for="rad1">Value 1</label>
|
||||
</div></pre>
|
||||
<p class="dont"><mark class="secondary">Don't:</mark> When using multiple radio buttons inside an <code>.input-group</code>, remember to use the usual structure of the radio button component for each radio button (i.e. the <code><input></code> and <code><label></code>). Not doing so will cause the radio buttons to not display properly.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-6 col-sm-last col-md-normal col-lg-4 col-lg-last">
|
||||
<pre><div class="input-group">
|
||||
<input type="checkbox" id="check1" tabindex="0">
|
||||
</div></pre>
|
||||
<p class="dont"><mark class="secondary">Don't:</mark> Never leave a checkbox or radio button without a <code><label></code>. The <code><label></code> is essential to properly display the checkbox or radio button.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user