@boostdev/design-system-components 2.17.0 → 2.18.0

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.
Files changed (66) hide show
  1. package/AGENTS.md +2 -1
  2. package/dist/client.cjs +57 -57
  3. package/dist/client.css +633 -627
  4. package/dist/client.js +57 -57
  5. package/dist/index.cjs +57 -57
  6. package/dist/index.css +633 -627
  7. package/dist/index.js +57 -57
  8. package/dist/web-components/{chunk-XI2U6U26.js → chunk-2FNCV46J.js} +4 -5
  9. package/dist/web-components/{chunk-XJU7KITO.js → chunk-5QA7JOC3.js} +4 -5
  10. package/dist/web-components/{chunk-EYCW7TKB.js → chunk-7GEAT2TY.js} +4 -5
  11. package/dist/web-components/chunk-FYTISJN3.js +18 -0
  12. package/dist/web-components/{chunk-LHFUXZ52.js → chunk-ISV56UWR.js} +4 -8
  13. package/dist/web-components/{chunk-YLDQOESI.js → chunk-K3VK6VEL.js} +6 -5
  14. package/dist/web-components/{chunk-GQNQBEYR.js → chunk-QZMFNJSN.js} +4 -5
  15. package/dist/web-components/{chunk-GPJWLAKU.js → chunk-VGPJ5L6N.js} +6 -5
  16. package/dist/web-components/{chunk-AGI6YQRC.js → chunk-WOFGYU6E.js} +4 -5
  17. package/dist/web-components/index.js +9 -8
  18. package/dist/web-components/interaction/form/bds-checkbox-group.js +1 -1
  19. package/dist/web-components/interaction/form/bds-combobox.js +2 -1
  20. package/dist/web-components/interaction/form/bds-form-input.js +2 -1
  21. package/dist/web-components/interaction/form/bds-number-input.js +2 -1
  22. package/dist/web-components/interaction/form/bds-radio-group.js +1 -1
  23. package/dist/web-components/interaction/form/bds-select.js +2 -1
  24. package/dist/web-components/interaction/form/bds-slider.js +2 -1
  25. package/dist/web-components/interaction/form/bds-textarea.js +2 -1
  26. package/package.json +1 -1
  27. package/src/components/interaction/form/Checkbox/Checkbox.tsx +1 -1
  28. package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.mdx +1 -1
  29. package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.module.css +1 -1
  30. package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.spec.tsx +1 -1
  31. package/src/components/interaction/form/Combobox/Combobox.mdx +2 -0
  32. package/src/components/interaction/form/FormInput/FormInput.mdx +4 -0
  33. package/src/components/interaction/form/NumberInput/NumberInput.mdx +2 -0
  34. package/src/components/interaction/form/Radio/Radio.tsx +1 -1
  35. package/src/components/interaction/form/RadioGroup/RadioGroup.mdx +1 -1
  36. package/src/components/interaction/form/RadioGroup/RadioGroup.module.css +1 -1
  37. package/src/components/interaction/form/RadioGroup/RadioGroup.spec.tsx +1 -1
  38. package/src/components/interaction/form/Select/Select.mdx +2 -0
  39. package/src/components/interaction/form/Slider/Slider.mdx +2 -0
  40. package/src/components/interaction/form/Switch/Switch.tsx +1 -1
  41. package/src/components/interaction/form/Textarea/Textarea.mdx +2 -0
  42. package/src/components/interaction/form/atoms/Label.module.css +10 -0
  43. package/src/components/interaction/form/atoms/Label.spec.tsx +48 -0
  44. package/src/components/interaction/form/atoms/Label.stories.tsx +3 -0
  45. package/src/components/interaction/form/atoms/Label.tsx +4 -2
  46. package/src/web-components/interaction/form/BdsCheckboxGroup.mdx +14 -0
  47. package/src/web-components/interaction/form/BdsCombobox.mdx +4 -0
  48. package/src/web-components/interaction/form/BdsFormInput.mdx +4 -0
  49. package/src/web-components/interaction/form/BdsNumberInput.mdx +4 -0
  50. package/src/web-components/interaction/form/BdsRadioGroup.mdx +11 -1
  51. package/src/web-components/interaction/form/BdsSelect.mdx +4 -0
  52. package/src/web-components/interaction/form/BdsSlider.mdx +4 -0
  53. package/src/web-components/interaction/form/BdsTextarea.mdx +4 -0
  54. package/src/web-components/interaction/form/bds-checkbox-group.spec.ts +11 -1
  55. package/src/web-components/interaction/form/bds-checkbox-group.ts +6 -5
  56. package/src/web-components/interaction/form/bds-combobox.ts +2 -5
  57. package/src/web-components/interaction/form/bds-form-input.ts +2 -5
  58. package/src/web-components/interaction/form/bds-number-input.ts +2 -5
  59. package/src/web-components/interaction/form/bds-radio-group.spec.ts +11 -1
  60. package/src/web-components/interaction/form/bds-radio-group.ts +6 -5
  61. package/src/web-components/interaction/form/bds-select.ts +2 -5
  62. package/src/web-components/interaction/form/bds-slider.ts +2 -8
  63. package/src/web-components/interaction/form/bds-textarea.ts +2 -5
  64. package/src/web-components/interaction/form/field-label.spec.ts +42 -0
  65. package/src/web-components/interaction/form/field-label.ts +20 -0
  66. package/src/web-components/test/helpers.ts +20 -0
