@warp-ds/elements 2.9.1 → 2.10.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +347 -284
- package/dist/docs/button/accessibility.md +42 -0
- package/dist/docs/button/api.md +63 -39
- package/dist/docs/button/button.md +322 -40
- package/dist/docs/button/examples.md +126 -0
- package/dist/docs/button/usage.md +89 -0
- package/dist/docs/modal/accessibility.md +1 -0
- package/dist/docs/modal/api.md +51 -0
- package/dist/docs/modal/examples.md +67 -0
- package/dist/docs/modal/modal.md +238 -0
- package/dist/docs/modal/usage.md +110 -0
- package/dist/docs/modal-footer/accessibility.md +1 -0
- package/dist/docs/modal-footer/api.md +11 -0
- package/dist/docs/modal-footer/examples.md +1 -0
- package/dist/docs/modal-footer/modal-footer.md +23 -0
- package/dist/docs/modal-footer/usage.md +1 -0
- package/dist/docs/modal-header/accessibility.md +1 -0
- package/dist/docs/modal-header/api.md +42 -0
- package/dist/docs/modal-header/examples.md +1 -0
- package/dist/docs/modal-header/modal-header.md +54 -0
- package/dist/docs/modal-header/usage.md +1 -0
- package/dist/docs/page-indicator/api.md +6 -6
- package/dist/docs/page-indicator/examples.md +8 -0
- package/dist/docs/page-indicator/page-indicator.md +23 -6
- package/dist/docs/page-indicator/usage.md +8 -0
- package/dist/docs/pagination/api.md +12 -10
- package/dist/docs/pagination/examples.md +20 -0
- package/dist/docs/pagination/pagination.md +50 -12
- package/dist/docs/pagination/usage.md +18 -0
- package/dist/docs/pill/accessibility.md +2 -0
- package/dist/docs/pill/api.md +10 -26
- package/dist/docs/pill/examples.md +23 -0
- package/dist/docs/pill/pill.md +43 -28
- package/dist/docs/pill/usage.md +8 -0
- package/dist/docs/radio/accessibility.md +1 -0
- package/dist/docs/radio/api.md +57 -0
- package/dist/docs/radio/examples.md +1 -0
- package/dist/docs/radio/radio.md +69 -0
- package/dist/docs/radio/usage.md +1 -0
- package/dist/docs/radio-group/accessibility.md +1 -0
- package/dist/docs/radio-group/api.md +69 -0
- package/dist/docs/radio-group/examples.md +68 -0
- package/dist/docs/radio-group/radio-group.md +311 -0
- package/dist/docs/radio-group/styling.md +118 -0
- package/dist/docs/radio-group/usage.md +44 -0
- package/dist/docs/select/accessibility.md +2 -0
- package/dist/docs/select/api.md +20 -16
- package/dist/docs/select/examples.md +116 -0
- package/dist/docs/select/select.md +168 -18
- package/dist/docs/select/usage.md +30 -0
- package/dist/index.d.ts +441 -474
- package/dist/packages/attention/attention.js +23 -21
- package/dist/packages/attention/attention.js.map +3 -3
- package/dist/packages/button/button.d.ts +54 -37
- package/dist/packages/button/button.js +17 -15
- package/dist/packages/button/button.js.map +3 -3
- package/dist/packages/button/button.react.stories.d.ts +2 -2
- package/dist/packages/button/react.d.ts +1 -1
- package/dist/packages/modal/index.d.ts +4 -4
- package/dist/packages/modal/index.js +4 -4
- package/dist/packages/modal/modal.d.ts +21 -12
- package/dist/packages/modal/modal.js +4 -4
- package/dist/packages/modal/modal.js.map +3 -3
- package/dist/packages/modal/modal.react.stories.d.ts +3 -3
- package/dist/packages/modal/modal.stories.d.ts +2 -1
- package/dist/packages/modal/modal.stories.js +85 -3
- package/dist/packages/modal/react.d.ts +2 -2
- package/dist/packages/modal-footer/modal-footer.d.ts +5 -3
- package/dist/packages/modal-footer/modal-footer.js +4 -4
- package/dist/packages/modal-footer/modal-footer.js.map +3 -3
- package/dist/packages/modal-footer/react.d.ts +1 -1
- package/dist/packages/modal-header/modal-header.d.ts +21 -11
- package/dist/packages/modal-header/modal-header.js +1 -1
- package/dist/packages/modal-header/modal-header.js.map +3 -3
- package/dist/packages/modal-header/react.d.ts +2 -2
- package/dist/packages/page-indicator/page-indicator.d.ts +9 -14
- package/dist/packages/page-indicator/page-indicator.js.map +2 -2
- package/dist/packages/pagination/pagination.d.ts +11 -11
- package/dist/packages/pagination/pagination.js.map +2 -2
- package/dist/packages/pill/pill.d.ts +14 -29
- package/dist/packages/pill/pill.js.map +2 -2
- package/dist/packages/pill/pill.react.stories.d.ts +2 -2
- package/dist/packages/pill/react.d.ts +1 -1
- package/dist/packages/radio/radio.d.ts +51 -13
- package/dist/packages/radio/radio.js +3 -3
- package/dist/packages/radio/radio.js.map +3 -3
- package/dist/packages/radio/radio.react.stories.d.ts +1 -1
- package/dist/packages/radio/radio.stories.d.ts +2 -2
- package/dist/packages/radio/react.d.ts +2 -2
- package/dist/packages/radio-group/radio-group.d.ts +43 -5
- package/dist/packages/radio-group/radio-group.js +7 -7
- package/dist/packages/radio-group/radio-group.js.map +3 -3
- package/dist/packages/radio-group/react.d.ts +4 -4
- package/dist/packages/select/select.d.ts +32 -48
- package/dist/packages/select/select.js.map +2 -2
- package/dist/web-types.json +349 -115
- package/package.json +5 -5
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
## `<w-radio-group>` API
|
|
2
|
+
|
|
3
|
+
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
4
|
+
|
|
5
|
+
### Properties
|
|
6
|
+
|
|
7
|
+
| Name | Type | Default | Summary |
|
|
8
|
+
|-|-|-|-|
|
|
9
|
+
| disabled | `boolean` | `false` | Disables the radio group and all child radios. |
|
|
10
|
+
| help-text | `string` | `''` | Help text for the radio group. |
|
|
11
|
+
| invalid | `boolean` | `false` | Marks the radio group as invalid. |
|
|
12
|
+
| label | `string` | `''` | Label for the radio group. |
|
|
13
|
+
| name | `string \| null` | `null` | The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form. |
|
|
14
|
+
| optional | `boolean` | `false` | Whether to show optional text next to the label. |
|
|
15
|
+
| required | `boolean` | `false` | Makes selecting a radio in the the group required. |
|
|
16
|
+
|
|
17
|
+
### Property Details
|
|
18
|
+
|
|
19
|
+
#### disabled
|
|
20
|
+
|
|
21
|
+
Disables the radio group and all child radios.
|
|
22
|
+
|
|
23
|
+
- Type: `boolean`
|
|
24
|
+
- Default: `false`
|
|
25
|
+
|
|
26
|
+
#### help-text
|
|
27
|
+
|
|
28
|
+
Help text for the radio group.
|
|
29
|
+
|
|
30
|
+
If you set `required` and `invalid` the group gets a default error message, but you can override it with this attribute.
|
|
31
|
+
|
|
32
|
+
- Type: `string`
|
|
33
|
+
- Default: `''`
|
|
34
|
+
|
|
35
|
+
#### invalid
|
|
36
|
+
|
|
37
|
+
Marks the radio group as invalid.
|
|
38
|
+
|
|
39
|
+
- Type: `boolean`
|
|
40
|
+
- Default: `false`
|
|
41
|
+
|
|
42
|
+
#### label
|
|
43
|
+
|
|
44
|
+
Label for the radio group.
|
|
45
|
+
|
|
46
|
+
- Type: `string`
|
|
47
|
+
- Default: `''`
|
|
48
|
+
|
|
49
|
+
#### name
|
|
50
|
+
|
|
51
|
+
The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form.
|
|
52
|
+
|
|
53
|
+
- Type: `string | null`
|
|
54
|
+
- Default: `null`
|
|
55
|
+
|
|
56
|
+
#### optional
|
|
57
|
+
|
|
58
|
+
Whether to show optional text next to the label.
|
|
59
|
+
|
|
60
|
+
- Type: `boolean`
|
|
61
|
+
- Default: `false`
|
|
62
|
+
|
|
63
|
+
#### required
|
|
64
|
+
|
|
65
|
+
Makes selecting a radio in the the group required.
|
|
66
|
+
|
|
67
|
+
- Type: `boolean`
|
|
68
|
+
- Default: `false`
|
|
69
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
## Examples
|
|
2
|
+
|
|
3
|
+
<elements-example>
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<w-radio-group label="Select an option" name="examples">
|
|
7
|
+
<w-radio value="one">Option 1</w-radio>
|
|
8
|
+
<w-radio value="two">Option 2</w-radio>
|
|
9
|
+
<w-radio value="three">Option 3</w-radio>
|
|
10
|
+
</w-radio-group>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
</elements-example>
|
|
14
|
+
|
|
15
|
+
### Optional
|
|
16
|
+
|
|
17
|
+
Add the `optional` prop to `<w-radio-group>` to indicate that the user doesn't have to pick an option.
|
|
18
|
+
|
|
19
|
+
<elements-example>
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<w-radio-group label="Select an option" name="optional" optional>
|
|
23
|
+
<w-radio value="one">Option 1</w-radio>
|
|
24
|
+
<w-radio value="two">Option 2</w-radio>
|
|
25
|
+
<w-radio value="three">Option 3</w-radio>
|
|
26
|
+
</w-radio-group>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
</elements-example>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Help text
|
|
33
|
+
|
|
34
|
+
Use `help-text` to give additional context when the label and options are not enough.
|
|
35
|
+
|
|
36
|
+
<elements-example>
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<w-radio-group label="Select an option" name="help" help-text="Pick whichever you like">
|
|
40
|
+
<w-radio value="one">Option 1</w-radio>
|
|
41
|
+
<w-radio value="two">Option 2</w-radio>
|
|
42
|
+
<w-radio value="three">Option 3</w-radio>
|
|
43
|
+
</w-radio-group>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
</elements-example>
|
|
47
|
+
|
|
48
|
+
### Disabled
|
|
49
|
+
|
|
50
|
+
Keep in mind that using disabled is an anti-pattern.
|
|
51
|
+
|
|
52
|
+
There will always be users who don't understand why an element is disabled, or users who can't even see that
|
|
53
|
+
it is disabled because of poor lighting conditions or other reasons.
|
|
54
|
+
|
|
55
|
+
Please consider more informative alternatives before choosing to use disabled on an element.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
<elements-example>
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<w-radio-group label="Select an option" name="disabled" disabled>
|
|
62
|
+
<w-radio value="one">Option 1</w-radio>
|
|
63
|
+
<w-radio value="two">Option 2</w-radio>
|
|
64
|
+
<w-radio value="three">Option 3</w-radio>
|
|
65
|
+
</w-radio-group>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
</elements-example>
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# RadioGroup (w-radio-group)
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Radios allow users to select a single option from a list of choices.
|
|
6
|
+
|
|
7
|
+
Use with `w-radio`.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
A radio input typically consists of two components:
|
|
12
|
+
|
|
13
|
+
- `<w-radio-group>` - A grouping wrapper that manages labeling, help text, roving keyboard focus, and validation for child radios.
|
|
14
|
+
- `<w-radio>` - A single radio with required and invalid states.
|
|
15
|
+
|
|
16
|
+
In advanced cases you may use `<w-radio>` without `<w-radio-group>`. If you're unsure what's correct in your case, always wrap `<w-radio>` in a `<w-radio-group>`.
|
|
17
|
+
|
|
18
|
+
The components automatically handle:
|
|
19
|
+
|
|
20
|
+
- Form integration and constraint validation
|
|
21
|
+
- Required state handling with validation messages
|
|
22
|
+
- Accessibility attributes, keyboard interaction, and labeling
|
|
23
|
+
|
|
24
|
+
<elements-example>
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<w-radio-group label="Select an option" name="usage">
|
|
28
|
+
<w-radio value="one">Option 1</w-radio>
|
|
29
|
+
<w-radio value="two">Option 2</w-radio>
|
|
30
|
+
<w-radio value="three">Option 3</w-radio>
|
|
31
|
+
</w-radio-group>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
</elements-example>
|
|
35
|
+
|
|
36
|
+
### Validation
|
|
37
|
+
|
|
38
|
+
Set the `invalid` attribute to display a radio group as invalid, for example if nothing was selected and the group was `required`.
|
|
39
|
+
|
|
40
|
+
`invalid` can be paired with `help-text` to provide feedback to the user about how to correct the error. However, since the `invalid` + `required` use case is so common you can omit `help-text` to use a generic built-in one.
|
|
41
|
+
|
|
42
|
+
<elements-example>
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<w-radio-group label="Select an option" name="usage" required invalid>
|
|
46
|
+
<w-radio value="one">Option 1</w-radio>
|
|
47
|
+
<w-radio value="two">Option 2</w-radio>
|
|
48
|
+
<w-radio value="three">Option 3</w-radio>
|
|
49
|
+
</w-radio-group>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
</elements-example>
|
|
53
|
+
|
|
54
|
+
## Accessibility
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
<elements-example>
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<w-radio-group label="Select an option" name="examples">
|
|
62
|
+
<w-radio value="one">Option 1</w-radio>
|
|
63
|
+
<w-radio value="two">Option 2</w-radio>
|
|
64
|
+
<w-radio value="three">Option 3</w-radio>
|
|
65
|
+
</w-radio-group>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
</elements-example>
|
|
69
|
+
|
|
70
|
+
### Optional
|
|
71
|
+
|
|
72
|
+
Add the `optional` prop to `<w-radio-group>` to indicate that the user doesn't have to pick an option.
|
|
73
|
+
|
|
74
|
+
<elements-example>
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<w-radio-group label="Select an option" name="optional" optional>
|
|
78
|
+
<w-radio value="one">Option 1</w-radio>
|
|
79
|
+
<w-radio value="two">Option 2</w-radio>
|
|
80
|
+
<w-radio value="three">Option 3</w-radio>
|
|
81
|
+
</w-radio-group>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
</elements-example>
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### Help text
|
|
88
|
+
|
|
89
|
+
Use `help-text` to give additional context when the label and options are not enough.
|
|
90
|
+
|
|
91
|
+
<elements-example>
|
|
92
|
+
|
|
93
|
+
```html
|
|
94
|
+
<w-radio-group label="Select an option" name="help" help-text="Pick whichever you like">
|
|
95
|
+
<w-radio value="one">Option 1</w-radio>
|
|
96
|
+
<w-radio value="two">Option 2</w-radio>
|
|
97
|
+
<w-radio value="three">Option 3</w-radio>
|
|
98
|
+
</w-radio-group>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
</elements-example>
|
|
102
|
+
|
|
103
|
+
### Disabled
|
|
104
|
+
|
|
105
|
+
Keep in mind that using disabled is an anti-pattern.
|
|
106
|
+
|
|
107
|
+
There will always be users who don't understand why an element is disabled, or users who can't even see that
|
|
108
|
+
it is disabled because of poor lighting conditions or other reasons.
|
|
109
|
+
|
|
110
|
+
Please consider more informative alternatives before choosing to use disabled on an element.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
<elements-example>
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<w-radio-group label="Select an option" name="disabled" disabled>
|
|
117
|
+
<w-radio value="one">Option 1</w-radio>
|
|
118
|
+
<w-radio value="two">Option 2</w-radio>
|
|
119
|
+
<w-radio value="three">Option 3</w-radio>
|
|
120
|
+
</w-radio-group>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
</elements-example>
|
|
124
|
+
|
|
125
|
+
## Styling API
|
|
126
|
+
|
|
127
|
+
This section documents the supported styling hooks for `<w-radio>` and `<w-radio-group>`.
|
|
128
|
+
|
|
129
|
+
Use these hooks to customize appearance without relying on internal structure or selectors.
|
|
130
|
+
|
|
131
|
+
Before changing the default styles, remember that doing so can result in less consistent experiences for users across the product. Prefer defaults.
|
|
132
|
+
|
|
133
|
+
- Prefer **component tokens** for size, spacing, and state styling.
|
|
134
|
+
- Use **parts** only for small, local tweaks.
|
|
135
|
+
- Avoid relying on internal class names or selectors.
|
|
136
|
+
|
|
137
|
+
### Parts
|
|
138
|
+
|
|
139
|
+
The radio exposes a small set of parts that can be targeted for last‑mile layout or typography tweaks.
|
|
140
|
+
|
|
141
|
+
| Part | Targets | Typical use |
|
|
142
|
+
|---|---|---|
|
|
143
|
+
| `control` | radio control (circle) | minor alignment or sizing tweaks |
|
|
144
|
+
| `label` | label content | typography tweaks |
|
|
145
|
+
|
|
146
|
+
Example:
|
|
147
|
+
|
|
148
|
+
```css
|
|
149
|
+
w-radio::part(label) {
|
|
150
|
+
font-weight: 600;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
w-radio::part(control) {
|
|
154
|
+
margin-top: 1px;
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Parts are intended as an **escape hatch**.
|
|
159
|
+
Prefer component tokens for anything state‑ or size‑related.
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### Component tokens
|
|
163
|
+
|
|
164
|
+
Component tokens (`--w-c-radio-*`) act as inputs to the radio styling.
|
|
165
|
+
They can be set directly on the component or inherited from a parent container.
|
|
166
|
+
|
|
167
|
+
```css
|
|
168
|
+
.settings-panel {
|
|
169
|
+
--w-c-radio-gap: 12px;
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Defaults are defined internally; setting a token is always optional.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
#### Layout & size
|
|
177
|
+
|
|
178
|
+
| Token | Purpose | Default |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| `--w-c-radio-gap` | space between control and label | `8px` |
|
|
181
|
+
| `--w-c-radio-size` | width/height of the control | `2rem` |
|
|
182
|
+
| `--w-c-radio-radius` | border radius of the control | `50%` |
|
|
183
|
+
| `--w-c-radio-border-width` | border width | `1px` |
|
|
184
|
+
| `--w-c-radio-checked-border-width` | border width when checked | `0.6rem` |
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
#### Colors
|
|
188
|
+
|
|
189
|
+
| Token | Purpose | Default |
|
|
190
|
+
|---|---|---|
|
|
191
|
+
| `--w-c-radio-bg` | control background | theme default |
|
|
192
|
+
| `--w-c-radio-border-color` | control border color | theme default |
|
|
193
|
+
| `--w-c-radio-border-color-checked` | border color when checked | theme default |
|
|
194
|
+
| `--w-c-radio-label-color` | label text color | `currentColor` |
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
#### Invalid state
|
|
198
|
+
|
|
199
|
+
| Token | Purpose | Default |
|
|
200
|
+
|---|---|---|
|
|
201
|
+
| `--w-c-radio-border-color-invalid` | border color when invalid | theme default |
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
#### Disabled state
|
|
205
|
+
|
|
206
|
+
| Token | Purpose | Default |
|
|
207
|
+
|---|---|---|
|
|
208
|
+
| `--w-c-radio-bg-disabled` | background when disabled | theme default |
|
|
209
|
+
| `--w-c-radio-border-color-disabled` | border when disabled | theme default |
|
|
210
|
+
| `--w-c-radio-label-color-disabled` | label color when disabled | theme default |
|
|
211
|
+
| `--w-c-radio-cursor-disabled` | cursor when disabled | `not-allowed` |
|
|
212
|
+
|
|
213
|
+
#### Typography
|
|
214
|
+
|
|
215
|
+
| Token | Purpose | Default |
|
|
216
|
+
|---|---|---|
|
|
217
|
+
| `--w-c-radio-label-font-size` | label font size | theme default |
|
|
218
|
+
| `--w-c-radio-label-line-height` | label line height | theme default |
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
#### Focus
|
|
222
|
+
|
|
223
|
+
| Token | Purpose | Default |
|
|
224
|
+
|---|---|---|
|
|
225
|
+
| `--w-c-radio-outline-width` | focus outline width | `2px` |
|
|
226
|
+
| `--w-c-radio-outline-color` | focus outline color | theme default |
|
|
227
|
+
| `--w-c-radio-outline-offset` | focus outline offset | theme default |
|
|
228
|
+
|
|
229
|
+
#### Interaction
|
|
230
|
+
|
|
231
|
+
| Token | Purpose | Default |
|
|
232
|
+
|---|---|---|
|
|
233
|
+
| `--w-c-radio-cursor` | cursor in enabled state | `pointer` |
|
|
234
|
+
|
|
235
|
+
#### Motion
|
|
236
|
+
|
|
237
|
+
| Token | Purpose | Default |
|
|
238
|
+
|---|---|---|
|
|
239
|
+
| `--w-c-radio-transition` | transition for control | `150ms cubic-bezier(0.4, 0, 0.2, 1)` |
|
|
240
|
+
|
|
241
|
+
Transitions are automatically disabled when `prefers-reduced-motion: reduce` is active.
|
|
242
|
+
|
|
243
|
+
## `<w-radio-group>` API
|
|
244
|
+
|
|
245
|
+
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
246
|
+
|
|
247
|
+
### Properties
|
|
248
|
+
|
|
249
|
+
| Name | Type | Default | Summary |
|
|
250
|
+
|-|-|-|-|
|
|
251
|
+
| disabled | `boolean` | `false` | Disables the radio group and all child radios. |
|
|
252
|
+
| help-text | `string` | `''` | Help text for the radio group. |
|
|
253
|
+
| invalid | `boolean` | `false` | Marks the radio group as invalid. |
|
|
254
|
+
| label | `string` | `''` | Label for the radio group. |
|
|
255
|
+
| name | `string \| null` | `null` | The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form. |
|
|
256
|
+
| optional | `boolean` | `false` | Whether to show optional text next to the label. |
|
|
257
|
+
| required | `boolean` | `false` | Makes selecting a radio in the the group required. |
|
|
258
|
+
|
|
259
|
+
### Property Details
|
|
260
|
+
|
|
261
|
+
#### disabled
|
|
262
|
+
|
|
263
|
+
Disables the radio group and all child radios.
|
|
264
|
+
|
|
265
|
+
- Type: `boolean`
|
|
266
|
+
- Default: `false`
|
|
267
|
+
|
|
268
|
+
#### help-text
|
|
269
|
+
|
|
270
|
+
Help text for the radio group.
|
|
271
|
+
|
|
272
|
+
If you set `required` and `invalid` the group gets a default error message, but you can override it with this attribute.
|
|
273
|
+
|
|
274
|
+
- Type: `string`
|
|
275
|
+
- Default: `''`
|
|
276
|
+
|
|
277
|
+
#### invalid
|
|
278
|
+
|
|
279
|
+
Marks the radio group as invalid.
|
|
280
|
+
|
|
281
|
+
- Type: `boolean`
|
|
282
|
+
- Default: `false`
|
|
283
|
+
|
|
284
|
+
#### label
|
|
285
|
+
|
|
286
|
+
Label for the radio group.
|
|
287
|
+
|
|
288
|
+
- Type: `string`
|
|
289
|
+
- Default: `''`
|
|
290
|
+
|
|
291
|
+
#### name
|
|
292
|
+
|
|
293
|
+
The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form.
|
|
294
|
+
|
|
295
|
+
- Type: `string | null`
|
|
296
|
+
- Default: `null`
|
|
297
|
+
|
|
298
|
+
#### optional
|
|
299
|
+
|
|
300
|
+
Whether to show optional text next to the label.
|
|
301
|
+
|
|
302
|
+
- Type: `boolean`
|
|
303
|
+
- Default: `false`
|
|
304
|
+
|
|
305
|
+
#### required
|
|
306
|
+
|
|
307
|
+
Makes selecting a radio in the the group required.
|
|
308
|
+
|
|
309
|
+
- Type: `boolean`
|
|
310
|
+
- Default: `false`
|
|
311
|
+
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
## Styling API
|
|
2
|
+
|
|
3
|
+
This section documents the supported styling hooks for `<w-radio>` and `<w-radio-group>`.
|
|
4
|
+
|
|
5
|
+
Use these hooks to customize appearance without relying on internal structure or selectors.
|
|
6
|
+
|
|
7
|
+
Before changing the default styles, remember that doing so can result in less consistent experiences for users across the product. Prefer defaults.
|
|
8
|
+
|
|
9
|
+
- Prefer **component tokens** for size, spacing, and state styling.
|
|
10
|
+
- Use **parts** only for small, local tweaks.
|
|
11
|
+
- Avoid relying on internal class names or selectors.
|
|
12
|
+
|
|
13
|
+
### Parts
|
|
14
|
+
|
|
15
|
+
The radio exposes a small set of parts that can be targeted for last‑mile layout or typography tweaks.
|
|
16
|
+
|
|
17
|
+
| Part | Targets | Typical use |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `control` | radio control (circle) | minor alignment or sizing tweaks |
|
|
20
|
+
| `label` | label content | typography tweaks |
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
|
|
24
|
+
```css
|
|
25
|
+
w-radio::part(label) {
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
w-radio::part(control) {
|
|
30
|
+
margin-top: 1px;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Parts are intended as an **escape hatch**.
|
|
35
|
+
Prefer component tokens for anything state‑ or size‑related.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Component tokens
|
|
39
|
+
|
|
40
|
+
Component tokens (`--w-c-radio-*`) act as inputs to the radio styling.
|
|
41
|
+
They can be set directly on the component or inherited from a parent container.
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
.settings-panel {
|
|
45
|
+
--w-c-radio-gap: 12px;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Defaults are defined internally; setting a token is always optional.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
#### Layout & size
|
|
53
|
+
|
|
54
|
+
| Token | Purpose | Default |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `--w-c-radio-gap` | space between control and label | `8px` |
|
|
57
|
+
| `--w-c-radio-size` | width/height of the control | `2rem` |
|
|
58
|
+
| `--w-c-radio-radius` | border radius of the control | `50%` |
|
|
59
|
+
| `--w-c-radio-border-width` | border width | `1px` |
|
|
60
|
+
| `--w-c-radio-checked-border-width` | border width when checked | `0.6rem` |
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
#### Colors
|
|
64
|
+
|
|
65
|
+
| Token | Purpose | Default |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `--w-c-radio-bg` | control background | theme default |
|
|
68
|
+
| `--w-c-radio-border-color` | control border color | theme default |
|
|
69
|
+
| `--w-c-radio-border-color-checked` | border color when checked | theme default |
|
|
70
|
+
| `--w-c-radio-label-color` | label text color | `currentColor` |
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
#### Invalid state
|
|
74
|
+
|
|
75
|
+
| Token | Purpose | Default |
|
|
76
|
+
|---|---|---|
|
|
77
|
+
| `--w-c-radio-border-color-invalid` | border color when invalid | theme default |
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
#### Disabled state
|
|
81
|
+
|
|
82
|
+
| Token | Purpose | Default |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `--w-c-radio-bg-disabled` | background when disabled | theme default |
|
|
85
|
+
| `--w-c-radio-border-color-disabled` | border when disabled | theme default |
|
|
86
|
+
| `--w-c-radio-label-color-disabled` | label color when disabled | theme default |
|
|
87
|
+
| `--w-c-radio-cursor-disabled` | cursor when disabled | `not-allowed` |
|
|
88
|
+
|
|
89
|
+
#### Typography
|
|
90
|
+
|
|
91
|
+
| Token | Purpose | Default |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `--w-c-radio-label-font-size` | label font size | theme default |
|
|
94
|
+
| `--w-c-radio-label-line-height` | label line height | theme default |
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
#### Focus
|
|
98
|
+
|
|
99
|
+
| Token | Purpose | Default |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `--w-c-radio-outline-width` | focus outline width | `2px` |
|
|
102
|
+
| `--w-c-radio-outline-color` | focus outline color | theme default |
|
|
103
|
+
| `--w-c-radio-outline-offset` | focus outline offset | theme default |
|
|
104
|
+
|
|
105
|
+
#### Interaction
|
|
106
|
+
|
|
107
|
+
| Token | Purpose | Default |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `--w-c-radio-cursor` | cursor in enabled state | `pointer` |
|
|
110
|
+
|
|
111
|
+
#### Motion
|
|
112
|
+
|
|
113
|
+
| Token | Purpose | Default |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| `--w-c-radio-transition` | transition for control | `150ms cubic-bezier(0.4, 0, 0.2, 1)` |
|
|
116
|
+
|
|
117
|
+
Transitions are automatically disabled when `prefers-reduced-motion: reduce` is active.
|
|
118
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
## Usage
|
|
2
|
+
|
|
3
|
+
A radio input typically consists of two components:
|
|
4
|
+
|
|
5
|
+
- `<w-radio-group>` - A grouping wrapper that manages labeling, help text, roving keyboard focus, and validation for child radios.
|
|
6
|
+
- `<w-radio>` - A single radio with required and invalid states.
|
|
7
|
+
|
|
8
|
+
In advanced cases you may use `<w-radio>` without `<w-radio-group>`. If you're unsure what's correct in your case, always wrap `<w-radio>` in a `<w-radio-group>`.
|
|
9
|
+
|
|
10
|
+
The components automatically handle:
|
|
11
|
+
|
|
12
|
+
- Form integration and constraint validation
|
|
13
|
+
- Required state handling with validation messages
|
|
14
|
+
- Accessibility attributes, keyboard interaction, and labeling
|
|
15
|
+
|
|
16
|
+
<elements-example>
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<w-radio-group label="Select an option" name="usage">
|
|
20
|
+
<w-radio value="one">Option 1</w-radio>
|
|
21
|
+
<w-radio value="two">Option 2</w-radio>
|
|
22
|
+
<w-radio value="three">Option 3</w-radio>
|
|
23
|
+
</w-radio-group>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
</elements-example>
|
|
27
|
+
|
|
28
|
+
### Validation
|
|
29
|
+
|
|
30
|
+
Set the `invalid` attribute to display a radio group as invalid, for example if nothing was selected and the group was `required`.
|
|
31
|
+
|
|
32
|
+
`invalid` can be paired with `help-text` to provide feedback to the user about how to correct the error. However, since the `invalid` + `required` use case is so common you can omit `help-text` to use a generic built-in one.
|
|
33
|
+
|
|
34
|
+
<elements-example>
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<w-radio-group label="Select an option" name="usage" required invalid>
|
|
38
|
+
<w-radio value="one">Option 1</w-radio>
|
|
39
|
+
<w-radio value="two">Option 2</w-radio>
|
|
40
|
+
<w-radio value="three">Option 3</w-radio>
|
|
41
|
+
</w-radio-group>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
</elements-example>
|
package/dist/docs/select/api.md
CHANGED
|
@@ -6,19 +6,19 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
6
6
|
|
|
7
7
|
| Name | Type | Default | Summary |
|
|
8
8
|
|-|-|-|-|
|
|
9
|
-
| always | `boolean` | `false` | Whether to always show a hint
|
|
10
|
-
| auto-focus | `boolean` | `false` | Whether the element should receive focus on render
|
|
9
|
+
| always | `boolean` | `false` | Whether to always show a hint. **Deprecated**: Use `help-text` instead and only set it if you want to display the help text. |
|
|
10
|
+
| auto-focus | `boolean` | `false` | Whether the element should receive focus on render. **Deprecated**: Use the native `autofocus` attribute instead. |
|
|
11
11
|
| autofocus | `boolean` | `false` | Whether the element should receive focus on render |
|
|
12
12
|
| disabled | `boolean` | `false` | Renders the field in a disabled state. |
|
|
13
|
-
| help-text | `string` | `-` | The content displayed as the help text.
|
|
14
|
-
| hint | `string` | `-` | The content displayed as the help text
|
|
15
|
-
| invalid | `boolean` | `false` | Renders the field in an invalid state.
|
|
16
|
-
| label | `string` | `-` | The content to
|
|
17
|
-
| name | `string` | `-` | - |
|
|
18
|
-
| optional | `boolean` | `false` | Whether to show optional
|
|
19
|
-
| read-only | `boolean` | `false` | Renders the field in a readonly state
|
|
13
|
+
| help-text | `string` | `-` | The content displayed as the help text. |
|
|
14
|
+
| hint | `string` | `-` | The content displayed as the help text. **Deprecated**: Use `help-text` instead. |
|
|
15
|
+
| invalid | `boolean` | `false` | Renders the field in an invalid state. |
|
|
16
|
+
| label | `string` | `-` | The content to display as the label. |
|
|
17
|
+
| name | `string` | `-` | The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form. |
|
|
18
|
+
| optional | `boolean` | `false` | Whether to show the optional indicator after the label. |
|
|
19
|
+
| read-only | `boolean` | `false` | Renders the field in a readonly state. **Deprecated**: Use the native readonly attribute instead. |
|
|
20
20
|
| readonly | `boolean` | `false` | Renders the field in a readonly state. |
|
|
21
|
-
| value | `string` | `-` |
|
|
21
|
+
| value | `string` | `-` | Lets you set the current value. |
|
|
22
22
|
|
|
23
23
|
### Property Details
|
|
24
24
|
|
|
@@ -56,7 +56,9 @@ Renders the field in a disabled state.
|
|
|
56
56
|
|
|
57
57
|
#### help-text
|
|
58
58
|
|
|
59
|
-
The content displayed as the help text.
|
|
59
|
+
The content displayed as the help text.
|
|
60
|
+
|
|
61
|
+
Paired with `invalid` to show the text as a validation error.
|
|
60
62
|
|
|
61
63
|
- Type: `string`
|
|
62
64
|
- Default: `-`
|
|
@@ -72,28 +74,30 @@ The content displayed as the help text.
|
|
|
72
74
|
|
|
73
75
|
#### invalid
|
|
74
76
|
|
|
75
|
-
Renders the field in an invalid state.
|
|
77
|
+
Renders the field in an invalid state.
|
|
78
|
+
|
|
79
|
+
Paired with `help-text` to provide feedback about the error.
|
|
76
80
|
|
|
77
81
|
- Type: `boolean`
|
|
78
82
|
- Default: `false`
|
|
79
83
|
|
|
80
84
|
#### label
|
|
81
85
|
|
|
82
|
-
The content to
|
|
86
|
+
The content to display as the label.
|
|
83
87
|
|
|
84
88
|
- Type: `string`
|
|
85
89
|
- Default: `-`
|
|
86
90
|
|
|
87
91
|
#### name
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
The [name](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#name) of the select when submitting the form.
|
|
90
94
|
|
|
91
95
|
- Type: `string`
|
|
92
96
|
- Default: `-`
|
|
93
97
|
|
|
94
98
|
#### optional
|
|
95
99
|
|
|
96
|
-
Whether to show optional
|
|
100
|
+
Whether to show the optional indicator after the label.
|
|
97
101
|
|
|
98
102
|
- Type: `boolean`
|
|
99
103
|
- Default: `false`
|
|
@@ -116,7 +120,7 @@ Renders the field in a readonly state.
|
|
|
116
120
|
|
|
117
121
|
#### value
|
|
118
122
|
|
|
119
|
-
|
|
123
|
+
Lets you set the current value.
|
|
120
124
|
|
|
121
125
|
- Type: `string`
|
|
122
126
|
- Default: `-`
|