Skip to content

Commit 3d4052b

Browse files
coliffmdo
authored andcommitted
docs: add role="switch" to switches
`role="switch"` is automatically added to checkboxes with the switch attribute in Safari, but we still need to add `role="switch"` for Chromium and Firefox etc,
1 parent 66a68ac commit 3d4052b

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

site/src/components/shortcodes/StepperPlayground.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const stepCounts = [3, 4, 5, 6]
134134
<label class="form-label fw-semibold mb-0 user-select-none">&nbsp;</label>
135135
<b-checkgroup class="py-2">
136136
<div class="switch">
137-
<input type="checkbox" value="" id="stepper-fullwidth" switch>
137+
<input type="checkbox" value="" id="stepper-fullwidth" role="switch" switch>
138138
</div>
139139
<label for="stepper-fullwidth">Full width</label>
140140
</b-checkgroup>

site/src/content/docs/forms/switch.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Switches work by layering an invisible checkbox over the custom switch indicator
1515
Switches also include the `switch` attribute for browsers that support it. This provides haptic feedback when toggling the switch.
1616

1717
<Example code={`<div class="switch">
18-
<input type="checkbox" value="" id="switch" switch>
18+
<input type="checkbox" value="" id="switch" role="switch" switch>
1919
</div>`} />
2020

2121
## Label
@@ -26,14 +26,14 @@ Consider margin utilities for additional spacing, and flex utilities for alignme
2626

2727
<Example class="d-flex flex-column gap-3" code={`<b-checkgroup>
2828
<div class="switch switch-sm mt-1">
29-
<input type="checkbox" value="" id="switchSmLabel" switch>
29+
<input type="checkbox" value="" id="switchSmLabel" role="switch" switch>
3030
</div>
3131
<label for="switchSmLabel">Small switch</label>
3232
</b-checkgroup>
3333
3434
<b-checkgroup>
3535
<div class="switch">
36-
<input type="checkbox" value="" id="switchMdLabel" switch>
36+
<input type="checkbox" value="" id="switchMdLabel" role="switch" switch>
3737
</div>
3838
<label for="switchMdLabel">Default switch</label>
3939
</b-checkgroup>`} />
@@ -44,7 +44,7 @@ Modify the appearance of checked checkboxes by adding the `.checked-{color}` cla
4444

4545
<Example class="d-flex flex-column gap-2" code={getData('theme-colors').map((themeColor) => ` <b-checkgroup>
4646
<div class="switch switch-sm mt-1 checked-${themeColor.name}">
47-
<input type="checkbox" value="" id="switch${themeColor.name}" switch checked>
47+
<input type="checkbox" value="" id="switch${themeColor.name}" role="switch" switch checked>
4848
</div>
4949
<label for="switch${themeColor.name}">Example ${themeColor.name} switch</label>
5050
</b-checkgroup>`)} />
@@ -55,7 +55,7 @@ Add the `disabled` attribute and the associated `<label>`s are automatically sty
5555

5656
<Example class="d-flex flex-column gap-3" code={`<b-checkgroup>
5757
<div class="switch">
58-
<input type="checkbox" value="" id="switchDisabledLabel" switch disabled>
58+
<input type="checkbox" value="" id="switchDisabledLabel" role="switch" switch disabled>
5959
</div>
6060
<label for="switchDisabledLabel">Disabled switch</label>
6161
</b-checkgroup>`} />
@@ -65,13 +65,13 @@ Add the `disabled` attribute and the associated `<label>`s are automatically sty
6565
Add a size modifier class to make your switch appear smaller or larger.
6666

6767
<Example class="d-flex flex-column gap-3" code={`<div class="switch switch-sm">
68-
<input type="checkbox" value="" id="switchSizeSm" switch>
68+
<input type="checkbox" value="" id="switchSizeSm" role="switch" switch>
6969
</div>
7070
<div class="switch">
71-
<input type="checkbox" value="" id="switchSizeMd" switch>
71+
<input type="checkbox" value="" id="switchSizeMd" role="switch" switch>
7272
</div>
7373
<div class="switch switch-lg">
74-
<input type="checkbox" value="" id="switchSizeLg" switch>
74+
<input type="checkbox" value="" id="switchSizeLg" role="switch" switch>
7575
</div>`} />
7676

7777
## CSS

site/src/content/docs/getting-started/rtl.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Toggle between LTR and RTL on this page to see Bootstrap's logical properties in
3737
<div class="bd-example">
3838
<b-checkgroup>
3939
<div class="switch">
40-
<input type="checkbox" value="" id="rtlSwitch" switch />
40+
<input type="checkbox" value="" id="rtlSwitch" role="switch" switch />
4141
</div>
4242
<label for="rtlSwitch">Enable RTL mode</label>
4343
</b-checkgroup>

0 commit comments

Comments
 (0)