@@ -1,3 +1,6 @@
1
+ import {
2
+ fieldLabelStyles
3
+ } from "./chunk-FYTISJN3.js";
1
4
  import {
2
5
  fieldMessageStyles,
3
6
  renderFieldMessage
@@ -32,11 +35,6 @@ var BdsTextarea = class extends i2 {
32
35
  }
33
36
 
34
37
  .label {
35
- display: block;
36
- font-size: var(--bds-font_size--body--s);
37
- font-family: var(--bds-font_family--body);
38
- font-weight: var(--bds-font_weight--semibold);
39
- color: var(--bds-color_on-bg);
40
38
  margin-block-end: var(--bds-space_xxs);
41
39
  }
42
40
 
@@ -91,6 +89,7 @@ var BdsTextarea = class extends i2 {
91
89
  --bdc-outline_width: var(--bdc-outline_width--error, 2px);
92
90
  }
93
91
 
92
+ ${fieldLabelStyles}
94
93
  ${fieldMessageStyles}
95
94
  `;
96
95
  static properties = {
@@ -0,0 +1,18 @@
1
+ import {
2
+ i
3
+ } from "./chunk-LGEZYFUU.js";
4
+
5
+ // src/web-components/interaction/form/field-label.ts
6
+ var fieldLabelStyles = i`
7
+ .label {
8
+ display: block;
9
+ font-family: var(--formLabel_font-family, var(--bds-font_family--body));
10
+ font-size: var(--formLabel_font-size, var(--bds-font_size--body--s));
11
+ font-weight: var(--formLabel_font-weight, var(--bds-font_weight--semibold));
12
+ color: var(--formLabel_color, var(--bds-color_on-bg));
13
+ }
14
+ `;
15
+
16
+ export {
17
+ fieldLabelStyles
18
+ };
@@ -1,3 +1,6 @@
1
+ import {
2
+ fieldLabelStyles
3
+ } from "./chunk-FYTISJN3.js";
1
4
  import {
2
5
  fieldMessageStyles,
3
6
  renderFieldMessage
@@ -38,14 +41,6 @@ var BdsSlider = class extends i2 {
38
41
  margin-block-end: var(--bds-space_xxs);
39
42
  }
40
43
 
41
- .label {
42
- display: block;
43
- font-size: var(--bds-font_size--body--s);
44
- font-family: var(--bds-font_family--body);
45
- font-weight: var(--bds-font_weight--semibold);
46
- color: var(--bds-color_on-bg);
47
- }
48
-
49
44
  .value {
50
45
  font-size: var(--bds-font_size--body--s);
51
46
  font-variant-numeric: tabular-nums;
@@ -135,6 +130,7 @@ var BdsSlider = class extends i2 {
135
130
  }
136
131
  }
137
132
 
133
+ ${fieldLabelStyles}
138
134
  ${fieldMessageStyles}
139
135
  `;
140
136
  static properties = {
@@ -33,11 +33,12 @@ var BdsRadioGroup = class extends i2 {
33
33
  }
34
34
 
35
35
  .legend {
36
- font-size: var(--bds-font_size--body--s);
37
- font-family: var(--bds-font_family--body);
38
- font-weight: var(--bds-font_weight--medium);
39
- color: var(--bds-color_on-bg);
40
- margin-block-end: var(--bds-space_xs);
36
+ padding: 0;
37
+ font-family: var(--radioGroup_legend-font-family, var(--bds-font_family--body));
38
+ font-size: var(--radioGroup_legend-font-size, var(--bds-font_size--body--s));
39
+ font-weight: var(--radioGroup_legend-font-weight, var(--bds-font_weight--medium));
40
+ color: var(--radioGroup_legend-color, var(--bds-color_on-bg));
41
+ margin-block-end: var(--radioGroup_legend-gap, var(--bds-space_xs));
41
42
  }
42
43
 
43
44
  .required {
@@ -1,3 +1,6 @@
1
+ import {
2
+ fieldLabelStyles
3
+ } from "./chunk-FYTISJN3.js";
1
4
  import {
2
5
  fieldMessageStyles,
3
6
  renderFieldMessage
@@ -32,11 +35,6 @@ var BdsNumberInput = class extends i2 {
32
35
  }
33
36
 
34
37
  .label {
35
- display: block;
36
- font-size: var(--bds-font_size--body--s);
37
- font-family: var(--bds-font_family--body);
38
- font-weight: var(--bds-font_weight--semibold);
39
- color: var(--bds-color_on-bg);
40
38
  margin-block-end: var(--bds-space_xxs);
41
39
  }
42
40
 
@@ -143,6 +141,7 @@ var BdsNumberInput = class extends i2 {
143
141
  color: var(--numberInput_stepper-color, var(--bds-color_interactive));
144
142
  }
145
143
 
144
+ ${fieldLabelStyles}
146
145
  ${fieldMessageStyles}
147
146
  `;
148
147
  static properties = {
@@ -38,11 +38,12 @@ var BdsCheckboxGroup = class extends i2 {
38
38
  }
39
39
 
40
40
  .legend {
41
- font-size: var(--bds-font_size--body--s);
42
- font-family: var(--bds-font_family--body);
43
- font-weight: var(--bds-font_weight--medium);
44
- color: var(--bds-color_on-bg);
45
- margin-block-end: var(--bds-space_xs);
41
+ padding: 0;
42
+ font-family: var(--checkboxGroup_legend-font-family, var(--bds-font_family--body));
43
+ font-size: var(--checkboxGroup_legend-font-size, var(--bds-font_size--body--s));
44
+ font-weight: var(--checkboxGroup_legend-font-weight, var(--bds-font_weight--medium));
45
+ color: var(--checkboxGroup_legend-color, var(--bds-color_on-bg));
46
+ margin-block-end: var(--checkboxGroup_legend-gap, var(--bds-space_xs));
46
47
  }
47
48
 
48
49
  .required {
@@ -1,3 +1,6 @@
1
+ import {
2
+ fieldLabelStyles
3
+ } from "./chunk-FYTISJN3.js";
1
4
  import {
2
5
  fieldMessageStyles,
3
6
  renderFieldMessage
@@ -36,11 +39,6 @@ var BdsFormInput = class extends i2 {
36
39
  }
37
40
 
38
41
  .label {
39
- display: block;
40
- font-size: var(--bds-font_size--body--s);
41
- font-family: var(--bds-font_family--body);
42
- font-weight: var(--bds-font_weight--semibold);
43
- color: var(--bds-color_on-bg);
44
42
  margin-block-end: var(--bds-space_xxs);
45
43
  }
46
44
 
@@ -126,6 +124,7 @@ var BdsFormInput = class extends i2 {
126
124
  display: none;
127
125
  }
128
126
 
127
+ ${fieldLabelStyles}
129
128
  ${fieldMessageStyles}
130
129
  `;
131
130
  static properties = {
@@ -6,22 +6,22 @@ import {
6
6
  } from "./chunk-3FSGP35V.js";
7
7
  import {
8
8
  BdsRadioGroup
9
- } from "./chunk-YLDQOESI.js";
9
+ } from "./chunk-K3VK6VEL.js";
10
10
  import {
11
11
  BdsSegmentedControl
12
12
  } from "./chunk-NTQ4TCUT.js";
13
13
  import {
14
14
  BdsSelect
15
- } from "./chunk-XJU7KITO.js";
15
+ } from "./chunk-5QA7JOC3.js";
16
16
  import {
17
17
  BdsSlider
18
- } from "./chunk-LHFUXZ52.js";
18
+ } from "./chunk-ISV56UWR.js";
19
19
  import {
20
20
  BdsSwitch
21
21
  } from "./chunk-CKCPV347.js";
22
22
  import {
23
23
  BdsTextarea
24
- } from "./chunk-EYCW7TKB.js";
24
+ } from "./chunk-7GEAT2TY.js";
25
25
  import {
26
26
  BdsGrid
27
27
  } from "./chunk-ITD2MV5K.js";
@@ -33,10 +33,10 @@ import {
33
33
  } from "./chunk-4MB2ICSK.js";
34
34
  import {
35
35
  BdsCheckboxGroup
36
- } from "./chunk-GPJWLAKU.js";
36
+ } from "./chunk-VGPJ5L6N.js";
37
37
  import {
38
38
  BdsCombobox
39
- } from "./chunk-XI2U6U26.js";
39
+ } from "./chunk-2FNCV46J.js";
40
40
  import {
41
41
  BdsFieldGroup
42
42
  } from "./chunk-SEO2F5KJ.js";
