Skip to content

Commit

Permalink
Merge pull request #13745 from twbs/fix-13281
Browse files Browse the repository at this point in the history
set not-allowed cursor on disabled radio+checkbox labels
  • Loading branch information
mdo committed Jun 8, 2014
2 parents 5fd8ca9 + dd7ee51 commit 7231efa
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
20 changes: 13 additions & 7 deletions dist/css/bootstrap.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion docs/_includes/css/forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ <h3>Textarea</h3>
{% endhighlight %}

<h3>Checkboxes and radios</h3>
<p>Checkboxes are for selecting one or several options in a list while radios are for selecting one option from many.</p>
<p>Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.</p>
<p>A checkbox or radio with the <code>disabled</code> attribute will be styled appropriately. To have the <code>&lt;label&gt;</code> for the checkbox or radio also display a "not-allowed" cursor when the user hovers over the label, add the <code>.disabled</code> class to your <code>.radio</code>, <code>.radio-inline</code>, <code>.checkbox</code>, <code>.checkbox-inline</code>, or <code>&lt;fieldset&gt;</code>.</p>
<h4>Default (stacked)</h4>
<div class="bs-example">
<form role="form">
Expand All @@ -217,6 +218,12 @@ <h4>Default (stacked)</h4>
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
<div class="checkbox disabled">
<label>
<input type="checkbox" value="" disabled>
Option two is disabled
</label>
</div>
<br>
<div class="radio">
<label>
Expand All @@ -230,6 +237,12 @@ <h4>Default (stacked)</h4>
Option two can be something else and selecting it will deselect option one
</label>
</div>
<div class="radio disabled">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
Option three is disabled
</label>
</div>
</form>
</div><!-- /.bs-example -->
{% highlight html %}
Expand All @@ -239,6 +252,12 @@ <h4>Default (stacked)</h4>
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
<div class="checkbox disabled">
<label>
<input type="checkbox" value="" disabled>
Option two is disabled
</label>
</div>

<div class="radio">
<label>
Expand All @@ -252,6 +271,12 @@ <h4>Default (stacked)</h4>
Option two can be something else and selecting it will deselect option one
</label>
</div>
<div class="radio disabled">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
Option three is disabled
</label>
</div>
{% endhighlight %}

<h4>Inline checkboxes and radios</h4>
Expand Down
24 changes: 20 additions & 4 deletions less/forms.less
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,35 @@ input[type="month"] {
}

// Apply same disabled cursor tweak as for inputs
// Some special care is needed because <label>s don't inherit their parent's `cursor`.
//
// Note: Neither radios nor checkboxes can be readonly.
input[type="radio"],
input[type="checkbox"],
.radio,
input[type="checkbox"] {
&[disabled],
&.disabled,
fieldset[disabled] & {
cursor: not-allowed;
}
}
// These classes are used directly on <label>s
.radio-inline,
.checkbox,
.checkbox-inline {
&[disabled],
&.disabled,
fieldset[disabled] & {
cursor: not-allowed;
}
}
// These classes are used on elements with <label> descendants
.radio,
.checkbox {
&.disabled,
fieldset[disabled] & {
label {
cursor: not-allowed;
}
}
}


// Form control sizing
Expand Down

0 comments on commit 7231efa

Please sign in to comment.