x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<label class="btn btn--toggle">
<input type="checkbox" name="check_bold" id="check_bold" value="1" />
<img aria-hidden="true" src="/assets/bold-13078f72.svg" width="16" height="16" />
<span class="sr-only">Toggle bold</span>
</label>
<label class="btn btn--toggle">
<input type="checkbox" name="check_italic" id="check_italic" value="1" />
<img aria-hidden="true" src="/assets/italic-659e5247.svg" width="16" height="16" />
<span class="sr-only">Toggle italic</span>
</label>
<label class="btn btn--toggle">
<input type="checkbox" name="check_underline" id="check_underline" value="1" />
<img aria-hidden="true" src="/assets/underline-d7dbd291.svg" width="16" height="16" />
<span class="sr-only">Toggle underline</span>
</label>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<label class="btn btn--toggle">
<%= check_box_tag :check_bold %>
<%= image_tag "bold.svg", size: 16, aria: { hidden: true }%>
<span class="sr-only">Toggle bold</span>
</label>
<label class="btn btn--toggle">
<%= check_box_tag :check_italic %>
<%= image_tag "italic.svg", size: 16, aria: { hidden: true } %>
<span class="sr-only">Toggle italic</span>
</label>
<label class="btn btn--toggle">
<%= check_box_tag :check_underline %>
<%= image_tag "underline.svg", size: 16, aria: { hidden: true } %>
<span class="sr-only">Toggle underline</span>
</label>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
.btn--toggle {
[type="checkbox"] {
position: absolute; clip: rect(0, 0, 0, 0);
}
&:has([type="checkbox"]:checked) {
--btn-background: var(--color-secondary);
}
&:has(:focus-visible) {
outline: var(--border-2) solid var(--color-selected-dark);
outline-offset: var(--border-2);
}
}
Java Script is not required or multiple files are needed, check the notes.