@@ -45,10 +45,11 @@ import {
45
45
  } from "./chunk-KZPRFY5P.js";
46
46
  import {
47
47
  BdsFormInput
48
- } from "./chunk-AGI6YQRC.js";
48
+ } from "./chunk-WOFGYU6E.js";
49
49
  import {
50
50
  BdsNumberInput
51
- } from "./chunk-GQNQBEYR.js";
51
+ } from "./chunk-QZMFNJSN.js";
52
+ import "./chunk-FYTISJN3.js";
52
53
  import "./chunk-SRKQ6GST.js";
53
54
  import {
54
55
  BdsDropdownMenuItem
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BdsCheckboxGroup
3
- } from "../../chunk-GPJWLAKU.js";
3
+ } from "../../chunk-VGPJ5L6N.js";
4
4
  import "../../chunk-SRKQ6GST.js";
5
5
  import "../../chunk-LGEZYFUU.js";
6
6
  export {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  BdsCombobox
3
- } from "../../chunk-XI2U6U26.js";
3
+ } from "../../chunk-2FNCV46J.js";
4
+ import "../../chunk-FYTISJN3.js";
4
5
  import "../../chunk-SRKQ6GST.js";
5
6
  import "../../chunk-LGEZYFUU.js";
6
7
  export {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  BdsFormInput
3
- } from "../../chunk-AGI6YQRC.js";
3
+ } from "../../chunk-WOFGYU6E.js";
4
+ import "../../chunk-FYTISJN3.js";
4
5
  import "../../chunk-SRKQ6GST.js";
