You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/website/src/routes/docs/headless/checkbox/index.mdx
+8-11Lines changed: 8 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,27 +34,25 @@ Allows users to visually select an option by checking it.
34
34
35
35
### Controlled Checkbox
36
36
37
-
You can bind the internal value of a checkbox to a user-defined signal:
37
+
To add reactive state, use the `bind:checked` prop on the `<Checkbox.Root />` component.
38
38
39
39
<Showcasename="controlled" />
40
40
41
-
Do keep in mind that the inital value of the signal WILL affect the initial value of the checkbox.
41
+
> Note that the initial value of the signal will affect the initial value of the checkbox.
42
42
43
-
In the example below, the left checkbox was bindided to a signal with an inital value of false while the right checkbox was bindded to a signal with an inital falue of true.
43
+
In the example below, the left checkbox starts as **false**, while the right checkbox starts as **true**.
44
44
45
45
<Showcasename="controlled-values" />
46
46
47
47
## Customization & Caveats
48
48
49
-
The Checkbox is made from the ground up to be as customizable as possible.
50
-
51
-
You can define your own CSS classes on every part of the component as if it were a normal div element. You can even define any valid HTML as your icon, but keep in mind that any child of the Checkbox Indicator is removed from the accesibilyti tree. This is done to prevent text, or emojis, that are meant to be used as icons from being added to the label of the Checkbox (see [automatic labeling](#automatic-labeling) for more info).
49
+
You can apply CSS classes to any part of the component. Any valid HTML can be used as an icon, but children of the Checkbox Indicator are removed from the accessibility tree to prevent them from being added to the Checkbox Label.
52
50
53
51
### Automatic Labeling
54
52
55
-
Due to the implementation of the Checkbox element being a div with the role of checkbox, any text present inside the Checkbox Root is interpreted as the checkbox label.
53
+
The Checkbox element is a div with the role of checkbox, so any text inside the Checkbox Root is interpreted as the checkbox label.
56
54
57
-
This also means that any text tag is stripped from its semantic meaning. In other words, passing an h1 tag is treated the same as passing a p tag: they are both treated as if you passed no tag at all. See [this](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/checkbox_role#all_descendants_are_presentational)section of MDN for a more detailed explenation.
55
+
Text tags lose their semantic meaning. For example, an h1 tag is treated the same as a p tag. See [this MDN section](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/checkbox_role#all_descendants_are_presentational) for more details.
58
56
59
57
## API
60
58
@@ -64,13 +62,12 @@ This also means that any text tag is stripped from its semantic meaning. In othe
64
62
propDescriptors={[
65
63
{
66
64
name: 'bind:checked',
67
-
description:
68
-
'two-way data bind of the value of the checkbox to a user-defined signal',
65
+
description: 'Two-way data binding of the checkbox value to a user-defined signal',
69
66
},
70
67
{
71
68
name: 'checklist',
72
69
description:
73
-
"when true makes the checkbox be treated as a tri-state checkbox AND binds it's value over all other checkboxes inside the checklist",
70
+
'When true, treats the checkbox as a tri-state and binds its value to all other checkboxes in the checklist',
0 commit comments