mirror of https://github.com/twbs/bootstrap.git
Bring back btn-check for now, but move to button stylesheet
This commit is contained in:
parent
d022106d09
commit
b3f71d921e
|
@ -279,4 +279,19 @@
|
|||
.btn-sm {
|
||||
@include button-size($btn-padding-y-sm, $btn-padding-x-sm, $btn-font-size-sm, $btn-border-radius-sm);
|
||||
}
|
||||
|
||||
.btn-check {
|
||||
position: absolute;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
pointer-events: none;
|
||||
|
||||
&[disabled],
|
||||
&:disabled {
|
||||
+ .btn {
|
||||
pointer-events: none;
|
||||
filter: none;
|
||||
opacity: .65;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ These classes can also be added to groups of links, as an alternative to the [`.
|
|||
|
||||
## Checkbox and radio button groups
|
||||
|
||||
Combine button-like checkbox and radio [toggle buttons]([[docsref:/forms/checks-radios]]) into a seamless looking button group.
|
||||
Combine button-like checkbox and radio toggle buttons into a seamless looking button group.
|
||||
|
||||
<Example code={`<div class="btn-group" role="group" aria-label="Basic checkbox toggle button group">
|
||||
<input type="checkbox" class="btn-check" id="btncheck1" autocomplete="off">
|
||||
|
|
|
@ -126,12 +126,83 @@ Additional utilities can be used to adjust the alignment of buttons when horizon
|
|||
<button class="btn btn-primary" type="button">Button</button>
|
||||
</div>`} />
|
||||
|
||||
## Toggle buttons
|
||||
|
||||
Create button-like checkboxes and radio buttons by using `.btn` styles rather than `.form-check-label` on the `<label>` elements. These toggle buttons can further be grouped in a [button group]([[docsref:/components/button-group]]) if needed.
|
||||
|
||||
### Checkbox toggle buttons
|
||||
|
||||
<Example code={`<input type="checkbox" class="btn-check" id="btn-check" autocomplete="off">
|
||||
<label class="btn btn-primary" for="btn-check">Single toggle</label>
|
||||
|
||||
<input type="checkbox" class="btn-check" id="btn-check-2" checked autocomplete="off">
|
||||
<label class="btn btn-primary" for="btn-check-2">Checked</label>
|
||||
|
||||
<input type="checkbox" class="btn-check" id="btn-check-3" autocomplete="off" disabled>
|
||||
<label class="btn btn-primary" for="btn-check-3">Disabled</label>`} />
|
||||
|
||||
<Example code={`<input type="checkbox" class="btn-check" id="btn-check-4" autocomplete="off">
|
||||
<label class="btn" for="btn-check-4">Single toggle</label>
|
||||
|
||||
<input type="checkbox" class="btn-check" id="btn-check-5" checked autocomplete="off">
|
||||
<label class="btn" for="btn-check-5">Checked</label>
|
||||
|
||||
<input type="checkbox" class="btn-check" id="btn-check-6" autocomplete="off" disabled>
|
||||
<label class="btn" for="btn-check-6">Disabled</label>`} />
|
||||
|
||||
<Callout>
|
||||
Visually, these checkbox toggle buttons are identical to the [button plugin toggle buttons]([[docsref:/components/buttons#button-plugin]]). However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as “checked“/“not checked“ (since, despite their appearance, they are fundamentally still checkboxes), whereas the button plugin toggle buttons will be announced as “button“/“button pressed“. The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
|
||||
</Callout>
|
||||
|
||||
### Radio toggle buttons
|
||||
|
||||
<Example code={`<input type="radio" class="btn-check" name="options" id="option1" autocomplete="off" checked>
|
||||
<label class="btn btn-secondary" for="option1">Checked</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options" id="option2" autocomplete="off">
|
||||
<label class="btn btn-secondary" for="option2">Radio</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options" id="option3" autocomplete="off" disabled>
|
||||
<label class="btn btn-secondary" for="option3">Disabled</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options" id="option4" autocomplete="off">
|
||||
<label class="btn btn-secondary" for="option4">Radio</label>`} />
|
||||
|
||||
<Example code={`<input type="radio" class="btn-check" name="options-base" id="option5" autocomplete="off" checked>
|
||||
<label class="btn" for="option5">Checked</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options-base" id="option6" autocomplete="off">
|
||||
<label class="btn" for="option6">Radio</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options-base" id="option7" autocomplete="off" disabled>
|
||||
<label class="btn" for="option7">Disabled</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options-base" id="option8" autocomplete="off">
|
||||
<label class="btn" for="option8">Radio</label>`} />
|
||||
|
||||
### Outlined styles
|
||||
|
||||
Different variants of `.btn`, such as the various outlined styles, are supported.
|
||||
|
||||
<Example code={`<input type="checkbox" class="btn-check" id="btn-check-outlined" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btn-check-outlined">Single toggle</label><br>
|
||||
|
||||
<input type="checkbox" class="btn-check" id="btn-check-2-outlined" checked autocomplete="off">
|
||||
<label class="btn btn-outline-secondary" for="btn-check-2-outlined">Checked</label><br>
|
||||
|
||||
<input type="radio" class="btn-check" name="options-outlined" id="success-outlined" autocomplete="off" checked>
|
||||
<label class="btn btn-outline-success" for="success-outlined">Checked success radio</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options-outlined" id="danger-outlined" autocomplete="off">
|
||||
<label class="btn btn-outline-danger" for="danger-outlined">Danger radio</label>`} />
|
||||
|
||||
|
||||
## Button plugin
|
||||
|
||||
The button plugin allows you to create simple on/off toggle buttons.
|
||||
|
||||
<Callout>
|
||||
Visually, these toggle buttons are identical to the [checkbox toggle buttons]([[docsref:/forms/checks-radios#checkbox-toggle-buttons]]). However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as “checked”/“not checked” (since, despite their appearance, they are fundamentally still checkboxes), whereas these toggle buttons will be announced as “button”/“button pressed”. The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
|
||||
Visually, these toggle buttons are identical to the [checkbox toggle buttons]([[docsref:/forms/checks]]). However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as “checked”/“not checked” (since, despite their appearance, they are fundamentally still checkboxes), whereas these toggle buttons will be announced as “button”/“button pressed”. The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
|
||||
</Callout>
|
||||
|
||||
### Toggle states
|
||||
|
|
|
@ -42,10 +42,7 @@ Several Bootstrap components include embedded SVGs in our CSS to style component
|
|||
- [Accordion]([[docsref:/components/accordion]])
|
||||
- [Carousel controls]([[docsref:/components/carousel#with-controls]])
|
||||
- [Close button]([[docsref:/components/close-button]]) (used in alerts and modals)
|
||||
- [Form checkboxes and radio buttons]([[docsref:/forms/checks-radios]])
|
||||
- [Form switches]([[docsref:/forms/checks-radios#switches]])
|
||||
- [Form validation icons]([[docsref:/forms/validation#server-side]])
|
||||
- [Navbar toggle buttons]([[docsref:/components/navbar#responsive-behaviors]])
|
||||
{/* - [Select menus]([[docsref:/forms/select]]) */}
|
||||
|
||||
Based on [community conversation](https://github.com/twbs/bootstrap/issues/25394), some options for addressing this in your own codebase include [replacing the URLs with locally hosted assets]([[docsref:/getting-started/webpack#extracting-svg-files]]), removing the images and using inline images (not possible in all components), and modifying your CSP. Our recommendation is to carefully review your own security policies and decide on the best path forward, if necessary.
|
||||
|
|
Loading…
Reference in New Issue