5
6
  import "../../chunk-LGEZYFUU.js";
6
7
  export {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  BdsNumberInput
3
- } from "../../chunk-GQNQBEYR.js";
3
+ } from "../../chunk-QZMFNJSN.js";
4
+ import "../../chunk-FYTISJN3.js";
4
5
  import "../../chunk-SRKQ6GST.js";
5
6
  import "../../chunk-LGEZYFUU.js";
6
7
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BdsRadioGroup
3
- } from "../../chunk-YLDQOESI.js";
3
+ } from "../../chunk-K3VK6VEL.js";
4
4
  import "../../chunk-SRKQ6GST.js";
5
5
  import "../../chunk-LGEZYFUU.js";
6
6
  export {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  BdsSelect
3
- } from "../../chunk-XJU7KITO.js";
3
+ } from "../../chunk-5QA7JOC3.js";
4
+ import "../../chunk-FYTISJN3.js";
4
5
  import "../../chunk-SRKQ6GST.js";
5
6
  import "../../chunk-LGEZYFUU.js";
6
7
  export {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  BdsSlider
3
- } from "../../chunk-LHFUXZ52.js";
3
+ } from "../../chunk-ISV56UWR.js";
4
+ import "../../chunk-FYTISJN3.js";
4
5
  import "../../chunk-SRKQ6GST.js";
5
6
  import "../../chunk-LGEZYFUU.js";
6
7
  export {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  BdsTextarea
3
- } from "../../chunk-EYCW7TKB.js";
3
+ } from "../../chunk-7GEAT2TY.js";
4
+ import "../../chunk-FYTISJN3.js";
4
5
  import "../../chunk-SRKQ6GST.js";
5
6
  import "../../chunk-LGEZYFUU.js";
