File: Radio.md

package info (click to toggle)
cockpit 354-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 308,956 kB
  • sloc: javascript: 775,606; python: 40,351; ansic: 35,655; cpp: 11,117; sh: 3,511; makefile: 580; xml: 261
file content (221 lines) | stat: -rw-r--r-- 6,260 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
---
id: Radio
section: components
subsection: forms
cssPrefix: pf-v6-c-radio
---## Examples

### Basic

```html
<div class="pf-v6-c-radio" id="radio-basic-example">
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    id="radio-basic-example-input"
    name="radio-basic-example-input"
  />
  <label
    class="pf-v6-c-radio__label"
    for="radio-basic-example-input"
  >Basic radio</label>
</div>

```

### Checked

```html
<div class="pf-v6-c-radio" id="radio-checked-example">
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    id="radio-checked-example-input"
    name="radio-checked-example-input"
    checked
  />
  <label
    class="pf-v6-c-radio__label"
    for="radio-checked-example-input"
  >Radio checked</label>
</div>

```

### Label wrapping input

```html
<label
  class="pf-v6-c-radio"
  id="radio-label-wrapping-input-example"
  for="radio-label-wrapping-input-example-input"
>
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    id="radio-label-wrapping-input-example-input"
    name="radio-label-wrapping-input-example-input"
  />
  <span class="pf-v6-c-radio__label">Radio label wraps input</span>
</label>

```

### Reversed

```html
<div class="pf-v6-c-radio" id="radio-reversed-example">
  <label
    class="pf-v6-c-radio__label"
    for="radio-reversed-example-input"
  >Radio reversed</label>
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    id="radio-reversed-example-input"
    name="radio-reversed-example-input"
  />
</div>

```

### Disabled

```html
<div class="pf-v6-c-radio" id="radio-disabled-example">
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    id="radio-disabled-example-input"
    name="radio-disabled-example-input"
    disabled
  />
  <label
    class="pf-v6-c-radio__label pf-m-disabled"
    for="radio-disabled-example-input"
  >Radio disabled</label>
</div>
<div class="pf-v6-c-radio" id="radio-disabled-checked-example">
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    id="radio-disabled-checked-example-input"
    name="radio-disabled-checked-example-input"
    checked
    disabled
  />
  <label
    class="pf-v6-c-radio__label pf-m-disabled"
    for="radio-disabled-checked-example-input"
  >Radio disabled checked</label>
</div>

```

### With description

```html
<div class="pf-v6-c-radio" id="radio-with-description-exmaple">
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    aria-describedby="radio-with-description-exmaple-description"
    id="radio-with-description-exmaple-input"
    name="radio-with-description-exmaple-input"
  />
  <label
    class="pf-v6-c-radio__label"
    for="radio-with-description-exmaple-input"
  >Radio with description</label>
  <span
    class="pf-v6-c-radio__description"
    id="radio-with-description-exmaple-description"
  >Single-tenant cloud service hosted and managed by Red Hat that offers high-availability enterprise-grade clusters in a virtual private cloud on AWS od GCP.</span>
</div>

```

### With body

```html
<div class="pf-v6-c-radio" id="radio-with-body-example">
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    id="radio-with-body-example-input"
    name="radio-with-body-example-input"
  />
  <label
    class="pf-v6-c-radio__label"
    for="radio-with-body-example-input"
  >Radio with body</label>
  <span class="pf-v6-c-radio__body">This is where custom content goes.</span>
</div>

```

### With description and body

```html
<div class="pf-v6-c-radio" id="radio-with-description-body-example">
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    aria-describedby="radio-with-description-body-example-description"
    id="radio-with-description-body-example-input"
    name="radio-with-description-body-example-input"
  />
  <label
    class="pf-v6-c-radio__label"
    for="radio-with-description-body-example-input"
  >Radio with description and body</label>
  <span
    class="pf-v6-c-radio__description"
    id="radio-with-description-body-example-description"
  >Single-tenant cloud service hosted and managed by Red Hat that offers high-availability enterprise-grade clusters in a virtual private cloud on AWS od GCP.</span>
  <span class="pf-v6-c-radio__body">This is where custom content goes.</span>
</div>

```

### Standalone input

```html
<label class="pf-v6-c-radio pf-m-standalone" id="radio-standalon-input-example">
  <input
    class="pf-v6-c-radio__input"
    type="radio"
    id="radio-standalon-input-example-input"
    name="radio-standalon-input-example-input"
    aria-label="Standalone radio"
  />
</label>

```

## Documentation

### Overview

The Radio component is provided for use cases outside of forms. If it is used without label text ensure some sort of label for assistive technologies. (for example: `aria-label`)

If you extend this component or modify the styles of this component, then make sure any hover styles defined are applied to the clickable elements, like `<input>` or `<label>` since hover styles are used to convey the clickable target area of an element. To maximize the target area, use the example html where the `<label>` is the wrapping element.

### Accessibility

| Attribute | Applied to | Outcome |
| -- | -- | -- |
| `disabled` | `<input type="radio">` | Indicates that the element is unavailable and removes it from keyboard focus. **Required when input is disabled** |
| `aria-describedby` | `.pf-v6-c-radio__input` |  When using `.pf-v6-c-radio__description` make use of this on the input. |

### Usage

| Class | Applied to | Outcome |
| -- | -- | -- |
| `.pf-v6-c-radio` | `<div>`, `<label>` |  Initiates the radio component. **Required**  |
| `.pf-v6-c-radio__input` | `<input type="radio">` |  Initiates a radio input. **Required**  |
| `.pf-v6-c-radio__label` | `<label>`, `<span>` |  Initiates a label. **Required**  |
| `.pf-v6-c-radio__description` | `<span>` | Initiates a radio description. |
| `.pf-v6-c-radio__body` | `<span>` | Initiates a radio body. |
| `.pf-m-standalone` | `.pf-v6-c-radio` |  Modifies the radio component for use with a standalone `<input type="radio">`. **Required when there is no label** |
| `.pf-m-disabled` | `.pf-v6-c-radio__label` |  Modifies the radio component for the disabled state. **Required when input is disabled** |