Debian Codegraph @

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

raw
1 ---
2 id: Drawer
3 cssPrefix: pf-v6-c-drawer
4 propComponents:
5 [
6 Drawer,
7 DrawerSection,
8 DrawerContent,
9 DrawerContentBody,
10 DrawerPanelContent,
11 DrawerHead,
12 DrawerActions,
13 DrawerCloseButton,
14 DrawerPanelDescription,
15 DrawerPanelBody,
16 DrawerPanelFocusTrapObject,
17 ]
18 section: components
19 ---
20
21 import { Fragment, useRef, useState } from 'react';
22 import accessibility from '@patternfly/react-styles/css/utilities/Accessibility/accessibility';
23
24 ## Examples
25
26 ### Basic
27
28 ```ts file="./DrawerBasic.tsx"
29
30 ```
31
32 ### Panel at end
33
34 ```ts file="./DrawerPanelEnd.tsx"
35
36 ```
37
38 ### Panel at start
39
40 ```ts file="./DrawerPanelStart.tsx"
41
42 ```
43
44 ### Panel on bottom
45
46 ```ts file="./DrawerPanelBottom.tsx"
47
48 ```
49
50 ### Basic inline
51
52 ```ts file="./DrawerBasicInline.tsx"
53
54 ```
55
56 ### Inline panel at end
57
58 ```ts file="./DrawerInlinePanelEnd.tsx"
59
60 ```
61
62 ### Inline panel at start
63
64 ```ts file="./DrawerInlinePanelStart.tsx"
65
66 ```
67
68 ### Stacked content body elements
69
70 ```ts file="./DrawerStackedContentBodyElements.tsx"
71
72 ```
73
74 ### Modified content padding
75
76 ```ts file="DrawerModifiedContentPadding.tsx"
77
78 ```
79
80 ### Modified panel padding
81
82 ```ts file="DrawerModifiedPanelPadding.tsx"
83
84 ```
85
86 ### Additional section above drawer content
87
88 ```ts file="DrawerAdditionalSectionAboveContent.tsx"
89
90 ```
91
92 ### Static drawer
93
94 **Note:** For mobile viewports, all drawer variants behave the same way. At the `md` breakpoint, or where `.pf-m-static{-on-[lg, xl, 2xl]}` is applied, the `static drawer` variant’s `close button` is automatically hidden because the drawer panel doesn’t close by design.
95
96 ```ts file="DrawerStatic.tsx"
97
98 ```
99
100 ### Breakpoint
101
102 ```ts file="DrawerBreakpoint.tsx"
103
104 ```
105
106 ### Resizable at end
107
108 ```ts file="DrawerResizableAtEnd.tsx"
109
110 ```
111
112 ### Resizable at start
113
114 ```ts file="DrawerResizableAtStart.tsx"
115
116 ```
117
118 ### Resizable on bottom
119
120 ```ts file="DrawerResizableOnBottom.tsx"
121
122 ```
123
124 ### Resizable on inline
125
126 ```ts file="DrawerResizableOnInline.tsx"
127
128 ```
129
130 ### Panel with secondary background
131
132 ```ts file="DrawerSecondaryBackground.tsx"
133
134 ```
135
136 ### With focus trap
137
138 When a [focus trap](/accessibility/develop#trapping-focus) is enabled on an element, a user will only be able to interact with the contents of that element until the focus trap is closed or deactivated.
139
140 To enable and customize a focus trap on a drawer panel, apply the `focusTrap` property to the `<DrawerPanelContent>` component. Enabling a focus trap with `focusTrap.enabled` will also automatically place focus on the first focusable element when the drawer panel expands, and return focus to the previously focused element when it collapses.
141
142 To customize which element receives focus when the drawer panel expands, use the `focusTrap.elementToFocusOnExpand` property.
143
144 ```ts file="./DrawerFocusTrap.tsx"
145
146 ```
147
148 ### Pill
149
150 ```ts file="./DrawerBasicPill.tsx"
151
152 ```
153
154 ### Pill inline
155
156 ```ts file="./DrawerPillInline.tsx"
157
158 ```