6
7
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boostdev/design-system-components",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "description": "BoostDev React component library: accessible, token-driven components built on @boostdev/design-system-foundation",
5
5
  "keywords": [
6
6
  "React",
@@ -31,7 +31,7 @@ export function Checkbox({ label, name, error, hint, className, ...props }: Chec
31
31
  name={name}
32
32
  className={cn(css.checkbox, error && css.checkboxError)}
33
33
  />
34
- <Label id={id} label={label} />
34
+ <Label id={id} label={label} variant="option" />
35
35
  </div>
36
36
  <Message inputId={id} type="error" message={error} />
37
37
  <Message inputId={id} type="hint" message={hint} />
@@ -46,7 +46,7 @@ All public override tokens. Set on the CheckboxGroup or any ancestor; they casca
46
46
  | `--checkboxGroup_items-gap` | `var(--bds-space_xs)` | Gap between the child checkboxes. |
47
47
  | `--checkboxGroup_legend-color` | `var(--bds-color_on-bg)` | Legend text colour. |
48
48
  | `--checkboxGroup_legend-font-family` | `var(--bds-font_family--body)` | Legend font family. |
49
- | `--checkboxGroup_legend-font-size` | `var(--bds-font_size--body)` | Legend font size, the same as the labels of the other fields. |
49
+ | `--checkboxGroup_legend-font-size` | `var(--bds-font_size--body--s)` | Legend font size, the same as the labels of the other fields. |
50
50
  | `--checkboxGroup_legend-font-weight` | `var(--bds-font_weight--medium)` | Legend font weight. |
51
51
  | `--checkboxGroup_legend-gap` | `var(--bds-space_xs)` | Space below the legend before the items. |
52
52
  | `--checkboxGroup_required-color` | `var(--bds-color_error)` | Colour of the visible `*` required marker. |
@@ -10,7 +10,7 @@
10
10
 
11
11
  .legend {
12
12
  font-family: var(--checkboxGroup_legend-font-family, var(--bds-font_family--body));
13
- font-size: var(--checkboxGroup_legend-font-size, var(--bds-font_size--body));
13
+ font-size: var(--checkboxGroup_legend-font-size, var(--bds-font_size--body--s));
14
14
  font-weight: var(--checkboxGroup_legend-font-weight, var(--bds-font_weight--medium));
15
15
  color: var(--checkboxGroup_legend-color, var(--bds-color_on-bg));
16
16
  padding: 0;
@@ -139,6 +139,6 @@ describe('CheckboxGroup', () => {
139
139
 
140
140
  it('sizes the legend like the labels of the other fields', () => {
141
141
  const css = readFileSync(resolve(process.cwd(), 'src/components/interaction/form/CheckboxGroup/CheckboxGroup.module.css'), 'utf8');
142
- expect(css).toMatch(/\.legend \{[^}]*font-size:\s*var\(--checkboxGroup_legend-font-size,\s*var\(--bds-font_size--body\)\)/);
142
+ expect(css).toMatch(/\.legend \{[^}]*font-size:\s*var\(--checkboxGroup_legend-font-size,\s*var\(--bds-font_size--body--s\)\)/);
143
143
  });
144
144
  });
@@ -57,6 +57,8 @@ Searchable select with type-ahead filtering. Combines a text input with a dropdo
57
57
  </tbody>
58
58
  </table>
59
59
 
60
+ The label above the field reads the shared label hooks (`--formLabel_*`: font-family, font-size, font-weight, color), listed on FormInput.
61
+
60
62
 
61
63
  ## Accessibility
62
64
 
@@ -43,6 +43,10 @@ Text input field with label, optional hint, and error state. The label and input
43
43
  <tr><td>`--formInput_border`</td><td>`none`</td><td>Border</td></tr>
44
44
  <tr><td>`--formInput_radius`</td><td>`var(--bds-border_radius--full)`</td><td>Corner radius</td></tr>
45
45
  <tr><td>`--formInput_shadow`</td><td>`var(--bdc-outline_shadow)`</td><td>Box shadow</td></tr>
46
+ <tr><td>`--formLabel_font-family`</td><td>`var(--bds-font_family--body)`</td><td>Font family of the label above the field (shared by all form controls with a label above the field)</td></tr>
47
+ <tr><td>`--formLabel_font-size`</td><td>`var(--bds-font_size--body--s)`</td><td>Label font size</td></tr>
48
+ <tr><td>`--formLabel_font-weight`</td><td>`var(--bds-font_weight--semibold)`</td><td>Label font weight</td></tr>
49
+ <tr><td>`--formLabel_color`</td><td>`var(--bds-color_on-bg)`</td><td>Label colour</td></tr>
46
50
  <tr><td>`--formMessage_font-size`</td><td>`var(--bds-font_size--body--s)`</td><td>Font size of the error and hint message (shared by all form controls)</td></tr>
47
51
  <tr><td>`--formMessage_gap`</td><td>`var(--bds-space_xxs)`</td><td>Gap between the error icon and the error text</td></tr>
48
52
  <tr><td>`--formMessage_icon-size`</td><td>`1.15em`</td><td>Size of the error icon</td></tr>
@@ -53,6 +53,8 @@ Numeric text input with increment/decrement stepper buttons. Enforces `min`, `ma
53
53
  </tbody>
54
54
  </table>
55
55
 
56
+ The label above the field reads the shared label hooks (`--formLabel_*`: font-family, font-size, font-weight, color), listed on FormInput.
57
+
56
58
 
57
59
  ## Accessibility
58
60
 
@@ -35,7 +35,7 @@ export function Radio({ label, name, description, error, hint, className, id: co
35
35
  {...props}
36
36
  />
37
37
  <div className={css.textWrapper}>
38
- <Label id={id} label={label} />
38
+ <Label id={id} label={label} variant="option" />
39
39
  {description && (
40
40
  <span id={descriptionId} className={css.description}>
41
41
  {description}
@@ -46,7 +46,7 @@ All public override tokens. Set on the RadioGroup or any ancestor; they cascade.
46
46
  | `--radioGroup_items-gap` | `var(--bds-space_xs)` | Gap between the child radios. |
47
47
  | `--radioGroup_legend-color` | `var(--bds-color_on-bg)` | Legend text colour. |
48
48
  | `--radioGroup_legend-font-family` | `var(--bds-font_family--body)` | Legend font family. |
49
- | `--radioGroup_legend-font-size` | `var(--bds-font_size--body)` | Legend font size, the same as the labels of the other fields. |
49
+ | `--radioGroup_legend-font-size` | `var(--bds-font_size--body--s)` | Legend font size, the same as the labels of the other fields. |
50
50
  | `--radioGroup_legend-font-weight` | `var(--bds-font_weight--medium)` | Legend font weight. |
51
51
  | `--radioGroup_legend-gap` | `var(--bds-space_xs)` | Space below the legend before the items. |
52
52
  | `--radioGroup_required-color` | `var(--bds-color_error)` | Colour of the visible `*` required marker. |
@@ -10,7 +10,7 @@
10
10
 
11
11
  .legend {
12
12
  font-family: var(--radioGroup_legend-font-family, var(--bds-font_family--body));
13
- font-size: var(--radioGroup_legend-font-size, var(--bds-font_size--body));
13
+ font-size: var(--radioGroup_legend-font-size, var(--bds-font_size--body--s));
14
14
  font-weight: var(--radioGroup_legend-font-weight, var(--bds-font_weight--medium));
15
15
  color: var(--radioGroup_legend-color, var(--bds-color_on-bg));
16
16
  padding: 0;
@@ -127,6 +127,6 @@ describe('RadioGroup', () => {
127
127
 
128
128
  it('sizes the legend like the labels of the other fields', () => {
129
129
  const css = readFileSync(resolve(process.cwd(), 'src/components/interaction/form/RadioGroup/RadioGroup.module.css'), 'utf8');
130
- expect(css).toMatch(/\.legend \{[^}]*font-size:\s*var\(--radioGroup_legend-font-size,\s*var\(--bds-font_size--body\)\)/);
130
+ expect(css).toMatch(/\.legend \{[^}]*font-size:\s*var\(--radioGroup_legend-font-size,\s*var\(--bds-font_size--body--s\)\)/);
131
131
  });
132
132
  });
@@ -56,6 +56,8 @@ Native dropdown for choosing one option from a list. Renders a styled `<select>`
56
56
  </tbody>
57
57
  </table>
58
58
 
59
+ The label above the field reads the shared label hooks (`--formLabel_*`: font-family, font-size, font-weight, color), listed on FormInput.
60
+
59
61
 
60
62
  ## Accessibility
61
63
 
@@ -56,6 +56,8 @@ Range input for selecting a numeric value within a bounded range.
56
56
  </tbody>
57
57
  </table>
58
58
 
59
+ The label above the field reads the shared label hooks (`--formLabel_*`: font-family, font-size, font-weight, color), listed on FormInput.
60
+
59
61
 
60
62
  ## Accessibility
61
63
 
@@ -49,7 +49,7 @@ export function Switch({
49
49
  <span className={css.thumb} />
50
50
  </span>
51
51
  </div>
52
- <Label id={id} label={label} />
52
+ <Label id={id} label={label} variant="option" />
53
53
  </div>
54
54
  <Message inputId={id} type="error" message={error} />
55
55
  <Message inputId={id} type="hint" message={hint} />
@@ -55,6 +55,8 @@ Multi-line text input with label, hint, and error support.
55
55
  </tbody>
56
56
  </table>
57
57
 
58
+ The label above the field reads the shared label hooks (`--formLabel_*`: font-family, font-size, font-weight, color), listed on FormInput.
59
+
58
60
 
59
61
  ## Accessibility
60
62
 
@@ -6,4 +6,14 @@
6
6
  color: var(--bds-color_on-bg);
7
7
  cursor: pointer;
8
8
  }
9
+
10
+ /* The label above a field. Same hooks and defaults as the web component
11
+ field labels (fieldLabelStyles in web-components/interaction/form/field-label.ts),
12
+ so a React form and a bds-* form look the same. */
13
+ .--field {
14
+ font-family: var(--formLabel_font-family, var(--bds-font_family--body));
15
+ font-size: var(--formLabel_font-size, var(--bds-font_size--body--s));
16
+ font-weight: var(--formLabel_font-weight, var(--bds-font_weight--semibold));
17
+ color: var(--formLabel_color, var(--bds-color_on-bg));
18
+ }
9
19
  }
@@ -0,0 +1,48 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { Label } from './Label';
3
+ import { FormInput } from '../FormInput';
4
+ import { Select } from '../Select';
5
+ import { Checkbox } from '../Checkbox';
6
+ import { Radio } from '../Radio';
7
+ import { Switch } from '../Switch';
8
+
9
+ describe('Label', () => {
10
+ it('labels the control with the given id', () => {
11
+ render(<Label id="email" label="Email" />);
12
+ expect(screen.getByText('Email').getAttribute('for')).toBe('email');
13
+ });
14
+
15
+ it('uses the field look by default', () => {
16
+ render(<Label id="email" label="Email" />);
17
+ expect(screen.getByText('Email').className).toContain('--field');
18
+ });
19
+
20
+ it('drops the field look for an option label', () => {
21
+ render(<Label id="terms" label="Accept terms" variant="option" />);
22
+ expect(screen.getByText('Accept terms').className).not.toContain('--field');
23
+ });
24
+
25
+ it('gives field labels the field look', () => {
26
+ render(
27
+ <>
28
+ <FormInput label="Email" name="email" />
29
+ <Select label="Country" name="country" options={[{ value: 'nl', label: 'Netherlands' }]} />
30
+ </>
31
+ );
32
+ expect(screen.getByText('Email').className).toContain('--field');
33
+ expect(screen.getByText('Country').className).toContain('--field');
34
+ });
35
+
36
+ it('keeps checkbox, radio and switch labels on the option look', () => {
37
+ render(
38
+ <>
39
+ <Checkbox label="Accept terms" name="terms" />
40
+ <Radio label="Pick up" name="delivery" value="pickup" />
41
+ <Switch label="Notifications" name="notifications" />
42
+ </>
43
+ );
44
+ ['Accept terms', 'Pick up', 'Notifications'].forEach(text =>
45
+ expect(screen.getByText(text).className).not.toContain('--field')
46
+ );
47
+ });
48
+ });
@@ -22,12 +22,15 @@ export const Required: Story = {
22
22
  },
23
23
  };
24
24
 
25
+ export const Option: Story = { args: { id: 'input-option', label: 'Accept the terms', variant: 'option' } };
26
+
25
27
  export const AllVariants: Story = {
26
28
  render: () => (
27
29
  <div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
28
30
  <Label id="a" label="Plain label" />
29
31
  <Label id="b" label="Label for a text input" />
30
32
  <Label id="c" label={<><strong>Bold</strong> label with markup</>} />
33
+ <Label id="d" label="Option label beside a checkbox" variant="option" />
31
34
  </div>
32
35
  ),
33
36
  };
@@ -6,11 +6,13 @@ import type { WithClassName } from '../../../../types';
6
6
  interface LabelProps extends WithClassName {
7
7
  id: string;
8
8
  label: ReactNode;
9
+ /** `field` is the label above a control, `option` the text beside a checkbox, radio or switch. */
10
+ variant?: 'field' | 'option';
9
11
  }
10
12
 
11
- export const Label = ({ label, id, className }: LabelProps) => {
13
+ export const Label = ({ label, id, className, variant = 'field' }: LabelProps) => {
12
14
  return (
13
- <label htmlFor={id} className={cn(css.label, className)}>
15
+ <label htmlFor={id} className={cn(css.label, variant === 'field' && css['--field'], className)}>
14
16
  {label}
15
17
  </label>
16
18
  );
@@ -53,6 +53,20 @@ Use `<bds-checkbox-group>` when you have multiple related checkboxes that belong
53
53
  |-------------|-----------------------------------|
54
54
  | `(default)` | `<bds-checkbox>` elements |
55
55
 
56
+ ## Overridable CSS custom properties
57
+
58
+ Legend hooks mirror the React `CheckboxGroup` (same names and defaults), so a theme carries over between the two implementations. Set them on the group or any ancestor.
59
+
60
+ | Variable | Default | Description |
61
+ |----------|---------|-------------|
62
+ | `--checkboxGroup_legend-color` | `var(--bds-color_on-bg)` | Legend text colour. |
63
+ | `--checkboxGroup_legend-font-family` | `var(--bds-font_family--body)` | Legend font family. |
64
+ | `--checkboxGroup_legend-font-size` | `var(--bds-font_size--body--s)` | Legend font size, the same as the field labels (`--formLabel_font-size`). |
65
+ | `--checkboxGroup_legend-font-weight` | `var(--bds-font_weight--medium)` | Legend font weight. |
66
+ | `--checkboxGroup_legend-gap` | `var(--bds-space_xs)` | Space below the legend before the items. |
67
+
68
+ Style slotted `<bds-checkbox>` elements via their own tokens.
69
+
56
70
  ## Usage in plain HTML
57
71
 
58
72
  ```html
@@ -96,6 +96,10 @@ _None._
96
96
  ></bds-combobox>
97
97
  ```
98
98
 
99
+ ## Label
100
+
101
+ The `label` reads the shared label hooks (`--formLabel_*`: font-family, font-size, font-weight, color), listed on `<bds-form-input>`. The React field labels use the same hooks and defaults.
102
+
99
103
  ## Error state
100
104
 
101
105
  With `error`, the message gets a warning icon and the field ring widens to `--bdc-outline_width--error` (2px). Message hooks (`--formMessage_*`: font-size, gap, icon-size, color--error, font-weight--error, color--hint, font-style--hint) are listed on `<bds-form-input>`.
@@ -88,6 +88,10 @@ Token names mirror the React `FormInput` component so themes carry over between
88
88
  | `--formInput_border` | `none` | Border (layered on top of the inset focus/error ring) |
89
89
  | `--formInput_radius` | `var(--bds-border_radius--full)` | Corner radius |
90
90
  | `--formInput_shadow` | `var(--bdc-outline_shadow)` | Box shadow |
91
+ | `--formLabel_font-family` | `var(--bds-font_family--body)` | Font family of the label above the field (shared by all form controls with a label above the field) |
92
+ | `--formLabel_font-size` | `var(--bds-font_size--body--s)` | Label font size |
93
+ | `--formLabel_font-weight` | `var(--bds-font_weight--semibold)` | Label font weight |
94
+ | `--formLabel_color` | `var(--bds-color_on-bg)` | Label colour |
91
95
  | `--formMessage_font-size` | `var(--bds-font_size--body--s)` | Font size of the error and hint message (shared by all form controls) |
92
96
  | `--formMessage_gap` | `var(--bds-space_xxs)` | Gap between the error icon and the error text |
93
97
  | `--formMessage_icon-size` | `1.15em` | Size of the error icon |
@@ -73,6 +73,10 @@ Use `<bds-number-input>` for quantity selectors, counters, or any numeric field
73
73
  <bds-number-input name="qty" label="Quantity" value="1" min="0" max="99" step="1"></bds-number-input>
74
74
  ```
75
75
 
76
+ ## Label
77
+
78
+ The `label` reads the shared label hooks (`--formLabel_*`: font-family, font-size, font-weight, color), listed on `<bds-form-input>`. The React field labels use the same hooks and defaults.
79
+
76
80
  ## Error state
77
81
 
78
82
  With `error`, the message gets a warning icon and the field ring widens to `--bdc-outline_width--error` (2px). Message hooks (`--formMessage_*`: font-size, gap, icon-size, color--error, font-weight--error, color--hint, font-style--hint) are listed on `<bds-form-input>`.