Debian Codegraph @

node/@patternfly/patternfly/docs/demos/PasswordStrength/examples/PasswordStrength.md

raw
1 ---
2 id: 'Password strength'
3 section: components
4 ---## Examples
5
6 ### Initial state
7
8 ```html
9 <form class="pf-v6-c-form" novalidate>
10 <div class="pf-v6-c-form__group">
11 <div class="pf-v6-c-form__group-label pf-m-info">
12 <div class="pf-v6-c-form__group-label-main"><label
13 class="pf-v6-c-form__label"
14 for="password-strength-demo--initial-password"
15 >
16 <span class="pf-v6-c-form__label-text">Password</span>&nbsp;<span class="pf-v6-c-form__label-required" aria-hidden="true">&#42;</span></label>
17 </div>
18 <div class="pf-v6-c-form__group-label-info"></div>
19 </div>
20 <div class="pf-v6-c-form__group-control">
21 <div class="pf-v6-c-input-group">
22 <div class="pf-v6-c-input-group__item pf-m-fill">
23 <span class="pf-v6-c-form-control pf-m-required">
24 <input
25 required
26 type="text"
27 id="password-strength-demo--initial-password"
28 name="password-strength-demo--initial-password"
29 aria-label="Password input"
30 value
31 placeholder="Password"
32 />
33 </span>
34 </div>
35 <div class="pf-v6-c-input-group__item">
36 <button
37 class="pf-v6-c-button pf-m-control"
38 type="button"
39 aria-label="Show password"
40 >
41 <span class="pf-v6-c-button__icon">
42 <svg
43 class="pf-v6-svg"
44 fill="currentColor"
45 viewBox="0 0 640 512"
46 aria-hidden="true"
47 role="img"
48 width="1em"
49 height="1em"
50 >
51 <path
52 d="M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z"
53 />
54 </svg>
55 </span>
56 </button>
57 </div>
58 </div>
59 <div class="pf-v6-c-form__helper-text" aria-live="polite">
60 <div class="pf-v6-c-helper-text">
61 <div
62 class="pf-v6-c-helper-text__item pf-m-indeterminate pf-m-dynamic"
63 >
64 <span class="pf-v6-c-helper-text__item-icon">
65 <i class="fas fa-fw fa-minus" aria-hidden="true"></i>
66 </span>
67 <span class="pf-v6-c-helper-text__item-text">
68 <span class="pf-v6-screen-reader">Indeterminate:</span>
69 Must be at least 14 characters
70 </span>
71 </div>
72 <div
73 class="pf-v6-c-helper-text__item pf-m-indeterminate pf-m-dynamic"
74 >
75 <span class="pf-v6-c-helper-text__item-icon">
76 <i class="fas fa-fw fa-minus" aria-hidden="true"></i>
77 </span>
78 <span class="pf-v6-c-helper-text__item-text">
79 <span class="pf-v6-screen-reader">Indeterminate:</span>
80 Cannot contain the word "redhat"
81 </span>
82 </div>
83 <div
84 class="pf-v6-c-helper-text__item pf-m-indeterminate pf-m-dynamic"
85 >
86 <span class="pf-v6-c-helper-text__item-icon">
87 <i class="fas fa-fw fa-minus" aria-hidden="true"></i>
88 </span>
89 <span class="pf-v6-c-helper-text__item-text">
90 <span class="pf-v6-screen-reader">Indeterminate:</span>
91 Must include at least 3 of the following: lowercase letters, uppercase letters, numbers, symbols
92 </span>
93 </div>
94 </div>
95 </div>
96 </div>
97 </div>
98 </form>
99
100 ```
101
102 ### Invalid password
103
104 ```html
105 <form class="pf-v6-c-form" novalidate>
106 <div class="pf-v6-c-form__group">
107 <div class="pf-v6-c-form__group-label pf-m-info">
108 <div class="pf-v6-c-form__group-label-main"><label
109 class="pf-v6-c-form__label"
110 for="password-strength-demo--invalid-password"
111 >
112 <span class="pf-v6-c-form__label-text">Password</span>&nbsp;<span class="pf-v6-c-form__label-required" aria-hidden="true">&#42;</span></label>
113 </div>
114 <div class="pf-v6-c-form__group-label-info"></div>
115 </div>
116 <div class="pf-v6-c-form__group-control">
117 <div class="pf-v6-c-input-group">
118 <div class="pf-v6-c-input-group__item pf-m-fill">
119 <span class="pf-v6-c-form-control pf-m-required">
120 <input
121 required
122 type="text"
123 id="password-strength-demo--invalid-password"
124 name="password-strength-demo--invalid-password"
125 aria-label="Password input"
126 value="Marie$RedHat78"
127 placeholder="Password"
128 />
129 </span>
130 </div>
131 <div class="pf-v6-c-input-group__item">
132 <button
133 class="pf-v6-c-button pf-m-control"
134 type="button"
135 aria-label="Show password"
136 >
137 <span class="pf-v6-c-button__icon">
138 <svg
139 class="pf-v6-svg"
140 fill="currentColor"
141 viewBox="0 0 640 512"
142 aria-hidden="true"
143 role="img"
144 width="1em"
145 height="1em"
146 >
147 <path
148 d="M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z"
149 />
150 </svg>
151 </span>
152 </button>
153 </div>
154 </div>
155 <div class="pf-v6-c-form__helper-text" aria-live="polite">
156 <div class="pf-v6-c-helper-text">
157 <div class="pf-v6-c-helper-text__item pf-m-success pf-m-dynamic">
158 <span class="pf-v6-c-helper-text__item-icon">
159 <i class="fas fa-fw fa-check-circle" aria-hidden="true"></i>
160 </span>
161 <span class="pf-v6-c-helper-text__item-text">
162 <span class="pf-v6-screen-reader">Success:</span>
163 Must be at least 14 characters
164 </span>
165 </div>
166 <div class="pf-v6-c-helper-text__item pf-m-error pf-m-dynamic">
167 <span class="pf-v6-c-helper-text__item-icon">
168 <i class="fas fa-fw fa-exclamation-circle" aria-hidden="true"></i>
169 </span>
170 <span class="pf-v6-c-helper-text__item-text">
171 <span class="pf-v6-screen-reader">Error:</span>
172 Cannot contain the word "redhat"
173 </span>
174 </div>
175 <div class="pf-v6-c-helper-text__item pf-m-success pf-m-dynamic">
176 <span class="pf-v6-c-helper-text__item-icon">
177 <i class="fas fa-fw fa-check-circle" aria-hidden="true"></i>
178 </span>
179 <span class="pf-v6-c-helper-text__item-text">
180 <span class="pf-v6-screen-reader">Success:</span>
181 Must include at least 3 of the following: lowercase letters, uppercase letters, numbers, symbols
182 </span>
183 </div>
184 </div>
185 </div>
186 </div>
187 </div>
188 </form>
189
190 ```
191
192 ### Valid, weak password
193
194 ```html
195 <form class="pf-v6-c-form" novalidate>
196 <div class="pf-v6-c-form__group">
197 <div class="pf-v6-c-form__group-label pf-m-info">
198 <div class="pf-v6-c-form__group-label-main"><label
199 class="pf-v6-c-form__label"
200 for="password-strength-demo--weak-password"
201 >
202 <span class="pf-v6-c-form__label-text">Password</span>&nbsp;<span class="pf-v6-c-form__label-required" aria-hidden="true">&#42;</span></label>
203 </div>
204 <div class="pf-v6-c-form__group-label-info">
205 <div class="pf-v6-c-helper-text">
206 <div class="pf-v6-c-helper-text__item pf-m-error">
207 <span class="pf-v6-c-helper-text__item-icon">
208 <i class="fas fa-fw fa-exclamation-circle" aria-hidden="true"></i>
209 </span>
210 <span class="pf-v6-c-helper-text__item-text">
211 <span class="pf-v6-screen-reader">Error:</span>
212 Weak
213 </span>
214 </div>
215 </div>
216 </div>
217 </div>
218 <div class="pf-v6-c-form__group-control">
219 <div class="pf-v6-c-input-group">
220 <div class="pf-v6-c-input-group__item pf-m-fill">
221 <span class="pf-v6-c-form-control pf-m-required">
222 <input
223 required
224 type="text"
225 id="password-strength-demo--weak-password"
226 name="password-strength-demo--weak-password"
227 aria-label="Password input"
228 value="Marie$Can3Read"
229 placeholder="Password"
230 />
231 </span>
232 </div>
233 <div class="pf-v6-c-input-group__item">
234 <button
235 class="pf-v6-c-button pf-m-control"
236 type="button"
237 aria-label="Show password"
238 >
239 <span class="pf-v6-c-button__icon">
240 <svg
241 class="pf-v6-svg"
242 fill="currentColor"
243 viewBox="0 0 640 512"
244 aria-hidden="true"
245 role="img"
246 width="1em"
247 height="1em"
248 >
249 <path
250 d="M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z"
251 />
252 </svg>
253 </span>
254 </button>
255 </div>
256 </div>
257 <div class="pf-v6-c-form__helper-text" aria-live="polite">
258 <div class="pf-v6-c-helper-text">
259 <div class="pf-v6-c-helper-text__item pf-m-success pf-m-dynamic">
260 <span class="pf-v6-c-helper-text__item-icon">
261 <i class="fas fa-fw fa-check-circle" aria-hidden="true"></i>
262 </span>
263 <span class="pf-v6-c-helper-text__item-text">
264 <span class="pf-v6-screen-reader">Success:</span>
265 Must be at least 14 characters
266 </span>
267 </div>
268 <div class="pf-v6-c-helper-text__item pf-m-success pf-m-dynamic">
269 <span class="pf-v6-c-helper-text__item-icon">
270 <i class="fas fa-fw fa-check-circle" aria-hidden="true"></i>
271 </span>
272 <span class="pf-v6-c-helper-text__item-text">
273 <span class="pf-v6-screen-reader">Success:</span>
274 Cannot contain the word "redhat"
275 </span>
276 </div>
277 <div class="pf-v6-c-helper-text__item pf-m-success pf-m-dynamic">
278 <span class="pf-v6-c-helper-text__item-icon">
279 <i class="fas fa-fw fa-check-circle" aria-hidden="true"></i>
280 </span>
281 <span class="pf-v6-c-helper-text__item-text">
282 <span class="pf-v6-screen-reader">Success:</span>
283 Must include at least 3 of the following: lowercase letters, uppercase letters, numbers, symbols
284 </span>
285 </div>
286 </div>
287 </div>
288 </div>
289 </div>
290 </form>
291
292 ```
293
294 ### Valid, strong password
295
296 ```html
297 <form class="pf-v6-c-form" novalidate>
298 <div class="pf-v6-c-form__group">
299 <div class="pf-v6-c-form__group-label pf-m-info">
300 <div class="pf-v6-c-form__group-label-main"><label
301 class="pf-v6-c-form__label"
302 for="password-strength-demo--strong-password"
303 >
304 <span class="pf-v6-c-form__label-text">Password</span>&nbsp;<span class="pf-v6-c-form__label-required" aria-hidden="true">&#42;</span></label>
305 </div>
306 <div class="pf-v6-c-form__group-label-info">
307 <div class="pf-v6-c-helper-text">
308 <div class="pf-v6-c-helper-text__item pf-m-success">
309 <span class="pf-v6-c-helper-text__item-icon">
310 <i class="fas fa-fw fa-check-circle" aria-hidden="true"></i>
311 </span>
312 <span class="pf-v6-c-helper-text__item-text">
313 <span class="pf-v6-screen-reader">Success:</span>
314 Strong
315 </span>
316 </div>
317 </div>
318 </div>
319 </div>
320 <div class="pf-v6-c-form__group-control">
321 <div class="pf-v6-c-input-group">
322 <div class="pf-v6-c-input-group__item pf-m-fill">
323 <span class="pf-v6-c-form-control pf-m-required">
324 <input
325 required
326 type="text"
327 id="password-strength-demo--strong-password"
328 name="password-strength-demo--strong-password"
329 aria-label="Password input"
330 value="Marie$Can8Read3Pass@Word"
331 placeholder="Password"
332 />
333 </span>
334 </div>
335 <div class="pf-v6-c-input-group__item">
336 <button
337 class="pf-v6-c-button pf-m-control"
338 type="button"
339 aria-label="Show password"
340 >
341 <span class="pf-v6-c-button__icon">
342 <svg
343 class="pf-v6-svg"
344 fill="currentColor"
345 viewBox="0 0 640 512"
346 aria-hidden="true"
347 role="img"
348 width="1em"
349 height="1em"
350 >
351 <path
352 d="M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z"
353 />
354 </svg>
355 </span>
356 </button>
357 </div>
358 </div>
359 <div class="pf-v6-c-form__helper-text" aria-live="polite">
360 <div class="pf-v6-c-helper-text">
361 <div class="pf-v6-c-helper-text__item pf-m-success pf-m-dynamic">
362 <span class="pf-v6-c-helper-text__item-icon">
363 <i class="fas fa-fw fa-check-circle" aria-hidden="true"></i>
364 </span>
365 <span class="pf-v6-c-helper-text__item-text">
366 <span class="pf-v6-screen-reader">Success:</span>
367 Must be at least 14 characters
368 </span>
369 </div>
370 <div class="pf-v6-c-helper-text__item pf-m-success pf-m-dynamic">
371 <span class="pf-v6-c-helper-text__item-icon">
372 <i class="fas fa-fw fa-check-circle" aria-hidden="true"></i>
373 </span>
374 <span class="pf-v6-c-helper-text__item-text">
375 <span class="pf-v6-screen-reader">Success:</span>
376 Cannot contain the word "redhat"
377 </span>
378 </div>
379 <div class="pf-v6-c-helper-text__item pf-m-success pf-m-dynamic">
380 <span class="pf-v6-c-helper-text__item-icon">
381 <i class="fas fa-fw fa-check-circle" aria-hidden="true"></i>
382 </span>
383 <span class="pf-v6-c-helper-text__item-text">
384 <span class="pf-v6-screen-reader">Success:</span>
385 Must include at least 3 of the following: lowercase letters, uppercase letters, numbers, symbols
386 </span>
387 </div>
388 </div>
389 </div>
390 </div>
391 </div>
392 </form>
393
394 ```
395
396 ## Documentation
397
398 This demo implements a password strength meter. It uses multiple helper text items in the form helper text area below the input field to indicate whether the password meets validity criteria. Once the validity criteria are met, it also places helper text in the info area above the input field to indicate the strength of the password.