Commit 1fe92ec
committed
feat(checkbox): modernize for md3 spec compliance
Rewrites the Checkbox renderer to match the Material Design 3 spec
(https://m3.material.io/components/checkbox/specs):
- 18dp container with 2dp outline (unselected) / 0dp outline + theme
primary fill (selected), inside a 40dp state-layer tap target.
- State-layer overlay renders hover (8%), focus (10%) and pressed (10%)
layers in the color the spec defines for each (selected pressed flips
to onSurface; error always wins).
- Focus indicator: 3dp ring at theme.colors.secondary with the 2dp
outer-offset from md.sys.state.focusIndicator. Gated on
:focus-visible via the useFocusVisible hook added in #4952.
- Animations approximate Compose Material3 Checkbox.kt: 100ms fill
transition and 150ms checkmark draw, sequenced short-leg then
long-leg to suggest the stroke fraction. Indeterminate uses a
scaleX-animated dash.
- No new peer-deps: the checkmark is built from two rotated rectangles
(View-based), not an SVG path.
utils.ts:
- New getSelectionVisualState helper returns the full color +
opacity + outline-width picture for a given state combo.
- Legacy getSelectionControlColor kept as a compatibility export
for RadioButtonAndroid (radio button modernization is out of
scope for this PR).
9 snapshots auto-updated to reflect the new render tree.1 parent 8720eac commit 1fe92ec
11 files changed
Lines changed: 1788 additions & 838 deletions
File tree
- example/src/Examples
- src/components
- Checkbox
- RadioButton
- __tests__
- Checkbox
- __snapshots__
- RadioButton
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
12 | 32 | | |
13 | 33 | | |
14 | 34 | | |
| |||
33 | 53 | | |
34 | 54 | | |
35 | 55 | | |
36 | | - | |
| 56 | + | |
37 | 57 | | |
38 | | - | |
| 58 | + | |
39 | 59 | | |
40 | | - | |
| 60 | + | |
41 | 61 | | |
42 | 62 | | |
43 | 63 | | |
| |||
54 | 74 | | |
55 | 75 | | |
56 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
57 | 113 | | |
58 | 114 | | |
59 | 115 | | |
| |||
71 | 127 | | |
72 | 128 | | |
73 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
74 | 138 | | |
75 | 139 | | |
76 | 140 | | |
0 commit comments