Debian Codegraph @

node/@patternfly/react-core/src/components/Switch/examples/Switch.md

raw
1 ---
2 id: Switch
3 section: components
4 cssPrefix: pf-v6-c-switch
5 propComponents: ['Switch']
6 ouia: true
7 ---
8
9 import { Fragment, useState } from 'react';
10
11 ## Examples
12
13 To keep inline with accessibility guidelines, the label for a switch must never dynamically change. A dynamically changing label (such as one label for an "on" state and another label for an "off" state) can be confusing as the contexts for each label changes as the switch state does. This applies to both visible text labels as well as labels provided via `aria-label`.
14
15 ### Basic
16
17 ```ts file="./SwitchBasic.tsx"
18
19 ```
20
21 ### Reversed Layout
22
23 ```ts file="./SwitchReversed.tsx"
24
25 ```
26
27 ### Without label
28
29 ```ts file="./SwitchWithoutLabel.tsx"
30
31 ```
32
33 ### Checked with label
34
35 ```ts file="./SwitchCheckedWithLabel.tsx"
36
37 ```
38
39 ### Disabled
40
41 ```ts file="./SwitchDisabled.tsx"
42
43 ```
44
45 ### Uncontrolled
46
47 ```ts file="./SwitchUncontrolled.tsx"
48
49 ```