Debian Codegraph @

node/@patternfly/patternfly/docs/components/Check/examples/Check.md

raw
1 ---
2 id: Checkbox
3 section: components
4 subsection: forms
5 cssPrefix: pf-v6-c-check
6 ---## Examples
7
8 ### Basic
9
10 ```html
11 <div class="pf-v6-c-check">
12 <input
13 class="pf-v6-c-check__input"
14 type="checkbox"
15 id="basic-example-example-input"
16 name="basic-example-example-input"
17 />
18 <label class="pf-v6-c-check__label" for="basic-example-example-input">Check</label>
19 </div>
20
21 ```
22
23 ### Required
24
25 ```html
26 <div class="pf-v6-c-check">
27 <input
28 class="pf-v6-c-check__input"
29 type="checkbox"
30 id="check-required-example-input"
31 name="check-required-example-input"
32 />
33 <label class="pf-v6-c-check__label" for="check-required-example-input">
34 Check
35 <span class="pf-v6-c-check__label-required" aria-hidden="true">&#42;</span>
36 </label>
37 </div>
38
39 ```
40
41 ### Checked
42
43 ```html
44 <div class="pf-v6-c-check">
45 <input
46 class="pf-v6-c-check__input"
47 type="checkbox"
48 id="check-checked-example-input"
49 name="check-checked-example-input"
50 checked
51 />
52 <label
53 class="pf-v6-c-check__label"
54 for="check-checked-example-input"
55 >Check checked</label>
56 </div>
57
58 ```
59
60 ### Label wrapping input
61
62 ```html
63 <label class="pf-v6-c-check" for="check-label-wrapping-input-example-input">
64 <input
65 class="pf-v6-c-check__input"
66 type="checkbox"
67 id="check-label-wrapping-input-example-input"
68 name="check-label-wrapping-input-example-input"
69 />
70 <span class="pf-v6-c-check__label">Check label wraps input</span>
71 </label>
72
73 ```
74
75 ### Reversed
76
77 ```html
78 <div class="pf-v6-c-check">
79 <label
80 class="pf-v6-c-check__label"
81 for="check-reversed-example-input"
82 >Check reversed</label>
83 <input
84 class="pf-v6-c-check__input"
85 type="checkbox"
86 id="check-reversed-example-input"
87 name="check-reversed-example-input"
88 />
89 </div>
90
91 ```
92
93 ### Disabled
94
95 ```html
96 <div class="pf-v6-c-check">
97 <input
98 class="pf-v6-c-check__input"
99 type="checkbox"
100 id="check-disabled-example-input"
101 name="check-disabled-example-input"
102 disabled
103 />
104 <label
105 class="pf-v6-c-check__label pf-m-disabled"
106 for="check-disabled-example-input"
107 >Check disabled</label>
108 </div>
109 <div class="pf-v6-c-check">
110 <input
111 class="pf-v6-c-check__input"
112 type="checkbox"
113 id="check-disabled-checked-example-input"
114 name="check-disabled-checked-example-input"
115 checked
116 disabled
117 />
118 <label
119 class="pf-v6-c-check__label pf-m-disabled"
120 for="check-disabled-checked-example-input"
121 >Check disabled checked</label>
122 </div>
123
124 ```
125
126 ### With description
127
128 ```html
129 <div class="pf-v6-c-check">
130 <input
131 class="pf-v6-c-check__input"
132 type="checkbox"
133 aria-describedby="check-with-example-description-example-description"
134 id="check-with-example-description-example-input"
135 name="check-with-example-description-example-input"
136 />
137 <label
138 class="pf-v6-c-check__label"
139 for="check-with-example-description-example-input"
140 >Check with description</label>
141 <span
142 class="pf-v6-c-check__description"
143 id="check-with-example-description-example-description"
144 >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>
145 </div>
146
147 ```
148
149 ### With body
150
151 ```html
152 <div class="pf-v6-c-check">
153 <input
154 class="pf-v6-c-check__input"
155 type="checkbox"
156 id="check-with-example-body-example-input"
157 name="check-with-example-body-example-input"
158 />
159 <label
160 class="pf-v6-c-check__label"
161 for="check-with-example-body-example-input"
162 >Check with body</label>
163 <span class="pf-v6-c-check__body">This is where custom content goes.</span>
164 </div>
165
166 ```
167
168 ### With description and body
169
170 ```html
171 <div class="pf-v6-c-check">
172 <input
173 class="pf-v6-c-check__input"
174 type="checkbox"
175 aria-describedby="check-with-example-description-body-example-description"
176 id="check-with-example-description-body-example-input"
177 name="check-with-example-description-body-example-input"
178 />
179 <label
180 class="pf-v6-c-check__label"
181 for="check-with-example-description-body-example-input"
182 >Check with description and body</label>
183 <span
184 class="pf-v6-c-check__description"
185 id="check-with-example-description-body-example-description"
186 >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>
187 <span class="pf-v6-c-check__body">This is where custom content goes.</span>
188 </div>
189
190 ```
191
192 ### Standalone input
193
194 ```html
195 <label
196 class="pf-v6-c-check pf-m-standalone"
197 for="standalone-input-example-input"
198 >
199 <input
200 class="pf-v6-c-check__input"
201 type="checkbox"
202 id="standalone-input-example-input"
203 name="standalone-input-example-input"
204 aria-label="Standalone check"
205 />
206 </label>
207
208 ```
209
210 ## Documentation
211
212 ### Overview
213
214 The Check 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`)
215
216 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.
217
218 ### Accessibility
219
220 | Attribute | Applied to | Outcome |
221 | -- | -- | -- |
222 | `disabled` | `.pf-v6-c-check__input` | Indicates that the element is unavailable and removes it from keyboard focus. **Required when input is disabled** |
223 | `required` | `.pf-v6-c-check__input` | Indicates that the element is required. |
224 | `aria-describedby` | `.pf-v6-c-check__input` | When using `.pf-v6-c-check__description` make use of this on the input. |
225
226 ### Usage
227
228 | Class | Applied to | Outcome |
229 | -- | -- | -- |
230 | `.pf-v6-c-check` | `<div>`, `<label>` | Initiates the check component. **Required** |
231 | `.pf-v6-c-check__input` | `<input type="checkbox">` | Initiates a check input. **Required** |
232 | `.pf-v6-c-check__label` | `<label>`, `<span>` | Initiates a label. **Required** |
233 | `.pf-v6-c-check__label-required` | `<span>` | Initiates a required indicator. |
234 | `.pf-v6-c-check__description` | `<span>` | Initiates a check description. |
235 | `.pf-v6-c-check__body` | `<span>` | Initiates a check body. |
236 | `.pf-m-standalone` | `.pf-v6-c-check` | Modifies the check component for use with a standalone `<input type="checkbox">`. **Required when there is no label** |
237 | `.pf-m-disabled` | `.pf-v6-c-check__label` | Modifies the check component for the disabled state. **Required when input is disabled** |