Debian Codegraph @

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

raw
1 ---
2 id: Code editor
3 section: components
4 cssPrefix: pf-v6-c-code-editor
5 ---import './CodeEditor.css';
6
7 ## Examples
8
9 ### Default
10
11 ```html
12 <div class="pf-v6-c-code-editor">
13 <div class="pf-v6-c-code-editor__header">
14 <div class="pf-v6-c-code-editor__header-content">
15 <div class="pf-v6-c-code-editor__controls">
16 <button
17 class="pf-v6-c-button pf-m-plain"
18 type="button"
19 aria-label="Copy to clipboard"
20 >
21 <span class="pf-v6-c-button__icon">
22 <svg
23 class="pf-v6-svg"
24 fill="currentColor"
25 viewBox="0 0 448 512"
26 aria-hidden="true"
27 role="img"
28 width="1em"
29 height="1em"
30 >
31 <path
32 d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
33 />
34 </svg>
35 </span>
36 </button>
37 <button
38 class="pf-v6-c-button pf-m-plain"
39 type="button"
40 aria-label="Download code"
41 >
42 <span class="pf-v6-c-button__icon">
43 <svg
44 class="pf-v6-svg"
45 fill="currentColor"
46 viewBox="0 0 512 512"
47 aria-hidden="true"
48 role="img"
49 width="1em"
50 height="1em"
51 >
52 <path
53 d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
54 />
55 </svg>
56 </span>
57 </button>
58 <button
59 class="pf-v6-c-button pf-m-plain"
60 type="button"
61 aria-label="Upload code"
62 >
63 <span class="pf-v6-c-button__icon">
64 <svg
65 class="pf-v6-svg"
66 fill="currentColor"
67 viewBox="0 0 512 512"
68 aria-hidden="true"
69 role="img"
70 width="1em"
71 height="1em"
72 >
73 <path
74 d="M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
75 />
76 </svg>
77 </span>
78 </button>
79 </div>
80 <div class="pf-v6-c-code-editor__header-main"></div>
81 </div>
82 <div class="pf-v6-c-code-editor__tab">
83 <span class="pf-v6-c-code-editor__tab-icon">
84 <i class="fas fa-code"></i>
85 </span>
86 <span class="pf-v6-c-code-editor__tab-text">HTML</span>
87 </div>
88 </div>
89 <div class="pf-v6-c-code-editor__main">
90 <div dir="ltr" class="pf-v6-c-code-editor__code">
91 <pre class="pf-v6-c-code-editor__code-pre">
92 code goes here
93 </pre>
94 </div>
95 </div>
96 </div>
97
98 ```
99
100 ### Read-only
101
102 ```html
103 <div class="pf-v6-c-code-editor pf-m-read-only">
104 <div class="pf-v6-c-code-editor__header">
105 <div class="pf-v6-c-code-editor__header-content">
106 <div class="pf-v6-c-code-editor__controls">
107 <button
108 class="pf-v6-c-button pf-m-plain"
109 type="button"
110 aria-label="Copy to clipboard"
111 >
112 <span class="pf-v6-c-button__icon">
113 <svg
114 class="pf-v6-svg"
115 fill="currentColor"
116 viewBox="0 0 448 512"
117 aria-hidden="true"
118 role="img"
119 width="1em"
120 height="1em"
121 >
122 <path
123 d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
124 />
125 </svg>
126 </span>
127 </button>
128 <button
129 class="pf-v6-c-button pf-m-plain"
130 type="button"
131 aria-label="Download code"
132 >
133 <span class="pf-v6-c-button__icon">
134 <svg
135 class="pf-v6-svg"
136 fill="currentColor"
137 viewBox="0 0 512 512"
138 aria-hidden="true"
139 role="img"
140 width="1em"
141 height="1em"
142 >
143 <path
144 d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
145 />
146 </svg>
147 </span>
148 </button>
149 <button
150 class="pf-v6-c-button pf-m-plain"
151 type="button"
152 aria-label="Upload code"
153 >
154 <span class="pf-v6-c-button__icon">
155 <svg
156 class="pf-v6-svg"
157 fill="currentColor"
158 viewBox="0 0 512 512"
159 aria-hidden="true"
160 role="img"
161 width="1em"
162 height="1em"
163 >
164 <path
165 d="M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
166 />
167 </svg>
168 </span>
169 </button>
170 </div>
171 <div class="pf-v6-c-code-editor__header-main"></div>
172 </div>
173 <div class="pf-v6-c-code-editor__tab">
174 <span class="pf-v6-c-code-editor__tab-icon">
175 <i class="fas fa-code"></i>
176 </span>
177 <span class="pf-v6-c-code-editor__tab-text">HTML</span>
178 </div>
179 </div>
180 <div class="pf-v6-c-code-editor__main">
181 <div dir="ltr" class="pf-v6-c-code-editor__code">
182 <pre class="pf-v6-c-code-editor__code-pre">
183 code goes here
184 </pre>
185 </div>
186 </div>
187 </div>
188
189 ```
190
191 ### Without actions
192
193 ```html
194 <div class="pf-v6-c-code-editor">
195 <div class="pf-v6-c-code-editor__header">
196 <div class="pf-v6-c-code-editor__tab">
197 <span class="pf-v6-c-code-editor__tab-icon">
198 <i class="fas fa-code" aria-hidden="true"></i>
199 </span>
200 <span class="pf-v6-c-code-editor__tab-text">YAML</span>
201 </div>
202 </div>
203 <div class="pf-v6-c-code-editor__main">
204 <div class="pf-v6-c-code-editor__upload">
205 <div class="pf-v6-c-empty-state">
206 <div class="pf-v6-c-empty-state__content">
207 <div class="pf-v6-c-empty-state__header">
208 <div class="pf-v6-c-empty-state__icon">
209 <svg
210 class="pf-v6-svg"
211 fill="currentColor"
212 viewBox="0 0 640 512"
213 aria-hidden="true"
214 role="img"
215 width="1em"
216 height="1em"
217 >
218 <path
219 d="M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z"
220 />
221 </svg>
222 </div>
223 <div class="pf-v6-c-empty-state__title">
224 <h4 class="pf-v6-c-empty-state__title-text">Start editing</h4>
225 </div>
226 </div>
227
228 <div
229 class="pf-v6-c-empty-state__body"
230 >Drag a file here or browse to upload.</div>
231
232 <div class="pf-v6-c-empty-state__footer">
233 <div class="pf-v6-c-empty-state__actions">
234 <button class="pf-v6-c-button pf-m-primary" type="button">
235 <span class="pf-v6-c-button__text">Browse</span>
236 </button>
237 </div>
238 <div class="pf-v6-c-empty-state__actions">
239 <button class="pf-v6-c-button pf-m-link" type="button">
240 <span class="pf-v6-c-button__text">Start from scratch</span>
241 </button>
242 </div>
243 </div>
244 </div>
245 </div>
246 </div>
247 </div>
248 </div>
249
250 ```
251
252 ### Without language tab
253
254 ```html
255 <div class="pf-v6-c-code-editor">
256 <div class="pf-v6-c-code-editor__header"></div>
257 <div class="pf-v6-c-code-editor__main">
258 <div dir="ltr" class="pf-v6-c-code-editor__code">
259 <pre class="pf-v6-c-code-editor__code-pre">
260 code goes here
261 </pre>
262 </div>
263 </div>
264 </div>
265
266 ```
267
268 ### Drag file and hover over component
269
270 ```html
271 <div class="pf-v6-c-code-editor">
272 <div class="pf-v6-c-code-editor__header">
273 <div class="pf-v6-c-code-editor__tab">
274 <span class="pf-v6-c-code-editor__tab-icon">
275 <i class="fas fa-code" aria-hidden="true"></i>
276 </span>
277 <span class="pf-v6-c-code-editor__tab-text">YAML</span>
278 </div>
279 </div>
280 <div class="pf-v6-c-code-editor__main pf-m-drag-hover">
281 <div class="pf-v6-c-code-editor__upload">
282 <div class="pf-v6-c-empty-state">
283 <div class="pf-v6-c-empty-state__content">
284 <div class="pf-v6-c-empty-state__header">
285 <div class="pf-v6-c-empty-state__icon">
286 <svg
287 class="pf-v6-svg"
288 fill="currentColor"
289 viewBox="0 0 640 512"
290 aria-hidden="true"
291 role="img"
292 width="1em"
293 height="1em"
294 >
295 <path
296 d="M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z"
297 />
298 </svg>
299 </div>
300 <div class="pf-v6-c-empty-state__title">
301 <h4 class="pf-v6-c-empty-state__title-text">Start editing</h4>
302 </div>
303 </div>
304
305 <div
306 class="pf-v6-c-empty-state__body"
307 >Drag a file here or browse to upload.</div>
308
309 <div class="pf-v6-c-empty-state__footer">
310 <div class="pf-v6-c-empty-state__actions">
311 <button class="pf-v6-c-button pf-m-primary" type="button">
312 <span class="pf-v6-c-button__text">Browse</span>
313 </button>
314 </div>
315 <div class="pf-v6-c-empty-state__actions">
316 <button class="pf-v6-c-button pf-m-link" type="button">
317 <span class="pf-v6-c-button__text">Start from scratch</span>
318 </button>
319 </div>
320 </div>
321 </div>
322 </div>
323 </div>
324 </div>
325 </div>
326
327 ```
328
329 ### With optional header content and keyboard shortcuts
330
331 ```html
332 <div class="pf-v6-c-code-editor">
333 <div class="pf-v6-c-code-editor__header">
334 <div class="pf-v6-c-code-editor__header-content">
335 <div class="pf-v6-c-code-editor__controls">
336 <button
337 class="pf-v6-c-button pf-m-plain"
338 type="button"
339 aria-label="Copy to clipboard"
340 >
341 <span class="pf-v6-c-button__icon">
342 <svg
343 class="pf-v6-svg"
344 fill="currentColor"
345 viewBox="0 0 448 512"
346 aria-hidden="true"
347 role="img"
348 width="1em"
349 height="1em"
350 >
351 <path
352 d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
353 />
354 </svg>
355 </span>
356 </button>
357 <button
358 class="pf-v6-c-button pf-m-plain"
359 type="button"
360 aria-label="Download code"
361 >
362 <span class="pf-v6-c-button__icon">
363 <svg
364 class="pf-v6-svg"
365 fill="currentColor"
366 viewBox="0 0 512 512"
367 aria-hidden="true"
368 role="img"
369 width="1em"
370 height="1em"
371 >
372 <path
373 d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
374 />
375 </svg>
376 </span>
377 </button>
378 <button
379 class="pf-v6-c-button pf-m-plain"
380 type="button"
381 aria-label="Upload code"
382 >
383 <span class="pf-v6-c-button__icon">
384 <svg
385 class="pf-v6-svg"
386 fill="currentColor"
387 viewBox="0 0 512 512"
388 aria-hidden="true"
389 role="img"
390 width="1em"
391 height="1em"
392 >
393 <path
394 d="M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
395 />
396 </svg>
397 </span>
398 </button>
399 </div>
400 <div class="pf-v6-c-code-editor__header-main">Header main content</div>
401 <div class="pf-v6-c-code-editor__keyboard-shortcuts">
402 <button class="pf-v6-c-button pf-m-link" type="button">
403 <span class="pf-v6-c-button__icon pf-m-start">
404 <svg
405 class="pf-v6-svg"
406 viewBox="0 0 1024 1024"
407 fill="currentColor"
408 aria-hidden="true"
409 role="img"
410 width="1em"
411 height="1em"
412 >
413 <path
414 d="M521.3,576 C627.5,576 713.7,502 713.7,413.7 C713.7,325.4 627.6,253.6 521.3,253.6 C366,253.6 334.5,337.7 329.2,407.2 C329.2,414.3 335.2,416 343.5,416 L445,416 C450.5,416 458,415.5 460.8,406.5 C460.8,362.6 582.9,357.1 582.9,413.6 C582.9,441.9 556.2,470.9 521.3,473 C486.4,475.1 447.3,479.8 447.3,521.7 L447.3,553.8 C447.3,570.8 456.1,576 472,576 C487.9,576 521.3,576 521.3,576 M575.3,751.3 L575.3,655.3 C575.313862,651.055109 573.620137,646.982962 570.6,644 C567.638831,640.947672 563.552355,639.247987 559.3,639.29884 L463.3,639.29884 C459.055109,639.286138 454.982962,640.979863 452,644 C448.947672,646.961169 447.247987,651.047645 447.29884,655.3 L447.29884,751.3 C447.286138,755.544891 448.979863,759.617038 452,762.6 C454.961169,765.652328 459.047645,767.352013 463.3,767.30116 L559.3,767.30116 C563.544891,767.313862 567.617038,765.620137 570.6,762.6 C573.659349,759.643612 575.360354,755.553963 575.3,751.3 M512,896 C300.2,896 128,723.9 128,512 C128,300.3 300.2,128 512,128 C723.8,128 896,300.2 896,512 C896,723.8 723.7,896 512,896 M512.1,0 C229.7,0 0,229.8 0,512 C0,794.2 229.8,1024 512.1,1024 C794.4,1024 1024,794.3 1024,512 C1024,229.7 794.4,0 512.1,0"
415 />
416 </svg>
417 </span>
418 <span class="pf-v6-c-button__text">View shortcuts</span>
419 </button>
420 </div>
421 </div>
422 <div class="pf-v6-c-code-editor__tab">
423 <span class="pf-v6-c-code-editor__tab-icon">
424 <i class="fas fa-code"></i>
425 </span>
426 <span class="pf-v6-c-code-editor__tab-text">HTML</span>
427 </div>
428 </div>
429 <div class="pf-v6-c-code-editor__main">
430 <div dir="ltr" class="pf-v6-c-code-editor__code">
431 <pre class="pf-v6-c-code-editor__code-pre">
432 code goes here
433 </pre>
434 </div>
435 </div>
436 </div>
437
438 ```
439
440 ### With optional code editor container
441
442 This is an extra container used in React to prevent event propagation if upload is enabled or there is a provided empty state.
443
444 ```html
445 <div class="pf-v6-c-code-editor">
446 <div role="presentation" tabindex="0" class="pf-v6-c-code-editor__container">
447 <div class="pf-v6-c-code-editor__header">
448 <div class="pf-v6-c-code-editor__header-content">
449 <div class="pf-v6-c-code-editor__controls">
450 <button
451 class="pf-v6-c-button pf-m-plain"
452 type="button"
453 aria-label="Copy to clipboard"
454 >
455 <span class="pf-v6-c-button__icon">
456 <svg
457 class="pf-v6-svg"
458 fill="currentColor"
459 viewBox="0 0 448 512"
460 aria-hidden="true"
461 role="img"
462 width="1em"
463 height="1em"
464 >
465 <path
466 d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
467 />
468 </svg>
469 </span>
470 </button>
471 <button
472 class="pf-v6-c-button pf-m-plain"
473 type="button"
474 aria-label="Download code"
475 >
476 <span class="pf-v6-c-button__icon">
477 <svg
478 class="pf-v6-svg"
479 fill="currentColor"
480 viewBox="0 0 512 512"
481 aria-hidden="true"
482 role="img"
483 width="1em"
484 height="1em"
485 >
486 <path
487 d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
488 />
489 </svg>
490 </span>
491 </button>
492 <button
493 class="pf-v6-c-button pf-m-plain"
494 type="button"
495 aria-label="Upload code"
496 >
497 <span class="pf-v6-c-button__icon">
498 <svg
499 class="pf-v6-svg"
500 fill="currentColor"
501 viewBox="0 0 512 512"
502 aria-hidden="true"
503 role="img"
504 width="1em"
505 height="1em"
506 >
507 <path
508 d="M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
509 />
510 </svg>
511 </span>
512 </button>
513 </div>
514 </div>
515 <div class="pf-v6-c-code-editor__tab">
516 <span class="pf-v6-c-code-editor__tab-icon">
517 <i class="fas fa-code"></i>
518 </span>
519 <span class="pf-v6-c-code-editor__tab-text">HTML</span>
520 </div>
521 </div>
522 <div class="pf-v6-c-code-editor__main">
523 <div class="pf-v6-c-code-editor__upload">
524 <div class="pf-v6-c-empty-state">
525 <div class="pf-v6-c-empty-state__content">
526 <div class="pf-v6-c-empty-state__header">
527 <div class="pf-v6-c-empty-state__icon">
528 <svg
529 class="pf-v6-svg"
530 fill="currentColor"
531 viewBox="0 0 640 512"
532 aria-hidden="true"
533 role="img"
534 width="1em"
535 height="1em"
536 >
537 <path
538 d="M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z"
539 />
540 </svg>
541 </div>
542 <div class="pf-v6-c-empty-state__title">
543 <h4 class="pf-v6-c-empty-state__title-text">Start editing</h4>
544 </div>
545 </div>
546
547 <div
548 class="pf-v6-c-empty-state__body"
549 >Drag a file here or browse to upload.</div>
550
551 <div class="pf-v6-c-empty-state__footer">
552 <div class="pf-v6-c-empty-state__actions">
553 <button class="pf-v6-c-button pf-m-primary" type="button">
554 <span class="pf-v6-c-button__text">Browse</span>
555 </button>
556 </div>
557 <div class="pf-v6-c-empty-state__actions">
558 <button class="pf-v6-c-button pf-m-link" type="button">
559 <span class="pf-v6-c-button__text">Start from scratch</span>
560 </button>
561 </div>
562 </div>
563 </div>
564 </div>
565 </div>
566 </div>
567 </div>
568 </div>
569
570 ```
571
572 ### With full height modifier
573
574 ```html
575 <div class="pf-v6-c-code-editor pf-m-full-height">
576 <div class="pf-v6-c-code-editor__header">
577 <div class="pf-v6-c-code-editor__header-content">
578 <div class="pf-v6-c-code-editor__controls">
579 <button
580 class="pf-v6-c-button pf-m-plain"
581 type="button"
582 aria-label="Copy to clipboard"
583 >
584 <span class="pf-v6-c-button__icon">
585 <svg
586 class="pf-v6-svg"
587 fill="currentColor"
588 viewBox="0 0 448 512"
589 aria-hidden="true"
590 role="img"
591 width="1em"
592 height="1em"
593 >
594 <path
595 d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"
596 />
597 </svg>
598 </span>
599 </button>
600 <button
601 class="pf-v6-c-button pf-m-plain"
602 type="button"
603 aria-label="Download code"
604 >
605 <span class="pf-v6-c-button__icon">
606 <svg
607 class="pf-v6-svg"
608 fill="currentColor"
609 viewBox="0 0 512 512"
610 aria-hidden="true"
611 role="img"
612 width="1em"
613 height="1em"
614 >
615 <path
616 d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
617 />
618 </svg>
619 </span>
620 </button>
621 <button
622 class="pf-v6-c-button pf-m-plain"
623 type="button"
624 aria-label="Upload code"
625 >
626 <span class="pf-v6-c-button__icon">
627 <svg
628 class="pf-v6-svg"
629 fill="currentColor"
630 viewBox="0 0 512 512"
631 aria-hidden="true"
632 role="img"
633 width="1em"
634 height="1em"
635 >
636 <path
637 d="M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"
638 />
639 </svg>
640 </span>
641 </button>
642 </div>
643 <div class="pf-v6-c-code-editor__header-main">Header main content</div>
644 <div class="pf-v6-c-code-editor__keyboard-shortcuts">
645 <button class="pf-v6-c-button pf-m-link" type="button">
646 <span class="pf-v6-c-button__icon pf-m-start">
647 <svg
648 class="pf-v6-svg"
649 viewBox="0 0 1024 1024"
650 fill="currentColor"
651 aria-hidden="true"
652 role="img"
653 width="1em"
654 height="1em"
655 >
656 <path
657 d="M521.3,576 C627.5,576 713.7,502 713.7,413.7 C713.7,325.4 627.6,253.6 521.3,253.6 C366,253.6 334.5,337.7 329.2,407.2 C329.2,414.3 335.2,416 343.5,416 L445,416 C450.5,416 458,415.5 460.8,406.5 C460.8,362.6 582.9,357.1 582.9,413.6 C582.9,441.9 556.2,470.9 521.3,473 C486.4,475.1 447.3,479.8 447.3,521.7 L447.3,553.8 C447.3,570.8 456.1,576 472,576 C487.9,576 521.3,576 521.3,576 M575.3,751.3 L575.3,655.3 C575.313862,651.055109 573.620137,646.982962 570.6,644 C567.638831,640.947672 563.552355,639.247987 559.3,639.29884 L463.3,639.29884 C459.055109,639.286138 454.982962,640.979863 452,644 C448.947672,646.961169 447.247987,651.047645 447.29884,655.3 L447.29884,751.3 C447.286138,755.544891 448.979863,759.617038 452,762.6 C454.961169,765.652328 459.047645,767.352013 463.3,767.30116 L559.3,767.30116 C563.544891,767.313862 567.617038,765.620137 570.6,762.6 C573.659349,759.643612 575.360354,755.553963 575.3,751.3 M512,896 C300.2,896 128,723.9 128,512 C128,300.3 300.2,128 512,128 C723.8,128 896,300.2 896,512 C896,723.8 723.7,896 512,896 M512.1,0 C229.7,0 0,229.8 0,512 C0,794.2 229.8,1024 512.1,1024 C794.4,1024 1024,794.3 1024,512 C1024,229.7 794.4,0 512.1,0"
658 />
659 </svg>
660 </span>
661 <span class="pf-v6-c-button__text">View shortcuts</span>
662 </button>
663 </div>
664 </div>
665 <div class="pf-v6-c-code-editor__tab">
666 <span class="pf-v6-c-code-editor__tab-icon">
667 <i class="fas fa-code"></i>
668 </span>
669 <span class="pf-v6-c-code-editor__tab-text">HTML</span>
670 </div>
671 </div>
672 <div class="pf-v6-c-code-editor__main">
673 <div dir="ltr" class="pf-v6-c-code-editor__code">
674 <pre class="pf-v6-c-code-editor__code-pre">
675 code goes here
676 </pre>
677 </div>
678 </div>
679 </div>
680
681 ```
682
683 ## Documentation
684
685 ### Usage
686
687 | Class | Applied to | Outcome |
688 | ------------------------------------------ | ---------- | --------------------------------------------------------------------------------------------- |
689 | `.pf-v6-c-code-editor` | `<div>` | Initiates the code editor component. **Required** |
690 | `.pf-v6-c-code-editor__header` | `<div>` | Initiates the code editor header used for the controls and tab elements. |
691 | `.pf-v6-c-code-editor__header-content` | `<div>` | Initiates the code editor header content used for the controls and tab elements. **Required** |
692 | `.pf-v6-c-code-editor__main` | `<div>` | Initiates the main container for a code editor e.g. Monaco **Required** |
693 | `.pf-v6-c-code-editor__code` | `<div>` | Initiates the container for code without a JS code editor. Comes with PatternFly styling. |
694 | `.pf-v6-c-code-editor__controls` | `<div>` | Initiates the code editor controls. |
695 | `.pf-v6-c-code-editor__header-main` | `<div>` | Initiates the code editor header content area. |
696 | `.pf-v6-c-code-editor__keyboard-shortcuts` | `<div>` | Initiates the code editor header keyboard shortcuts area. |
697 | `.pf-v6-c-code-editor__tab` | `<div>` | Initiates the code editor tab. |
698 | `.pf-v6-c-code-editor__tab-text` | `<span>` | Initiates the code editor tab text. |
699 | `.pf-v6-c-code-editor__tab-icon` | `<span>` | Initiates the code editor tab icon. |
700 | `.pf-v6-c-code-editor__upload` | `<div>` | Initiates the code editor upload border. |
701 | `.pf-v6-c-code-editor__container` | `<div>` | Initiates the container used inside `.pf-v6-c-code-editor` in PatternFly React. This is used in PatternFly React to prevent event propagation if upload is enabled or there is a provided empty state. |
702 | `.pf-m-full-height` | `.pf-v6-c-code-editor` | Modifies for full-height style. |