Repository navigation
feat: fix residual md3 deviation - checkbox component #5104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1a774eb
1ddbd87
6ebdc86
1f0e89c
37ab78a
d7205a3
314cb5e
c060f2e
a5c403e
8fb45fe
05ae4ce
d9ba88d
64590ec
17d078b
ec21e74
df3fe38
cfa49af
afb4c40
71c7a4d
b6de531
3797c68
c79fe23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -573,3 +573,43 @@ mutually exclusive options, use `SegmentedButtons`. | |
| /> | ||
| </> | ||
| ``` | ||
|
|
||
| ### Checkbox | ||
|
|
||
| #### Interaction states | ||
|
|
||
| Hover, focus and press now paint a Material Design 3 state layer, a 40dp circle around the box, on every platform. Hover and focus use `primary` when the checkbox is selected and `onSurface` when it is not, a press ripples in the opposite color, and an error checkbox uses `error` throughout. `color` and `uncheckedColor` also set the matching state layer color. Keyboard focus draws a 50dp ring with a 2dp gap around the state layer. | ||
|
|
||
| To use the platform ripple instead of the state layer press, pass `rippleColor` on any platform, `background` on Android or `underlayColor` on iOS. Setting `rippleEffectEnabled: false` on the `settings` prop of `PaperProvider` turns off the press ripple either way. | ||
|
|
||
| #### Touch target size | ||
|
|
||
| `Checkbox` now takes up 48dp instead of 36dp to meet the minimum touch target, so rows with a checkbox can grow up to 12dp taller. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| #### Style | ||
|
|
||
| `Checkbox` now accepts `style` and applies it to its outer container, so layout styles such as `margin`, `position` and `transform` move the whole checkbox, focus ring included. `width` and `height` do not resize the 48dp touch target. | ||
|
|
||
| To keep the 36dp footprint of 5.x, use a negative margin. The touch target stays 48dp and reaches 6dp into the space around the checkbox: | ||
|
|
||
| ```tsx | ||
| // Before (v5) | ||
| <Checkbox status="checked" onPress={onPress} aria-label="Notify me" /> | ||
|
|
||
| // After (v6) | ||
| <Checkbox | ||
| status="checked" | ||
| onPress={onPress} | ||
| aria-label="Notify me" | ||
| style={{ margin: -6 }} | ||
| /> | ||
| ``` | ||
|
|
||
| #### Accessible name | ||
|
|
||
| A standalone `Checkbox` has no visible label, so it now warns in development when it has no accessible name. Pass `aria-label` or `accessibilityLabel`, or use `Checkbox.Item`, which names the whole row. On Android and web, `aria-labelledby` names it too. A checkbox hidden from assistive technology, for example with `aria-hidden`, does not warn. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A hidden checkbox that keeps |
||
|
|
||
| ```diff | ||
| -<Checkbox status="checked" onPress={onPress} /> | ||
| +<Checkbox status="checked" onPress={onPress} aria-label="Notify me" /> | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add that Space now toggles a checkbox on web, so apps with their own Space handling should remove it (it would toggle twice).