@brightspace-ui/core 3.121.0 → 3.122.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.
- package/components/inputs/README.md +2 -2
- package/components/inputs/docs/input-checkbox.md +47 -63
- package/components/inputs/docs/input-radio.md +65 -110
- package/components/inputs/docs/styling-native-inputs.md +153 -0
- package/components/inputs/input-radio-group.js +1 -1
- package/custom-elements.json +2 -2
- package/package.json +1 -1
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
There are various input components available:
|
4
4
|
|
5
|
-
- [
|
5
|
+
- [Checkbox Input (input-checkbox*)](docs/input-checkbox.md)
|
6
6
|
- [Color Input (input-color)](docs/input-color.md)
|
7
7
|
- [Date & Time Inputs (input-date, input-time, input-date-time)](docs/input-date-time.md)
|
8
8
|
- [Numeric Inputs (input-number, input-percent)](docs/input-numeric.md)
|
9
|
-
- [Radio
|
9
|
+
- [Radio Inputs (input-radio-*)](docs/input-radio.md)
|
10
10
|
- [Search (input-search)](docs/input-search.md)
|
11
11
|
- [Select Lists (input-select-styles)](docs/input-select-styles.md)
|
12
12
|
- [Text (input-text, input-styles, input-textarea)](docs/input-text.md)
|
@@ -1,51 +1,78 @@
|
|
1
|
-
#
|
1
|
+
# Checkbox Input
|
2
2
|
|
3
|
-
Checkboxes are used in forms to toggle an option or preference.
|
3
|
+
Checkboxes are used in forms to toggle an option or preference. They may be grouped to form a set of options.
|
4
4
|
|
5
|
-
<!-- docs: demo -->
|
5
|
+
<!-- docs: demo display:block -->
|
6
6
|
```html
|
7
7
|
<script type="module">
|
8
8
|
import '@brightspace-ui/core/components/inputs/input-checkbox.js';
|
9
|
+
import '@brightspace-ui/core/components/inputs/input-checkbox-group.js';
|
9
10
|
</script>
|
10
|
-
<d2l-input-checkbox label="
|
11
|
+
<d2l-input-checkbox-group label="Toppings">
|
12
|
+
<d2l-input-checkbox label="Ketchup" checked></d2l-input-checkbox>
|
13
|
+
<d2l-input-checkbox label="Mustard"></d2l-input-checkbox>
|
14
|
+
<d2l-input-checkbox label="Relish"></d2l-input-checkbox>
|
15
|
+
</d2l-input-checkbox-group>
|
11
16
|
```
|
12
17
|
|
13
18
|
## Best Practices
|
14
19
|
<!-- docs: start best practices -->
|
15
20
|
<!-- docs: start dos -->
|
16
|
-
* Use in a form to indicate an option or preference
|
21
|
+
* Use in a form to indicate an option or preference
|
17
22
|
* Use to allow the user to select multiple, independent options from a set
|
23
|
+
* When multiple options are presented together, [wrap them in a group](#d2l-input-checkbox-group)
|
18
24
|
* Use an indeterminate state to indicate a mixed state where some child items are checked and some are not
|
19
|
-
* Use as progressive disclosure in forms, so long as users are made aware both visually and non-visually that new options have been made available
|
25
|
+
* Use as progressive disclosure in forms, so long as users are made aware both visually and non-visually that new options have been made available
|
20
26
|
<!-- docs: end dos -->
|
21
27
|
|
22
28
|
<!-- docs: start donts -->
|
23
|
-
* Don't use as a toggle that performs an immediate action, use a Switch component
|
24
|
-
* Don't use for mutually exclusive options, use radio
|
29
|
+
* Don't use as a toggle that performs an immediate action, use a Switch component
|
30
|
+
* Don't use for mutually exclusive options, use radio input groups
|
25
31
|
* Don't use labels as “instructions” or “phrases”. Good label: “Visible to Students”. Bad label: (“Check this to make it visible to students”)
|
26
32
|
* Don't use labels to describe the default or “off” state of the option. As much as possible, use the label to refer to the “on” state. Good label: “Visible”. Bad label: “Hidden”.
|
27
33
|
<!-- docs: end donts -->
|
28
34
|
<!-- docs: end best practices -->
|
29
35
|
|
36
|
+
## Checkbox Input Group [d2l-input-checkbox-group]
|
37
|
+
|
38
|
+
When multiple checkboxes are displayed together, wrap them in a `<d2l-input-checkbox-group>`.
|
39
|
+
|
40
|
+
This will not only provide consistent spacing between checkboxes, but the group also internally renders a `<fieldset>` and `<legend>` with the provided `label`, which gives additional accessibility context. The label can be hidden visually if desired.
|
41
|
+
|
42
|
+
<!-- docs: demo code properties name:d2l-input-checkbox-group sandboxTitle:'Checkbox Group' display:block -->
|
43
|
+
```html
|
44
|
+
<script type="module">
|
45
|
+
import '@brightspace-ui/core/components/inputs/input-checkbox.js';
|
46
|
+
import '@brightspace-ui/core/components/inputs/input-checkbox-group.js';
|
47
|
+
</script>
|
48
|
+
<d2l-input-checkbox-group label="Toppings">
|
49
|
+
<d2l-input-checkbox label="Ketchup"></d2l-input-checkbox>
|
50
|
+
<d2l-input-checkbox label="Mustard"></d2l-input-checkbox>
|
51
|
+
<d2l-input-checkbox label="Relish"></d2l-input-checkbox>
|
52
|
+
</d2l-input-checkbox-group>
|
53
|
+
```
|
54
|
+
|
55
|
+
<!-- docs: start hidden content -->
|
56
|
+
### Properties
|
57
|
+
|
58
|
+
| Property | Type | Description |
|
59
|
+
|---|---|---|
|
60
|
+
| `label` | String, required | Label for the group of checkboxes |
|
61
|
+
| `label-hidden` | Boolean | Hides the label visually |
|
62
|
+
<!-- docs: end hidden content -->
|
63
|
+
|
30
64
|
## Checkbox Input [d2l-input-checkbox]
|
31
65
|
|
32
|
-
The `<d2l-input-checkbox>` element can be used
|
66
|
+
The `<d2l-input-checkbox>` element can be used on its own or as an option within a `<d2l-input-checkbox-group>` collection. It will display a checkbox and optional visible label.
|
67
|
+
|
68
|
+
When provided with a `name`, the checkbox will participate in forms if it is `checked` and enabled.
|
33
69
|
|
34
70
|
<!-- docs: demo code properties name:d2l-input-checkbox sandboxTitle:'Checkbox Input' display:block -->
|
35
71
|
```html
|
36
72
|
<script type="module">
|
37
73
|
import '@brightspace-ui/core/components/inputs/input-checkbox.js';
|
38
|
-
|
39
|
-
window.addEventListener('load', () => {
|
40
|
-
document.querySelector('d2l-input-checkbox')
|
41
|
-
.addEventListener('change', e => {
|
42
|
-
console.log('checked value: ', e.target.checked);
|
43
|
-
});
|
44
|
-
});
|
45
74
|
</script>
|
46
|
-
<
|
47
|
-
<d2l-input-checkbox label="Label for checkbox"></d2l-input-checkbox>
|
48
|
-
</div>
|
75
|
+
<d2l-input-checkbox label="Label for checkbox"></d2l-input-checkbox>
|
49
76
|
```
|
50
77
|
|
51
78
|
<!-- docs: start hidden content -->
|
@@ -59,7 +86,7 @@ The `<d2l-input-checkbox>` element can be used to get a checkbox and optional vi
|
|
59
86
|
| `indeterminate` | Boolean | Sets checkbox to an indeterminate state |
|
60
87
|
| `label` | String, required | Label for the input |
|
61
88
|
| `label-hidden` | Boolean | Hides the label visually (moves it to the input's `aria-label` attribute) |
|
62
|
-
| `name` | String | Name of the
|
89
|
+
| `name` | String | Name of the form control. Submitted with the form as part of a name/value pair. |
|
63
90
|
| `not-tabbable` | Boolean | Sets `tabindex="-1"` on the checkbox. Note that an alternative method of focusing is necessary to implement if using this property. |
|
64
91
|
| `value` | String | Value of the input |
|
65
92
|
|
@@ -79,49 +106,6 @@ checkbox.addEventListener('change', e => {
|
|
79
106
|
* `supporting`: Supporting information which will appear below and be aligned with the checkbox.
|
80
107
|
<!-- docs: end hidden content -->
|
81
108
|
|
82
|
-
### Groups of Checkboxes
|
83
|
-
|
84
|
-
If multiple checkboxes are displayed together, wrapping them in a `<d2l-input-checkbox-group>` provides consistent spacing between each checkbox.
|
85
|
-
|
86
|
-
<!-- docs: demo code -->
|
87
|
-
```html
|
88
|
-
<script type="module">
|
89
|
-
import '@brightspace-ui/core/components/inputs/input-checkbox.js';
|
90
|
-
import '@brightspace-ui/core/components/inputs/input-checkbox-group.js';
|
91
|
-
</script>
|
92
|
-
<d2l-input-checkbox-group label="Toppings">
|
93
|
-
<d2l-input-checkbox label="Ketchup"></d2l-input-checkbox>
|
94
|
-
<d2l-input-checkbox label="Mustard"></d2l-input-checkbox>
|
95
|
-
<d2l-input-checkbox label="Relish"></d2l-input-checkbox>
|
96
|
-
</d2l-input-checkbox-group>
|
97
|
-
```
|
98
|
-
|
99
|
-
## Applying styles to native checkboxes
|
100
|
-
|
101
|
-
As an alternative to using the `<d2l-input-checkbox>` custom element, you can style a native checkbox inside your own element. Import `input-checkbox-styles.js` and apply the `d2l-input-checkbox` CSS class to the input:
|
102
|
-
|
103
|
-
<!-- docs: demo code display:block -->
|
104
|
-
```html
|
105
|
-
<script type="module">
|
106
|
-
import { html, LitElement } from 'lit';
|
107
|
-
import { checkboxStyles } from '@brightspace-ui/core/components/inputs/input-checkbox.js';
|
108
|
-
|
109
|
-
class MyCheckboxElem extends LitElement {
|
110
|
-
|
111
|
-
static get styles() {
|
112
|
-
return checkboxStyles;
|
113
|
-
}
|
114
|
-
|
115
|
-
render() {
|
116
|
-
return html`<input type="checkbox" class="d2l-input-checkbox">`;
|
117
|
-
}
|
118
|
-
|
119
|
-
}
|
120
|
-
customElements.define('d2l-my-checkbox-elem', MyCheckboxElem);
|
121
|
-
</script>
|
122
|
-
<d2l-my-checkbox-elem></d2l-my-checkbox-elem>
|
123
|
-
```
|
124
|
-
|
125
109
|
## Accessibility
|
126
110
|
|
127
111
|
The `d2l-input-checkbox` component follows W3C's best practice recommendations for a [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/). This means that the component works in the following way:
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# Radio
|
1
|
+
# Radio Inputs
|
2
2
|
|
3
|
-
Radio
|
3
|
+
Radio inputs are used in forms to offer a single choice among mutually exclusive options.
|
4
4
|
|
5
5
|
<!-- docs: demo display:block -->
|
6
6
|
```html
|
@@ -15,11 +15,6 @@ Radio Buttons are used in forms to offer a single choice among mutually exclusiv
|
|
15
15
|
</d2l-input-radio-group>
|
16
16
|
```
|
17
17
|
|
18
|
-
Unlike checkboxes, individual radio buttons cannot be placed in a custom element. Items belonging to a radio group cannot span across different shadow roots -- all radios in the same group must be in the same shadow root.
|
19
|
-
|
20
|
-
As a result, we have to apply styles to native radio inputs.
|
21
|
-
|
22
|
-
|
23
18
|
## Best Practices
|
24
19
|
<!-- docs: start best practices -->
|
25
20
|
<!-- docs: start dos -->
|
@@ -28,127 +23,87 @@ As a result, we have to apply styles to native radio inputs.
|
|
28
23
|
<!-- docs: end dos -->
|
29
24
|
|
30
25
|
<!-- docs: start donts -->
|
31
|
-
* Don’t use two radio
|
32
|
-
* Don’t use for triggering an immediate action. Notable exceptions are forms that autosave with clear indication and as a trigger for progressive disclosure on traditional forms, so long as users are made aware that new options have been made available
|
26
|
+
* Don’t use two radio inputs if a single checkbox works better
|
27
|
+
* Don’t use for triggering an immediate action. Notable exceptions are forms that autosave with clear indication and as a trigger for progressive disclosure on traditional forms, so long as users are made aware that new options have been made available.
|
33
28
|
<!-- docs: end donts -->
|
34
29
|
<!-- docs: end best practices -->
|
35
30
|
|
36
|
-
## Radio
|
31
|
+
## Radio Input Group [d2l-input-radio-group]
|
37
32
|
|
38
|
-
The
|
33
|
+
The group is a required parent of `<d2l-input-radio>`. It internally renders a `<fieldset>` and `<legend>` with the provided `label`, which gives additional accessibility context. The label can be hidden visually if desired.
|
39
34
|
|
40
|
-
|
35
|
+
When provided with a `name`, the group will participate in forms with the `value` of the currently checked input.
|
41
36
|
|
42
|
-
<!-- docs: demo code display:block -->
|
37
|
+
<!-- docs: demo code properties name:d2l-input-radio-group sandboxTitle:'Checkbox Group' display:block -->
|
43
38
|
```html
|
44
39
|
<script type="module">
|
45
|
-
import
|
46
|
-
import
|
47
|
-
|
48
|
-
class MyRadioElem extends LitElement {
|
49
|
-
|
50
|
-
static get styles() {
|
51
|
-
return radioStyles;
|
52
|
-
}
|
53
|
-
|
54
|
-
render() {
|
55
|
-
return html`
|
56
|
-
<label class="d2l-input-radio-label">
|
57
|
-
<input type="radio" name="myGroup" checked>
|
58
|
-
Option 1 (selected)
|
59
|
-
</label>
|
60
|
-
<label class="d2l-input-radio-label d2l-input-radio-label-disabled">
|
61
|
-
<input type="radio" name="myGroup" disabled>
|
62
|
-
Option 2 (disabled)
|
63
|
-
</label>
|
64
|
-
<label class="d2l-input-radio-label">
|
65
|
-
<input type="radio" name="myGroup">
|
66
|
-
Option 3
|
67
|
-
</label>
|
68
|
-
`;
|
69
|
-
}
|
70
|
-
|
71
|
-
}
|
72
|
-
customElements.define('d2l-my-radio-elem', MyRadioElem);
|
40
|
+
import '@brightspace-ui/core/components/inputs/input-radio.js';
|
41
|
+
import '@brightspace-ui/core/components/inputs/input-radio-group.js';
|
73
42
|
</script>
|
74
|
-
<d2l-
|
43
|
+
<d2l-input-radio-group label="Bread" name="bread">
|
44
|
+
<d2l-input-radio label="Whole wheat" name="whole-wheat" checked></d2l-input-radio>
|
45
|
+
<d2l-input-radio label="Baguette" name="baguette"></d2l-input-radio>
|
46
|
+
<d2l-input-radio label="Marble Rye" name="marble-rye"></d2l-input-radio>
|
47
|
+
</d2l-input-radio-group>
|
75
48
|
```
|
76
49
|
|
77
|
-
|
50
|
+
<!-- docs: start hidden content -->
|
51
|
+
### Properties
|
78
52
|
|
79
|
-
|
53
|
+
| Property | Type | Description |
|
54
|
+
|---|---|---|
|
55
|
+
| `label` | String, required | Label for the group of radio inputs |
|
56
|
+
| `label-hidden` | Boolean | Hides the label visually |
|
57
|
+
| `name` | String | Name of the form control. Submitted with the form as part of a name/value pair. |
|
58
|
+
| `required` | Boolean | Indicates that a value is required |
|
80
59
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
return {
|
91
|
-
checked: { type: Boolean },
|
92
|
-
disabled: { type: Boolean },
|
93
|
-
invalid: { type: Boolean }
|
94
|
-
};
|
95
|
-
}
|
96
|
-
|
97
|
-
static get styles() {
|
98
|
-
return radioStyles;
|
99
|
-
}
|
100
|
-
|
101
|
-
render() {
|
102
|
-
const invalid = this.invalid ? 'true' : 'false';
|
103
|
-
return html`
|
104
|
-
<input
|
105
|
-
aria-invalid="${invalid}"
|
106
|
-
aria-label="Option 1"
|
107
|
-
?checked="${this.checked}"
|
108
|
-
class="d2l-input-radio"
|
109
|
-
?disabled="${this.disabled}"
|
110
|
-
type="radio">
|
111
|
-
`;
|
112
|
-
}
|
113
|
-
|
114
|
-
}
|
115
|
-
customElements.define('d2l-test-input-radio-solo', MyRadioElem);
|
116
|
-
</script>
|
117
|
-
<d2l-test-input-radio-solo></d2l-test-input-radio-solo>
|
60
|
+
### Events
|
61
|
+
|
62
|
+
When the radio group's state changes, it dispatches the `change` event:
|
63
|
+
|
64
|
+
```javascript
|
65
|
+
checkbox.addEventListener('change', e => {
|
66
|
+
const newValue = e.target.detail.value;
|
67
|
+
const oldValue = e.target.detail.oldValue; // may be undefined
|
68
|
+
});
|
118
69
|
```
|
70
|
+
<!-- docs: end hidden content -->
|
119
71
|
|
120
|
-
## Radio
|
72
|
+
## Radio Input [d2l-input-radio]
|
121
73
|
|
122
|
-
|
74
|
+
The `<d2l-input-radio>` element represents an option within its parent `<d2l-input-radio-group>`.
|
123
75
|
|
124
|
-
<!-- docs: demo code display:block -->
|
76
|
+
<!-- docs: demo code properties name:d2l-input-radio sandboxTitle:'Radio Input' display:block -->
|
125
77
|
```html
|
126
78
|
<script type="module">
|
127
|
-
import '@brightspace-ui/core/components/inputs/input-radio
|
128
|
-
import
|
129
|
-
import { inlineHelpStyles } from '@brightspace-ui/core/components/inputs/input-inline-help.js';
|
130
|
-
import { radioStyles } from '@brightspace-ui/core/components/inputs/input-radio-styles.js';
|
131
|
-
|
132
|
-
class MyRadioElem extends LitElement {
|
133
|
-
|
134
|
-
static get styles() {
|
135
|
-
return [ radioStyles, inlineHelpStyles ];
|
136
|
-
}
|
137
|
-
|
138
|
-
render() {
|
139
|
-
return html`
|
140
|
-
<label class="d2l-input-radio-label">
|
141
|
-
<input type="radio" aria-describedby="desc1" value="normal" checked>
|
142
|
-
Option 1
|
143
|
-
</label>
|
144
|
-
<d2l-input-radio-spacer id="desc1" class="d2l-input-inline-help">
|
145
|
-
Additional content can go here and will line up nicely with the edge of the radio.
|
146
|
-
</d2l-input-radio-spacer>
|
147
|
-
`;
|
148
|
-
}
|
149
|
-
|
150
|
-
}
|
151
|
-
customElements.define('d2l-my-radio-spacer-elem', MyRadioElem);
|
79
|
+
import '@brightspace-ui/core/components/inputs/input-radio.js';
|
80
|
+
import '@brightspace-ui/core/components/inputs/input-radio-group.js';
|
152
81
|
</script>
|
153
|
-
<d2l-
|
82
|
+
<d2l-input-radio-group label="Bread" name="bread">
|
83
|
+
<d2l-input-radio label="Whole wheat" name="whole-wheat" checked></d2l-input-radio>
|
84
|
+
<d2l-input-radio label="Baguette" name="baguette"></d2l-input-radio>
|
85
|
+
<d2l-input-radio label="Marble Rye" name="marble-rye"></d2l-input-radio>
|
86
|
+
</d2l-input-radio-group>
|
154
87
|
```
|
88
|
+
|
89
|
+
<!-- docs: start hidden content -->
|
90
|
+
### Properties
|
91
|
+
|
92
|
+
| Property | Type | Description |
|
93
|
+
|---|---|---|
|
94
|
+
| `label` | String, required | Label for the input |
|
95
|
+
| `checked` | Boolean | Checked state |
|
96
|
+
| `description` | String | Additional information communicated to screenreader users when focusing on the input |
|
97
|
+
| `disabled` | Boolean | Disables the input |
|
98
|
+
| `supporting-hidden-when-unchecked` | Boolean | Hides the supporting slot when unchecked |
|
99
|
+
| `value` | String | Value of the input |
|
100
|
+
|
101
|
+
### Slots
|
102
|
+
|
103
|
+
* `inline-help`: Help text that will appear below the input. Use this only when other helpful cues are not sufficient, such as a carefully-worded label.
|
104
|
+
* `supporting`: Supporting information which will appear below and be aligned with the input.
|
105
|
+
<!-- docs: end hidden content -->
|
106
|
+
|
107
|
+
## Accessibility
|
108
|
+
|
109
|
+
The `d2l-input-radio-group` and `d2l-input-radio` components follow W3C's best practice recommendations for a [radio group](https://www.w3.org/WAI/ARIA/apg/patterns/radio/).
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# Styling Native Inputs
|
2
|
+
|
3
|
+
In the majority of cases, it's recommended to use our web component wrappers around native inputs like text, textarea, checkboxes and radios. They'll provide functionality like inline help, skeletons, form participation, and localized validation out-of-the-box.
|
4
|
+
|
5
|
+
In the rare circumstance where a native HTML input is preferred, it is possible to apply styles such that they appear similar to our web component variants.
|
6
|
+
|
7
|
+
## Checkbox Input
|
8
|
+
|
9
|
+
Import `input-checkbox-styles.js` and apply the `d2l-input-checkbox` CSS class to the input:
|
10
|
+
|
11
|
+
<!-- docs: demo code display:block -->
|
12
|
+
```html
|
13
|
+
<script type="module">
|
14
|
+
import { html, LitElement } from 'lit';
|
15
|
+
import { checkboxStyles } from '@brightspace-ui/core/components/inputs/input-checkbox.js';
|
16
|
+
|
17
|
+
class MyCheckboxElem extends LitElement {
|
18
|
+
|
19
|
+
static get styles() {
|
20
|
+
return checkboxStyles;
|
21
|
+
}
|
22
|
+
|
23
|
+
render() {
|
24
|
+
return html`<input type="checkbox" class="d2l-input-checkbox">`;
|
25
|
+
}
|
26
|
+
|
27
|
+
}
|
28
|
+
customElements.define('d2l-my-checkbox-elem', MyCheckboxElem);
|
29
|
+
</script>
|
30
|
+
<d2l-my-checkbox-elem></d2l-my-checkbox-elem>
|
31
|
+
```
|
32
|
+
|
33
|
+
## Radio Inputs
|
34
|
+
|
35
|
+
### With Labels
|
36
|
+
|
37
|
+
The simplest way to apply radio styles is to use the `d2l-input-radio-label` CSS class on a `<label>` element that wraps the input.
|
38
|
+
|
39
|
+
For disabled items, add the `d2l-input-radio-label-disabled` class on the label and the `disabled` attribute on the input itself.
|
40
|
+
|
41
|
+
<!-- docs: demo code display:block -->
|
42
|
+
```html
|
43
|
+
<script type="module">
|
44
|
+
import { html, LitElement } from 'lit';
|
45
|
+
import { radioStyles } from '@brightspace-ui/core/components/inputs/input-radio-styles.js';
|
46
|
+
|
47
|
+
class MyRadioElem extends LitElement {
|
48
|
+
|
49
|
+
static get styles() {
|
50
|
+
return radioStyles;
|
51
|
+
}
|
52
|
+
|
53
|
+
render() {
|
54
|
+
return html`
|
55
|
+
<label class="d2l-input-radio-label">
|
56
|
+
<input type="radio" name="myGroup" checked>
|
57
|
+
Option 1 (selected)
|
58
|
+
</label>
|
59
|
+
<label class="d2l-input-radio-label d2l-input-radio-label-disabled">
|
60
|
+
<input type="radio" name="myGroup" disabled>
|
61
|
+
Option 2 (disabled)
|
62
|
+
</label>
|
63
|
+
<label class="d2l-input-radio-label">
|
64
|
+
<input type="radio" name="myGroup">
|
65
|
+
Option 3
|
66
|
+
</label>
|
67
|
+
`;
|
68
|
+
}
|
69
|
+
|
70
|
+
}
|
71
|
+
customElements.define('d2l-my-radio-elem', MyRadioElem);
|
72
|
+
</script>
|
73
|
+
<d2l-my-radio-elem></d2l-my-radio-elem>
|
74
|
+
```
|
75
|
+
|
76
|
+
### Individual Radio Inputs
|
77
|
+
|
78
|
+
If you'd like to manually link the radio input with a label, or use an ARIA label, place the `d2l-radio-input` CSS class on the input itself to style it. For example:
|
79
|
+
|
80
|
+
<!-- docs: demo code properties name:d2l-test-input-radio-solo display:block -->
|
81
|
+
```html
|
82
|
+
<script type="module">
|
83
|
+
import { html, LitElement } from 'lit';
|
84
|
+
import { radioStyles } from '@brightspace-ui/core/components/inputs/input-radio-styles.js';
|
85
|
+
|
86
|
+
class MyRadioElem extends LitElement {
|
87
|
+
|
88
|
+
static get properties() {
|
89
|
+
return {
|
90
|
+
checked: { type: Boolean },
|
91
|
+
disabled: { type: Boolean },
|
92
|
+
invalid: { type: Boolean }
|
93
|
+
};
|
94
|
+
}
|
95
|
+
|
96
|
+
static get styles() {
|
97
|
+
return radioStyles;
|
98
|
+
}
|
99
|
+
|
100
|
+
render() {
|
101
|
+
const invalid = this.invalid ? 'true' : 'false';
|
102
|
+
return html`
|
103
|
+
<input
|
104
|
+
aria-invalid="${invalid}"
|
105
|
+
aria-label="Option 1"
|
106
|
+
?checked="${this.checked}"
|
107
|
+
class="d2l-input-radio"
|
108
|
+
?disabled="${this.disabled}"
|
109
|
+
type="radio">
|
110
|
+
`;
|
111
|
+
}
|
112
|
+
|
113
|
+
}
|
114
|
+
customElements.define('d2l-test-input-radio-solo', MyRadioElem);
|
115
|
+
</script>
|
116
|
+
<d2l-test-input-radio-solo></d2l-test-input-radio-solo>
|
117
|
+
```
|
118
|
+
|
119
|
+
### Radio Spacer [d2l-input-radio-spacer]
|
120
|
+
|
121
|
+
To align related content below radio buttons, the `d2l-input-radio-spacer` element can be used in conjunction with the `d2l-input-radio-label` class:
|
122
|
+
|
123
|
+
<!-- docs: demo code display:block -->
|
124
|
+
```html
|
125
|
+
<script type="module">
|
126
|
+
import '@brightspace-ui/core/components/inputs/input-radio-spacer.js';
|
127
|
+
import { html, LitElement } from 'lit';
|
128
|
+
import { inlineHelpStyles } from '@brightspace-ui/core/components/inputs/input-inline-help.js';
|
129
|
+
import { radioStyles } from '@brightspace-ui/core/components/inputs/input-radio-styles.js';
|
130
|
+
|
131
|
+
class MyRadioElem extends LitElement {
|
132
|
+
|
133
|
+
static get styles() {
|
134
|
+
return [ radioStyles, inlineHelpStyles ];
|
135
|
+
}
|
136
|
+
|
137
|
+
render() {
|
138
|
+
return html`
|
139
|
+
<label class="d2l-input-radio-label">
|
140
|
+
<input type="radio" aria-describedby="desc1" value="normal" checked>
|
141
|
+
Option 1
|
142
|
+
</label>
|
143
|
+
<d2l-input-radio-spacer id="desc1" class="d2l-input-inline-help">
|
144
|
+
Additional content can go here and will line up nicely with the edge of the radio.
|
145
|
+
</d2l-input-radio-spacer>
|
146
|
+
`;
|
147
|
+
}
|
148
|
+
|
149
|
+
}
|
150
|
+
customElements.define('d2l-my-radio-spacer-elem', MyRadioElem);
|
151
|
+
</script>
|
152
|
+
<d2l-my-radio-spacer-elem></d2l-my-radio-spacer-elem>
|
153
|
+
```
|
@@ -16,7 +16,7 @@ class InputRadioGroup extends PropertyRequiredMixin(SkeletonMixin(FormElementMix
|
|
16
16
|
static get properties() {
|
17
17
|
return {
|
18
18
|
/**
|
19
|
-
* REQUIRED: Label for the
|
19
|
+
* REQUIRED: Label for the group of radio inputs
|
20
20
|
* @type {string}
|
21
21
|
*/
|
22
22
|
label: { required: true, type: String },
|
package/custom-elements.json
CHANGED
@@ -6918,7 +6918,7 @@
|
|
6918
6918
|
"attributes": [
|
6919
6919
|
{
|
6920
6920
|
"name": "label",
|
6921
|
-
"description": "REQUIRED: Label for the
|
6921
|
+
"description": "REQUIRED: Label for the group of radio inputs",
|
6922
6922
|
"type": "string"
|
6923
6923
|
},
|
6924
6924
|
{
|
@@ -6948,7 +6948,7 @@
|
|
6948
6948
|
{
|
6949
6949
|
"name": "label",
|
6950
6950
|
"attribute": "label",
|
6951
|
-
"description": "REQUIRED: Label for the
|
6951
|
+
"description": "REQUIRED: Label for the group of radio inputs",
|
6952
6952
|
"type": "string"
|
6953
6953
|
},
|
6954
6954
|
{
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.122.0",
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
5
5
|
"type": "module",
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|