@patternfly/react-core 4.265.0 → 4.265.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
  3. package/dist/esm/components/SearchInput/AdvancedSearchMenu.js +5 -4
  4. package/dist/esm/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
  5. package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
  6. package/dist/esm/components/SearchInput/SearchInput.js +23 -3
  7. package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
  8. package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
  9. package/dist/js/components/SearchInput/AdvancedSearchMenu.js +5 -4
  10. package/dist/js/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
  11. package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
  12. package/dist/js/components/SearchInput/SearchInput.js +23 -3
  13. package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
  14. package/dist/umd/react-core.min.js +1 -1
  15. package/package.json +2 -2
  16. package/src/components/SearchInput/AdvancedSearchMenu.tsx +7 -4
  17. package/src/components/SearchInput/SearchInput.tsx +26 -3
  18. package/src/components/SearchInput/examples/SearchInput.md +4 -0
  19. package/src/components/Tabs/examples/Tabs.md +21 -1557
  20. package/src/components/Tabs/examples/TabsBoxLight.tsx +63 -0
  21. package/src/components/Tabs/examples/TabsChildrenMounting.tsx +33 -0
  22. package/src/components/Tabs/examples/TabsContentWithBodyPadding.tsx +58 -0
  23. package/src/components/Tabs/examples/TabsDefault.tsx +62 -0
  24. package/src/components/Tabs/examples/TabsDefaultOverflow.tsx +74 -0
  25. package/src/components/Tabs/examples/TabsFilled.tsx +51 -0
  26. package/src/components/Tabs/examples/TabsFilledWithIcons.tsx +85 -0
  27. package/src/components/Tabs/examples/TabsIconAndText.tsx +108 -0
  28. package/src/components/Tabs/examples/TabsInset.tsx +65 -0
  29. package/src/components/Tabs/examples/TabsNav.tsx +40 -0
  30. package/src/components/Tabs/examples/TabsNavSecondary.tsx +76 -0
  31. package/src/components/Tabs/examples/TabsPageInsets.tsx +60 -0
  32. package/src/components/Tabs/examples/TabsSeparateContent.tsx +75 -0
  33. package/src/components/Tabs/examples/TabsSubtabs.tsx +115 -0
  34. package/src/components/Tabs/examples/TabsToggledSeparateContent.tsx +67 -0
  35. package/src/components/Tabs/examples/TabsTooltipReactRef.tsx +72 -0
  36. package/src/components/Tabs/examples/TabsUncontrolled.tsx +33 -0
  37. package/src/components/Tabs/examples/TabsUnmountingInvisibleChildren.tsx +33 -0
  38. package/src/components/Tabs/examples/TabsVertical.tsx +72 -0
  39. package/src/components/Tabs/examples/TabsVerticalExpandable.tsx +51 -0
  40. package/src/components/Tabs/examples/TabsVerticalExpandableUncontrolled.tsx +48 -0
@@ -25,84 +25,7 @@ Similarly the 'Tab content light variation' checkbox affects the TabContent back
25
25
 
26
26
  When passing in a Tooltip component to the Tab component, the Tooltip can also be passed in directly to the `tooltip` prop.
27
27
 
28
- ```js
29
- import React from 'react';
30
- import { Tabs, Tab, TabTitleText, Checkbox, Tooltip } from '@patternfly/react-core';
31
-
32
- class SimpleTabs extends React.Component {
33
- constructor(props) {
34
- super(props);
35
- this.state = {
36
- activeTabKey: 0,
37
- isBox: false
38
- };
39
- // Toggle currently active tab
40
- this.handleTabClick = (event, tabIndex) => {
41
- this.setState({
42
- activeTabKey: tabIndex
43
- });
44
- };
45
-
46
- this.toggleBox = checked => {
47
- this.setState({
48
- isBox: checked
49
- });
50
- };
51
- }
52
-
53
- render() {
54
- const { activeTabKey, isBox } = this.state;
55
- const tooltip = (
56
- <Tooltip content="Aria-disabled tabs are like disabled tabs, but focusable. Allows for tooltip support." />
57
- );
58
-
59
- return (
60
- <div>
61
- <Tabs
62
- activeKey={activeTabKey}
63
- onSelect={this.handleTabClick}
64
- isBox={isBox}
65
- aria-label="Tabs in the default example"
66
- role="region"
67
- >
68
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Default content - users">
69
- Users
70
- </Tab>
71
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
72
- Containers
73
- </Tab>
74
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
75
- Database
76
- </Tab>
77
- <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled>
78
- Disabled
79
- </Tab>
80
- <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled>
81
- ARIA Disabled
82
- </Tab>
83
- <Tab
84
- tooltip={tooltip}
85
- eventKey={5}
86
- title={<TabTitleText>ARIA Disabled (Tooltip)</TabTitleText>}
87
- isAriaDisabled
88
- >
89
- ARIA Disabled (Tooltip)
90
- </Tab>
91
- </Tabs>
92
- <div style={{ marginTop: '20px' }}>
93
- <Checkbox
94
- label="isBox"
95
- isChecked={isBox}
96
- onChange={this.toggleBox}
97
- aria-label="show box variation checkbox"
98
- id="toggle-box-default"
99
- name="toggle-box-default"
100
- />
101
- </div>
102
- </div>
103
- );
104
- }
105
- }
28
+ ```ts file="./TabsDefault.tsx"
106
29
  ```
107
30
 
108
31
  ### With tooltip react ref
@@ -111,305 +34,22 @@ When using a React ref to link a Tooltip to a Tab component via the `reference`
111
34
 
112
35
  The tooltip should also have the `id` prop passed in. The value given to this prop should then be passed into the tab's `aria-describedby` prop. This ensures a tooltip used with a React ref will be announced by the JAWS and NVDA screen readers.
113
36
 
114
- ```js
115
- import React from 'react';
116
- import { Tabs, Tab, TabTitleText, Checkbox, Tooltip } from '@patternfly/react-core';
117
-
118
- class SimpleTabs extends React.Component {
119
- constructor(props) {
120
- super(props);
121
- this.state = {
122
- activeTabKey: 0,
123
- isBox: false
124
- };
125
- // Toggle currently active tab
126
- this.handleTabClick = (event, tabIndex) => {
127
- this.setState({
128
- activeTabKey: tabIndex
129
- });
130
- };
131
-
132
- this.toggleBox = checked => {
133
- this.setState({
134
- isBox: checked
135
- });
136
- };
137
- }
138
-
139
- render() {
140
- const { activeTabKey, isBox } = this.state;
141
- const tooltipRef = React.createRef();
142
-
143
- return (
144
- <div>
145
- <Tabs
146
- activeKey={activeTabKey}
147
- onSelect={this.handleTabClick}
148
- isBox={isBox}
149
- aria-label="Tabs in the example with a tooltip ref"
150
- role="region"
151
- >
152
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Tooltip ref content - users">
153
- Users
154
- </Tab>
155
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
156
- Containers
157
- </Tab>
158
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
159
- Database
160
- </Tab>
161
- <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled>
162
- Disabled
163
- </Tab>
164
- <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled>
165
- ARIA Disabled
166
- </Tab>
167
- <Tab
168
- eventKey={5}
169
- title={<TabTitleText>ARIA Disabled (Tooltip)</TabTitleText>}
170
- isAriaDisabled
171
- ref={tooltipRef}
172
- aria-describedby="tooltip-ref1"
173
- >
174
- ARIA Disabled (Tooltip)
175
- </Tab>
176
- </Tabs>
177
- <Tooltip
178
- id="tooltip-ref1"
179
- content="Aria-disabled tabs are like disabled tabs, but focusable. Allows for tooltip support."
180
- reference={tooltipRef}
181
- />
182
- <div style={{ marginTop: '20px' }}>
183
- <Checkbox
184
- label="isBox"
185
- isChecked={isBox}
186
- onChange={this.toggleBox}
187
- aria-label="show box variation checkbox"
188
- id="toggle-box-tooltip-ref"
189
- name="toggle-box-tooltip-ref"
190
- />
191
- </div>
192
- </div>
193
- );
194
- }
195
- }
37
+ ```ts file="./TabsTooltipReactRef.tsx"
196
38
  ```
197
39
 
198
40
  ### Uncontrolled
199
41
 
200
- ```js
201
- import React from 'react';
202
- import { Tabs, Tab, TabTitleText, Checkbox, Tooltip } from '@patternfly/react-core';
203
-
204
- class UncontrolledSimpleTabs extends React.Component {
205
- render() {
206
- const tooltip = (
207
- <Tooltip content="Aria-disabled tabs are like disabled tabs, but focusable. Allows for tooltip support." />
208
- );
209
-
210
- return (
211
- <>
212
- <Tabs defaultActiveKey={0} aria-label="Tabs in the uncontrolled example" role="region">
213
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Uncontrolled ref content - users">
214
- Users
215
- </Tab>
216
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
217
- Containers
218
- </Tab>
219
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
220
- Database
221
- </Tab>
222
- <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled>
223
- Disabled
224
- </Tab>
225
- <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled>
226
- ARIA Disabled
227
- </Tab>
228
- <Tab
229
- eventKey={5}
230
- title={<TabTitleText>ARIA Disabled (Tooltip)</TabTitleText>}
231
- isAriaDisabled
232
- tooltip={tooltip}
233
- >
234
- ARIA Disabled (Tooltip)
235
- </Tab>
236
- </Tabs>
237
- </>
238
- );
239
- }
240
- }
42
+ ```ts file="./TabsUncontrolled.tsx"
241
43
  ```
242
44
 
243
45
  ### Box light variation
244
46
 
245
- ```js
246
- import React from 'react';
247
- import { Tabs, Tab, TabTitleText, Checkbox, Tooltip } from '@patternfly/react-core';
248
-
249
- class SimpleTabs extends React.Component {
250
- constructor(props) {
251
- super(props);
252
- this.state = {
253
- activeTabKey: 0,
254
- isTabsLightScheme: true
255
- };
256
- // Toggle currently active tab
257
- this.handleTabClick = (event, tabIndex) => {
258
- this.setState({
259
- activeTabKey: tabIndex
260
- });
261
- };
262
-
263
- this.toggleScheme = checked => {
264
- this.setState({
265
- isTabsLightScheme: checked
266
- });
267
- };
268
- }
269
-
270
- render() {
271
- const { activeTabKey, isBox, isTabsLightScheme } = this.state;
272
- const tooltip = (
273
- <Tooltip content="Aria-disabled tabs are like disabled tabs, but focusable. Allows for tooltip support." />
274
- );
275
-
276
- return (
277
- <div>
278
- <Tabs
279
- activeKey={activeTabKey}
280
- onSelect={this.handleTabClick}
281
- variant={isTabsLightScheme ? 'light300' : 'default'}
282
- isBox
283
- aria-label="Tabs in the box light variation example"
284
- role="region"
285
- >
286
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Box light variation content - users">
287
- Users
288
- </Tab>
289
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
290
- Containers
291
- </Tab>
292
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
293
- Database
294
- </Tab>
295
- <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled>
296
- Disabled
297
- </Tab>
298
- <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled>
299
- ARIA Disabled
300
- </Tab>
301
- <Tab
302
- eventKey={5}
303
- title={<TabTitleText>ARIA Disabled (Tooltip)</TabTitleText>}
304
- isAriaDisabled
305
- tooltip={tooltip}
306
- >
307
- ARIA Disabled (Tooltip)
308
- </Tab>
309
- </Tabs>
310
- <div style={{ marginTop: '20px' }}>
311
- <Checkbox
312
- label="Tabs light variation"
313
- isChecked={isTabsLightScheme}
314
- onChange={this.toggleScheme}
315
- aria-label="show light scheme variation checkbox"
316
- id="toggle-scheme"
317
- name="toggle-scheme"
318
- />
319
- </div>
320
- </div>
321
- );
322
- }
323
- }
47
+ ```ts file="./TabsBoxLight.tsx"
324
48
  ```
325
49
 
326
50
  ### Default overflow
327
51
 
328
- ```js
329
- import React from 'react';
330
- import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core';
331
-
332
- class ScrollButtonsPrimaryTabs extends React.Component {
333
- constructor(props) {
334
- super(props);
335
- this.state = {
336
- activeTabKey: 0,
337
- isBox: false
338
- };
339
-
340
- // Toggle currently active tab
341
- this.handleTabClick = (event, tabIndex) => {
342
- this.setState({
343
- activeTabKey: tabIndex
344
- });
345
- };
346
-
347
- this.toggleBox = checked => {
348
- this.setState({
349
- isBox: checked
350
- });
351
- };
352
- }
353
-
354
- render() {
355
- const { activeTabKey, isBox } = this.state;
356
- return (
357
- <div>
358
- <Tabs
359
- activeKey={activeTabKey}
360
- onSelect={this.handleTabClick}
361
- isBox={isBox}
362
- aria-label="Tabs in the default overflow example"
363
- role="region"
364
- >
365
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Default overflow content users">
366
- Users
367
- </Tab>
368
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
369
- Containers
370
- </Tab>
371
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
372
- Database
373
- </Tab>
374
- <Tab eventKey={3} title={<TabTitleText>Server</TabTitleText>}>
375
- Server
376
- </Tab>
377
- <Tab eventKey={4} title={<TabTitleText>System</TabTitleText>}>
378
- System
379
- </Tab>
380
- <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>}>
381
- Network
382
- </Tab>
383
- <Tab eventKey={7} title={<TabTitleText>Tab item 7</TabTitleText>}>
384
- Tab 7 section
385
- </Tab>
386
- <Tab eventKey={8} title={<TabTitleText>Tab item 8</TabTitleText>}>
387
- Tab 8 section
388
- </Tab>
389
- <Tab eventKey={9} title={<TabTitleText>Tab item 9</TabTitleText>}>
390
- Tab 9 section
391
- </Tab>
392
- <Tab eventKey={10} title={<TabTitleText>Tab item 10</TabTitleText>}>
393
- Tab 10 section
394
- </Tab>
395
- <Tab eventKey={11} title={<TabTitleText>Tab item 11</TabTitleText>}>
396
- Tab 11 section
397
- </Tab>
398
- </Tabs>
399
- <div style={{ marginTop: '20px' }}>
400
- <Checkbox
401
- label="isBox"
402
- isChecked={isBox}
403
- onChange={this.toggleBox}
404
- aria-label="show box variation checkbox on overflow"
405
- id="toggle-box-overflow"
406
- name="toggle-box-overflow"
407
- />
408
- </div>
409
- </div>
410
- );
411
- }
412
- }
52
+ ```ts file="./TabsDefaultOverflow.tsx"
413
53
  ```
414
54
 
415
55
  ### Horizontal overflow
@@ -419,1258 +59,82 @@ class ScrollButtonsPrimaryTabs extends React.Component {
419
59
 
420
60
  ### Vertical
421
61
 
422
- ```js
423
- import React from 'react';
424
- import { Tabs, Tab, TabTitleText, Checkbox, Tooltip } from '@patternfly/react-core';
425
-
426
- class VerticalTabs extends React.Component {
427
- constructor(props) {
428
- super(props);
429
- this.state = {
430
- activeTabKey: 0,
431
- isBox: false
432
- };
433
- // Toggle currently active tab
434
- this.handleTabClick = (event, tabIndex) => {
435
- this.setState({
436
- activeTabKey: tabIndex
437
- });
438
- };
439
-
440
- this.toggleBox = checked => {
441
- this.setState({
442
- isBox: checked
443
- });
444
- };
445
- }
446
-
447
- render() {
448
- const { activeTabKey, isBox } = this.state;
449
- const tooltip = (
450
- <Tooltip content="Aria-disabled tabs are like disabled tabs, but focusable. Allows for tooltip support." />
451
- );
452
-
453
- return (
454
- <div>
455
- <Tabs
456
- activeKey={activeTabKey}
457
- onSelect={this.handleTabClick}
458
- isVertical
459
- isBox={isBox}
460
- aria-label="Tabs in the vertical example"
461
- role="region"
462
- >
463
- <Tab
464
- eventKey={0}
465
- title={
466
- <TabTitleText aria-label="vertical" role="region">
467
- Users
468
- </TabTitleText>
469
- }
470
- aria-label="Vertical example content users"
471
- >
472
- Users
473
- </Tab>
474
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
475
- Containers
476
- </Tab>
477
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
478
- Database
479
- </Tab>
480
- <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled>
481
- Disabled
482
- </Tab>
483
- <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled>
484
- ARIA Disabled
485
- </Tab>
486
- <Tab
487
- eventKey={5}
488
- title={<TabTitleText>ARIA Disabled (Tooltip)</TabTitleText>}
489
- isAriaDisabled
490
- tooltip={tooltip}
491
- >
492
- ARIA Disabled (Tooltip)
493
- </Tab>
494
- </Tabs>
495
- <div style={{ marginTop: '20px' }}>
496
- <Checkbox
497
- label="isBox"
498
- isChecked={isBox}
499
- onChange={this.toggleBox}
500
- aria-label="show box variation checkbox with vertical"
501
- id="toggle-box-vertical"
502
- name="toggle-box-vertical"
503
- />
504
- </div>
505
- </div>
506
- );
507
- }
508
- }
62
+ ```ts file="./TabsVertical.tsx"
509
63
  ```
510
64
 
511
65
  ### Vertical expandable
512
66
 
513
- ```js
514
- import React from 'react';
515
- import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core';
516
- class VerticalExpandableTabs extends React.Component {
517
- constructor(props) {
518
- super(props);
519
- this.state = {
520
- activeTabKey: 0,
521
- isExpanded: false
522
- };
523
- // Toggle currently active tab
524
- this.handleTabClick = (event, tabIndex) => {
525
- this.setState({
526
- activeTabKey: tabIndex
527
- });
528
- };
529
- this.onToggle = isExpanded => {
530
- this.setState({
531
- isExpanded
532
- });
533
- };
534
- }
535
- render() {
536
- const { activeTabKey, isExpanded } = this.state;
537
- return (
538
- <Tabs
539
- activeKey={activeTabKey}
540
- onSelect={this.handleTabClick}
541
- isVertical
542
- expandable={{ default: 'expandable', md: 'nonExpandable', lg: 'expandable' }}
543
- isExpanded={isExpanded}
544
- onToggle={this.onToggle}
545
- toggleText="Containers"
546
- aria-label="Tabs in the vertical expandable example"
547
- role="region"
548
- >
549
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Vertical expandable content users">
550
- Users
551
- </Tab>
552
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
553
- Containers
554
- </Tab>
555
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
556
- Database
557
- </Tab>
558
- <Tab eventKey={3} title={<TabTitleText>Server</TabTitleText>}>
559
- Server
560
- </Tab>
561
- <Tab eventKey={4} title={<TabTitleText>System</TabTitleText>}>
562
- System
563
- </Tab>
564
- <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>}>
565
- Network
566
- </Tab>
567
- </Tabs>
568
- );
569
- }
570
- }
67
+ ```ts file="./TabsVerticalExpandable.tsx"
571
68
  ```
572
69
 
573
70
  ### Vertical expandable uncontrolled
574
71
 
575
- ```js
576
- import React from 'react';
577
- import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core';
578
- class VerticalExpandableUncontrolledTabs extends React.Component {
579
- constructor(props) {
580
- super(props);
581
- this.state = {
582
- activeTabKey: 0
583
- };
584
- // Toggle currently active tab
585
- this.handleTabClick = (event, tabIndex) => {
586
- this.setState({
587
- activeTabKey: tabIndex
588
- });
589
- };
590
- }
591
- render() {
592
- const { activeTabKey } = this.state;
593
- return (
594
- <Tabs
595
- activeKey={activeTabKey}
596
- onSelect={this.handleTabClick}
597
- isVertical
598
- expandable={{ default: 'expandable', md: 'nonExpandable', lg: 'expandable' }}
599
- defaultIsExpanded={false}
600
- toggleText="Containers"
601
- aria-label="Tabs in the vertical expandable uncontrolled example"
602
- role="region"
603
- >
604
- <Tab
605
- eventKey={0}
606
- title={<TabTitleText>Users</TabTitleText>}
607
- aria-label="Vertical expandable uncontrolled content users"
608
- >
609
- Users
610
- </Tab>
611
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
612
- Containers
613
- </Tab>
614
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
615
- Database
616
- </Tab>
617
- <Tab eventKey={3} title={<TabTitleText>Server</TabTitleText>}>
618
- Server
619
- </Tab>
620
- <Tab eventKey={4} title={<TabTitleText>System</TabTitleText>}>
621
- System
622
- </Tab>
623
- <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>}>
624
- Network
625
- </Tab>
626
- </Tabs>
627
- );
628
- }
629
- }
72
+ ```ts file="./TabsVerticalExpandableUncontrolled.tsx"
630
73
  ```
631
74
 
632
75
  ### Inset
633
76
 
634
- ```js
635
- import React from 'react';
636
- import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core';
637
-
638
- class InsetTabs extends React.Component {
639
- constructor(props) {
640
- super(props);
641
- this.state = {
642
- activeTabKey: 0,
643
- isBox: false
644
- };
645
- // Toggle currently active tab
646
- this.handleTabClick = (event, tabIndex) => {
647
- this.setState({
648
- activeTabKey: tabIndex
649
- });
650
- };
651
-
652
- this.toggleBox = checked => {
653
- this.setState({
654
- isBox: checked
655
- });
656
- };
657
- }
658
-
659
- render() {
660
- const { activeTabKey, isBox } = this.state;
661
- return (
662
- <div>
663
- <Tabs
664
- activeKey={activeTabKey}
665
- onSelect={this.handleTabClick}
666
- inset={{
667
- default: 'insetNone',
668
- md: 'insetSm',
669
- xl: 'insetLg',
670
- '2xl': 'inset2xl'
671
- }}
672
- isBox={isBox}
673
- aria-label="Tabs in the inset example"
674
- role="region"
675
- >
676
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Inset example content users">
677
- Users
678
- </Tab>
679
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
680
- Containers
681
- </Tab>
682
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
683
- Database
684
- </Tab>
685
- <Tab eventKey={3} title={<TabTitleText>Server</TabTitleText>}>
686
- Server
687
- </Tab>
688
- <Tab eventKey={4} title={<TabTitleText>System</TabTitleText>}>
689
- System
690
- </Tab>
691
- <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>}>
692
- Network
693
- </Tab>
694
- </Tabs>
695
- <div style={{ marginTop: '20px' }}>
696
- <Checkbox
697
- label="isBox"
698
- isChecked={isBox}
699
- onChange={this.toggleBox}
700
- aria-label="show box variation checkbox with inset"
701
- id="toggle-box-inset"
702
- name="toggle-box-inset"
703
- />
704
- </div>
705
- </div>
706
- );
707
- }
708
- }
77
+ ```ts file="./TabsInset.tsx"
709
78
  ```
710
79
 
711
80
  ### Page Insets
712
81
 
713
- ```js
714
- import React from 'react';
715
- import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core';
716
-
717
- class PageInsetsTabs extends React.Component {
718
- constructor(props) {
719
- super(props);
720
- this.state = {
721
- activeTabKey: 0,
722
- isBox: false
723
- };
724
- // Toggle currently active tab
725
- this.handleTabClick = (event, tabIndex) => {
726
- this.setState({
727
- activeTabKey: tabIndex
728
- });
729
- };
730
-
731
- this.toggleBox = checked => {
732
- this.setState({
733
- isBox: checked
734
- });
735
- };
736
- }
737
-
738
- render() {
739
- const { activeTabKey, isBox } = this.state;
740
- return (
741
- <div>
742
- <Tabs
743
- activeKey={activeTabKey}
744
- onSelect={this.handleTabClick}
745
- usePageInsets
746
- isBox={isBox}
747
- aria-label="Tabs in the page insets example"
748
- role="region"
749
- >
750
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Page insets example content users">
751
- Users
752
- </Tab>
753
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
754
- Containers
755
- </Tab>
756
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
757
- Database
758
- </Tab>
759
- <Tab eventKey={3} title={<TabTitleText>Server</TabTitleText>}>
760
- Server
761
- </Tab>
762
- <Tab eventKey={4} title={<TabTitleText>System</TabTitleText>}>
763
- System
764
- </Tab>
765
- <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>}>
766
- Network
767
- </Tab>
768
- </Tabs>
769
- <div style={{ marginTop: '20px' }}>
770
- <Checkbox
771
- label="isBox"
772
- isChecked={isBox}
773
- onChange={this.toggleBox}
774
- aria-label="show box variation checkbox with inset"
775
- id="toggle-box-page-inset"
776
- name="toggle-box-page-inset"
777
- />
778
- </div>
779
- </div>
780
- );
781
- }
782
- }
82
+ ```ts file="./TabsPageInsets.tsx"
783
83
  ```
784
84
 
785
85
  ### Icons and text
786
86
 
787
- ```js
788
- import React from 'react';
789
- import { Tabs, Tab, TabTitleText, TabTitleIcon } from '@patternfly/react-core';
790
- import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon';
791
- import BoxIcon from '@patternfly/react-icons/dist/esm/icons/box-icon';
792
- import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon';
793
- import ServerIcon from '@patternfly/react-icons/dist/esm/icons/server-icon';
794
- import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon';
795
- import ProjectDiagramIcon from '@patternfly/react-icons/dist/esm/icons/project-diagram-icon';
796
-
797
- class IconAndTextTabs extends React.Component {
798
- constructor(props) {
799
- super(props);
800
- this.state = {
801
- activeTabKey: 0
802
- };
803
- // Toggle currently active tab
804
- this.handleTabClick = (event, tabIndex) => {
805
- this.setState({
806
- activeTabKey: tabIndex
807
- });
808
- };
809
- }
810
-
811
- render() {
812
- return (
813
- <Tabs
814
- activeKey={this.state.activeTabKey}
815
- onSelect={this.handleTabClick}
816
- aria-label="Tabs in the icons and text example"
817
- role="region"
818
- >
819
- <Tab
820
- eventKey={0}
821
- title={
822
- <>
823
- <TabTitleIcon>
824
- <UsersIcon />
825
- </TabTitleIcon>{' '}
826
- <TabTitleText>Users</TabTitleText>{' '}
827
- </>
828
- }
829
- aria-label="icons and text content"
830
- >
831
- Users
832
- </Tab>
833
- <Tab
834
- eventKey={1}
835
- title={
836
- <>
837
- <TabTitleIcon>
838
- <BoxIcon />
839
- </TabTitleIcon>{' '}
840
- <TabTitleText>Containers</TabTitleText>{' '}
841
- </>
842
- }
843
- >
844
- Containers
845
- </Tab>
846
- <Tab
847
- eventKey={2}
848
- title={
849
- <>
850
- <TabTitleIcon>
851
- <DatabaseIcon />
852
- </TabTitleIcon>{' '}
853
- <TabTitleText>Database</TabTitleText>{' '}
854
- </>
855
- }
856
- >
857
- Database
858
- </Tab>
859
- <Tab
860
- eventKey={3}
861
- title={
862
- <>
863
- <TabTitleIcon>
864
- <ServerIcon />
865
- </TabTitleIcon>{' '}
866
- <TabTitleText>Server</TabTitleText>{' '}
867
- </>
868
- }
869
- >
870
- Server
871
- </Tab>
872
- <Tab
873
- eventKey={4}
874
- title={
875
- <>
876
- <TabTitleIcon>
877
- <LaptopIcon />
878
- </TabTitleIcon>{' '}
879
- <TabTitleText>System</TabTitleText>{' '}
880
- </>
881
- }
882
- >
883
- System
884
- </Tab>
885
- <Tab
886
- eventKey={6}
887
- title={
888
- <>
889
- <TabTitleIcon>
890
- <ProjectDiagramIcon />
891
- </TabTitleIcon>{' '}
892
- <TabTitleText>Network</TabTitleText>{' '}
893
- </>
894
- }
895
- >
896
- Network
897
- </Tab>
898
- </Tabs>
899
- );
900
- }
901
- }
87
+ ```ts file="./TabsIconAndText.tsx"
902
88
  ```
903
89
 
904
90
  ### Tabs with sub tabs
905
91
 
906
- ```js
907
- import React from 'react';
908
- import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core';
909
-
910
- class SecondaryTabs extends React.Component {
911
- constructor(props) {
912
- super(props);
913
- this.state = {
914
- activeTabKey1: 0,
915
- activeTabKey2: 10,
916
- isBox: false
917
- };
918
- // Toggle currently active tab
919
- this.handleTabClickFirst = (event, tabIndex) => {
920
- this.setState({
921
- activeTabKey1: tabIndex
922
- });
923
- };
924
- // Toggle currently active secondary tab
925
- this.handleTabClickSecond = (event, tabIndex) => {
926
- this.setState({
927
- activeTabKey2: tabIndex
928
- });
929
- };
930
-
931
- this.toggleBox = checked => {
932
- this.setState({
933
- isBox: checked
934
- });
935
- };
936
- }
937
-
938
- render() {
939
- const { activeTabKey1, activeTabKey2, isBox } = this.state;
940
- return (
941
- <div>
942
- <Tabs
943
- activeKey={activeTabKey1}
944
- onSelect={this.handleTabClickFirst}
945
- isBox={isBox}
946
- aria-label="Tabs in the tabs with subtabs example"
947
- role="region"
948
- >
949
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Tabs with subtabs content users">
950
- <Tabs
951
- aria-label="secondary tabs for users"
952
- role="region"
953
- activeKey={activeTabKey2}
954
- isSecondary
955
- onSelect={this.handleTabClickSecond}
956
- >
957
- <Tab eventKey={20} title={<TabTitleText>Secondary tab item 1</TabTitleText>}>
958
- Secondary tab item 1 item section
959
- </Tab>
960
- <Tab eventKey={21} title={<TabTitleText>Secondary tab item 2</TabTitleText>}>
961
- Secondary tab item 2 section
962
- </Tab>
963
- <Tab eventKey={22} title={<TabTitleText>Secondary tab item 3</TabTitleText>}>
964
- Secondary tab item 3 section
965
- </Tab>
966
- <Tab eventKey={23} title={<TabTitleText>Secondary tab item 4</TabTitleText>}>
967
- Secondary tab item 4 section
968
- </Tab>
969
- <Tab eventKey={24} title={<TabTitleText>Secondary tab item 5</TabTitleText>}>
970
- Secondary tab item 5 section
971
- </Tab>
972
- <Tab eventKey={25} title={<TabTitleText>Secondary tab item 6</TabTitleText>}>
973
- Secondary tab item 6 section
974
- </Tab>
975
- <Tab eventKey={26} title={<TabTitleText>Secondary tab item 7</TabTitleText>}>
976
- Secondary tab item 7 section
977
- </Tab>
978
- <Tab eventKey={27} title={<TabTitleText>Secondary tab item 8</TabTitleText>}>
979
- Secondary tab item 8 section
980
- </Tab>
981
- </Tabs>
982
- </Tab>
983
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
984
- Containers
985
- </Tab>
986
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
987
- Database
988
- </Tab>
989
- <Tab eventKey={3} title={<TabTitleText>Server</TabTitleText>}>
990
- Server
991
- </Tab>
992
- <Tab eventKey={4} title={<TabTitleText>System</TabTitleText>}>
993
- System
994
- </Tab>
995
- <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>}>
996
- Network
997
- </Tab>
998
- <Tab eventKey={7} title={<TabTitleText>Tab item 7</TabTitleText>}>
999
- Tab 7 section
1000
- </Tab>
1001
- <Tab eventKey={8} title={<TabTitleText>Tab item 8</TabTitleText>}>
1002
- Tab 8 section
1003
- </Tab>
1004
- <Tab eventKey={9} title={<TabTitleText>Tab item 9</TabTitleText>}>
1005
- Tab 9 section
1006
- </Tab>
1007
- <Tab eventKey={10} title={<TabTitleText>Tab item 10</TabTitleText>}>
1008
- Tab 10 section
1009
- </Tab>
1010
- <Tab eventKey={11} title={<TabTitleText>Tab item 11</TabTitleText>}>
1011
- Tab 11 section
1012
- </Tab>
1013
- </Tabs>
1014
- <div style={{ marginTop: '20px' }}>
1015
- <Checkbox
1016
- label="isBox"
1017
- isChecked={isBox}
1018
- onChange={this.toggleBox}
1019
- aria-label="show box variation checkbox with sub tabs"
1020
- id="toggle-box-secondary"
1021
- name="toggle-box-secondary"
1022
- />
1023
- </div>
1024
- </div>
1025
- );
1026
- }
1027
- }
92
+ ```ts file="./TabsSubtabs.tsx"
1028
93
  ```
1029
94
 
1030
95
  ### Filled
1031
96
 
1032
- ```js
1033
- import React from 'react';
1034
- import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core';
1035
-
1036
- class FilledTabs extends React.Component {
1037
- constructor(props) {
1038
- super(props);
1039
- this.state = {
1040
- activeTabKey: 0,
1041
- isBox: false
1042
- };
1043
- // Toggle currently active tab
1044
- this.handleTabClick = (event, tabIndex) => {
1045
- this.setState({
1046
- activeTabKey: tabIndex
1047
- });
1048
- };
1049
-
1050
- this.toggleBox = checked => {
1051
- this.setState({
1052
- isBox: checked
1053
- });
1054
- };
1055
- }
1056
-
1057
- render() {
1058
- const { activeTabKey, isBox } = this.state;
1059
- return (
1060
- <div>
1061
- <Tabs
1062
- isFilled
1063
- activeKey={activeTabKey}
1064
- onSelect={this.handleTabClick}
1065
- isBox={isBox}
1066
- aria-label="Tabs in the filled example"
1067
- role="region"
1068
- >
1069
- <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Tabs filled example content users">
1070
- Users
1071
- </Tab>
1072
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
1073
- Containers
1074
- </Tab>
1075
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
1076
- Database
1077
- </Tab>
1078
- </Tabs>
1079
- <div style={{ marginTop: '20px' }}>
1080
- <Checkbox
1081
- label="isBox"
1082
- isChecked={isBox}
1083
- onChange={this.toggleBox}
1084
- aria-label="show box variation checkbox with filled tabs"
1085
- id="toggle-box-filled"
1086
- name="toggle-box-filled"
1087
- />
1088
- </div>
1089
- </div>
1090
- );
1091
- }
1092
- }
97
+ ```ts file="TabsFilled.tsx"
1093
98
  ```
1094
99
 
1095
100
  ### Filled with icons
1096
101
 
1097
- ```js
1098
- import React from 'react';
1099
- import { Tabs, Tab, TabTitleText, TabTitleIcon, Checkbox } from '@patternfly/react-core';
1100
- import UsersIcon from '@patternfly/react-icons/dist/esm/icons/users-icon';
1101
- import BoxIcon from '@patternfly/react-icons/dist/esm/icons/box-icon';
1102
- import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon';
1103
-
1104
- class FilledTabsWithIcons extends React.Component {
1105
- constructor(props) {
1106
- super(props);
1107
- this.state = {
1108
- activeTabKey: 0,
1109
- isBox: false
1110
- };
1111
- // Toggle currently active tab
1112
- this.handleTabClick = (event, tabIndex) => {
1113
- this.setState({
1114
- activeTabKey: tabIndex
1115
- });
1116
- };
1117
-
1118
- this.toggleBox = checked => {
1119
- this.setState({
1120
- isBox: checked
1121
- });
1122
- };
1123
- }
1124
-
1125
- render() {
1126
- const { activeTabKey, isBox } = this.state;
1127
- return (
1128
- <div>
1129
- <Tabs
1130
- isFilled
1131
- activeKey={activeTabKey}
1132
- onSelect={this.handleTabClick}
1133
- isBox={isBox}
1134
- aria-label="Tabs in the filled with icons example"
1135
- role="region"
1136
- >
1137
- <Tab
1138
- eventKey={0}
1139
- title={
1140
- <>
1141
- <TabTitleIcon>
1142
- <UsersIcon />
1143
- </TabTitleIcon>{' '}
1144
- <TabTitleText>Users</TabTitleText>{' '}
1145
- </>
1146
- }
1147
- aria-label="filled tabs with icons content users"
1148
- >
1149
- Users
1150
- </Tab>
1151
- <Tab
1152
- eventKey={1}
1153
- title={
1154
- <>
1155
- <TabTitleIcon>
1156
- <BoxIcon />
1157
- </TabTitleIcon>{' '}
1158
- <TabTitleText>Containers</TabTitleText>{' '}
1159
- </>
1160
- }
1161
- >
1162
- Containers
1163
- </Tab>
1164
- <Tab
1165
- eventKey={2}
1166
- title={
1167
- <>
1168
- <TabTitleIcon>
1169
- <DatabaseIcon />
1170
- </TabTitleIcon>{' '}
1171
- <TabTitleText>Database</TabTitleText>{' '}
1172
- </>
1173
- }
1174
- >
1175
- Database
1176
- </Tab>
1177
- </Tabs>
1178
- <div style={{ marginTop: '20px' }}>
1179
- <Checkbox
1180
- label="isBox"
1181
- isChecked={isBox}
1182
- onChange={this.toggleBox}
1183
- aria-label="show box variation checkbox with filled icon tabs"
1184
- id="toggle-box-filled-icon"
1185
- name="toggle-box-filled-icon"
1186
- />
1187
- </div>
1188
- </div>
1189
- );
1190
- }
1191
- }
102
+ ```ts file="./TabsFilledWithIcons.tsx"
1192
103
  ```
1193
104
 
1194
105
  ### Using the nav element
1195
106
 
1196
- ```js
1197
- import React from 'react';
1198
- import { Tabs, Tab, TabsComponent, TabTitleText } from '@patternfly/react-core';
1199
-
1200
- class TabsNav extends React.Component {
1201
- constructor(props) {
1202
- super(props);
1203
- this.state = {
1204
- activeTabKey: 0
1205
- };
1206
-
1207
- // Toggle currently active tab
1208
- this.handleTabClick = (event, tabIndex) => {
1209
- this.setState({
1210
- activeTabKey: tabIndex
1211
- });
1212
- };
1213
- }
1214
-
1215
- render() {
1216
- return (
1217
- <Tabs
1218
- activeKey={this.state.activeTabKey}
1219
- onSelect={this.handleTabClick}
1220
- component={TabsComponent.nav}
1221
- aria-label="Tabs in the nav element example"
1222
- >
1223
- <Tab
1224
- eventKey={0}
1225
- title={<TabTitleText>Users</TabTitleText>}
1226
- href="#users"
1227
- aria-label="Nav element content users"
1228
- >
1229
- Users
1230
- </Tab>
1231
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>} href="#containers">
1232
- Containers
1233
- </Tab>
1234
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>} href="#database">
1235
- Database
1236
- </Tab>
1237
- <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled href="#disabled">
1238
- Disabled
1239
- </Tab>
1240
- <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled href="#aria-disabled">
1241
- ARIA Disabled
1242
- </Tab>
1243
- <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>} href="#network">
1244
- Network
1245
- </Tab>
1246
- </Tabs>
1247
- );
1248
- }
1249
- }
107
+ ```ts file="./TabsNav.tsx"
1250
108
  ```
1251
109
 
1252
110
  ### Sub nav using the nav element
1253
111
 
1254
- ```js
1255
- import React from 'react';
1256
- import { Tabs, Tab, TabsComponent, TabTitleText } from '@patternfly/react-core';
1257
-
1258
- class SecondaryTabsNav extends React.Component {
1259
- constructor(props) {
1260
- super(props);
1261
- this.state = {
1262
- activeTabKey1: 0,
1263
- activeTabKey2: 10
1264
- };
1265
-
1266
- // Toggle currently active tab
1267
- this.handleTabClickFirst = (event, tabIndex) => {
1268
- this.setState({
1269
- activeTabKey1: tabIndex
1270
- });
1271
- };
1272
-
1273
- // Toggle currently active secondary tab
1274
- this.handleTabClickSecond = (event, tabIndex) => {
1275
- this.setState({
1276
- activeTabKey2: tabIndex
1277
- });
1278
- };
1279
- }
1280
-
1281
- render() {
1282
- return (
1283
- <Tabs
1284
- activeKey={this.state.activeTabKey1}
1285
- onSelect={this.handleTabClickFirst}
1286
- component={TabsComponent.nav}
1287
- aria-label="Tabs in the sub tabs with nav element example"
1288
- >
1289
- <Tab
1290
- eventKey={0}
1291
- title={<TabTitleText>Users</TabTitleText>}
1292
- href="#"
1293
- aria-label="Subtabs with nav content users"
1294
- >
1295
- <Tabs
1296
- activeKey={this.state.activeTabKey2}
1297
- isSecondary
1298
- onSelect={this.handleTabClickSecond}
1299
- aria-label="Local secondary"
1300
- component={TabsComponent.nav}
1301
- >
1302
- <Tab eventKey={20} title={<TabTitleText>Item 1</TabTitleText>} href="#">
1303
- Item 1 item section
1304
- </Tab>
1305
- <Tab eventKey={21} title={<TabTitleText>Item 2</TabTitleText>} href="#">
1306
- Item 2 section
1307
- </Tab>
1308
- <Tab eventKey={22} title={<TabTitleText>Item 3</TabTitleText>} href="#">
1309
- Item 3 section
1310
- </Tab>
1311
- <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled href="#">
1312
- Disabled
1313
- </Tab>
1314
- <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled href="#">
1315
- ARIA Disabled
1316
- </Tab>
1317
- <Tab eventKey={25} title={<TabTitleText>Item 6</TabTitleText>} href="#">
1318
- Item 6 section
1319
- </Tab>
1320
- </Tabs>
1321
- </Tab>
1322
- <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>} href="#">
1323
- Containers
1324
- </Tab>
1325
- <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>} href="#">
1326
- Database
1327
- </Tab>
1328
- <Tab eventKey={3} title={<TabTitleText>Disabled</TabTitleText>} isDisabled href="#">
1329
- Disabled
1330
- </Tab>
1331
- <Tab eventKey={4} title={<TabTitleText>ARIA Disabled</TabTitleText>} isAriaDisabled href="#">
1332
- ARIA Disabled
1333
- </Tab>
1334
- <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>} href="#">
1335
- Network
1336
- </Tab>
1337
- </Tabs>
1338
- );
1339
- }
1340
- }
112
+ ```ts file="./TabsNavSecondary.tsx"
1341
113
  ```
1342
114
 
1343
115
  ### Separate content
1344
116
 
1345
- ```js
1346
- import React from 'react';
1347
- import { Tabs, Tab, TabTitleText, TabContent } from '@patternfly/react-core';
1348
-
1349
- class SeparateTabContent extends React.Component {
1350
- constructor(props) {
1351
- super(props);
1352
- this.state = {
1353
- activeKey: 0
1354
- };
1355
-
1356
- this.contentRef1 = React.createRef();
1357
- this.contentRef2 = React.createRef();
1358
- this.contentRef3 = React.createRef();
1359
-
1360
- // Toggle currently active tab
1361
- this.handleTabClick = (event, tabIndex) => {
1362
- this.setState({
1363
- activeTabKey: tabIndex
1364
- });
1365
- };
1366
- }
1367
-
1368
- render() {
1369
- return (
1370
- <React.Fragment>
1371
- <Tabs
1372
- activeKey={this.state.activeTabKey}
1373
- onSelect={this.handleTabClick}
1374
- aria-label="Tabs in the seperate content example"
1375
- role="region"
1376
- >
1377
- <Tab
1378
- eventKey={0}
1379
- title={<TabTitleText>Tab item 1</TabTitleText>}
1380
- tabContentId="refTab1Section"
1381
- tabContentRef={this.contentRef1}
1382
- />
1383
- <Tab
1384
- eventKey={1}
1385
- title={<TabTitleText>Tab item 2</TabTitleText>}
1386
- tabContentId="refTab2Section"
1387
- tabContentRef={this.contentRef2}
1388
- />
1389
- <Tab
1390
- eventKey={2}
1391
- title={<TabTitleText>Tab item 3</TabTitleText>}
1392
- tabContentId="refTab3Section"
1393
- tabContentRef={this.contentRef3}
1394
- />
1395
- </Tabs>
1396
- <div>
1397
- <TabContent
1398
- eventKey={0}
1399
- id="refTab1Section"
1400
- ref={this.contentRef1}
1401
- aria-label="This is content for the first separate content tab"
1402
- >
1403
- Tab 1 section
1404
- </TabContent>
1405
- <TabContent
1406
- eventKey={1}
1407
- id="refTab2Section"
1408
- ref={this.contentRef2}
1409
- aria-label="This is content for the second separate content tab"
1410
- hidden
1411
- >
1412
- Tab 2 section
1413
- </TabContent>
1414
- <TabContent
1415
- eventKey={2}
1416
- id="refTab3Section"
1417
- ref={this.contentRef3}
1418
- aria-label="This is content for the third separate content tab"
1419
- hidden
1420
- >
1421
- Tab 3 section
1422
- </TabContent>
1423
- </div>
1424
- </React.Fragment>
1425
- );
1426
- }
1427
- }
117
+ ```ts file="./TabsSeparateContent.tsx"
1428
118
  ```
1429
119
 
1430
120
  ### Tab content with body and padding
1431
121
 
1432
- ```js
1433
- import React from 'react';
1434
- import { Tabs, Tab, TabTitleText, TabContent, TabContentBody } from '@patternfly/react-core';
1435
-
1436
- const TabContentWithBody = () => {
1437
- const [activeTabKey, setActiveTabKey] = React.useState(0);
1438
-
1439
- // Toggle currently active tab
1440
- const handleTabClick = (event, tabIndex) => {
1441
- setActiveTabKey(tabIndex);
1442
- };
1443
-
1444
- const contentRef1 = React.createRef();
1445
- const contentRef2 = React.createRef();
1446
- const contentRef3 = React.createRef();
1447
-
1448
- return (
1449
- <React.Fragment>
1450
- <Tabs
1451
- activeKey={activeTabKey}
1452
- onSelect={handleTabClick}
1453
- aria-label="Tabs in the body and padding example"
1454
- role="region"
1455
- >
1456
- <Tab
1457
- eventKey={0}
1458
- title={<TabTitleText>Tab item 1</TabTitleText>}
1459
- tabContentId="tab1SectionBodyPadding"
1460
- tabContentRef={contentRef1}
1461
- />
1462
- <Tab
1463
- eventKey={1}
1464
- title={<TabTitleText>Tab item 2</TabTitleText>}
1465
- tabContentId="tab2SectionBodyPadding"
1466
- tabContentRef={contentRef2}
1467
- />
1468
- <Tab
1469
- eventKey={2}
1470
- title={<TabTitleText>Tab item 3</TabTitleText>}
1471
- tabContentId="tab3SectionBodyPadding"
1472
- tabContentRef={contentRef3}
1473
- />
1474
- </Tabs>
1475
- <div>
1476
- <TabContent eventKey={0} id="tab1SectionBodyPadding" ref={contentRef1}>
1477
- <TabContentBody hasPadding> Tab 1 section with body and padding </TabContentBody>
1478
- </TabContent>
1479
- <TabContent eventKey={1} id="tab2SectionBodyPadding" ref={contentRef2} hidden>
1480
- <TabContentBody hasPadding> Tab 2 section with body and padding </TabContentBody>
1481
- </TabContent>
1482
- <TabContent eventKey={2} id="tab3SectionBodyPadding" ref={contentRef3} hidden>
1483
- <TabContentBody hasPadding> Tab 3 section with body and padding </TabContentBody>
1484
- </TabContent>
1485
- </div>
1486
- </React.Fragment>
1487
- );
1488
- };
122
+ ```ts file="./TabsContentWithBodyPadding.tsx"
1489
123
  ```
1490
124
 
1491
125
  ### Children mounting on click
1492
126
 
1493
- ```js
1494
- import React from 'react';
1495
- import { Tabs, Tab, TabTitleText } from '@patternfly/react-core';
1496
-
1497
- class MountingSimpleTabs extends React.Component {
1498
- constructor(props) {
1499
- super(props);
1500
- this.state = {
1501
- activeTabKey: 0
1502
- };
1503
- // Toggle currently active tab
1504
- this.handleTabClick = (event, tabIndex) => {
1505
- this.setState({
1506
- activeTabKey: tabIndex
1507
- });
1508
- };
1509
- }
1510
-
1511
- render() {
1512
- return (
1513
- <Tabs
1514
- mountOnEnter
1515
- activeKey={this.state.activeTabKey}
1516
- onSelect={this.handleTabClick}
1517
- aria-label="Tabs in the children mounting on click example"
1518
- role="region"
1519
- >
1520
- <Tab eventKey={0} title={<TabTitleText>Tab item 1</TabTitleText>} aria-label="Tab 1">
1521
- Tab 1 section
1522
- </Tab>
1523
- <Tab eventKey={1} title={<TabTitleText>Tab item 2</TabTitleText>} aria-label="Tab 2">
1524
- Tab 2 section
1525
- </Tab>
1526
- <Tab eventKey={2} title={<TabTitleText>Tab item 3</TabTitleText>} aria-label="Tab 3">
1527
- Tab 3 section
1528
- </Tab>
1529
- </Tabs>
1530
- );
1531
- }
1532
- }
127
+ ```ts file="./TabsChildrenMounting.tsx"
1533
128
  ```
1534
129
 
1535
130
  ### Unmounting invisible children
1536
131
 
1537
- ```js
1538
- import React from 'react';
1539
- import { Tabs, Tab, TabTitleText } from '@patternfly/react-core';
1540
-
1541
- class UnmountingSimpleTabs extends React.Component {
1542
- constructor(props) {
1543
- super(props);
1544
- this.state = {
1545
- activeTabKey: 0
1546
- };
1547
- // Toggle currently active tab
1548
- this.handleTabClick = (event, tabIndex) => {
1549
- this.setState({
1550
- activeTabKey: tabIndex
1551
- });
1552
- };
1553
- }
1554
-
1555
- render() {
1556
- return (
1557
- <Tabs
1558
- unmountOnExit
1559
- activeKey={this.state.activeTabKey}
1560
- onSelect={this.handleTabClick}
1561
- aria-label="Tabs in the unmounting invisible children example"
1562
- role="region"
1563
- >
1564
- <Tab eventKey={0} title={<TabTitleText>Tab item 1</TabTitleText>} aria-label="Invisible children tab 1">
1565
- Tab 1 section
1566
- </Tab>
1567
- <Tab eventKey={1} title={<TabTitleText>Tab item 2</TabTitleText>} aria-label="Invisible children tab 2">
1568
- Tab 2 section
1569
- </Tab>
1570
- <Tab eventKey={2} title={<TabTitleText>Tab item 3</TabTitleText>} aria-label="Invisible children tab 3">
1571
- Tab 3 section
1572
- </Tab>
1573
- </Tabs>
1574
- );
1575
- }
1576
- }
132
+ ```ts file="./TabsUnmountingInvisibleChildren.tsx"
1577
133
  ```
1578
134
 
1579
135
  ### Toggled separate content
1580
136
 
1581
- ```js
1582
- import React from 'react';
1583
- import { Tabs, Tab, TabContent, Button, Divider } from '@patternfly/react-core';
1584
-
1585
- class ToggledSeparateContent extends React.Component {
1586
- constructor(props) {
1587
- super(props);
1588
- this.state = {
1589
- activeKey: 0,
1590
- isTab2Hidden: false
1591
- };
1592
-
1593
- this.contentRef1 = React.createRef();
1594
- this.contentRef2 = React.createRef();
1595
- this.contentRef3 = React.createRef();
1596
-
1597
- // Toggle currently active tab
1598
- this.handleTabClick = (event, tabIndex) => {
1599
- this.setState({
1600
- activeTabKey: tabIndex
1601
- });
1602
- };
1603
- }
1604
-
1605
- render() {
1606
- const { activeKey, isTab2Hidden } = this.state;
1607
- return (
1608
- <React.Fragment>
1609
- <Button onClick={() => this.setState({ isTab2Hidden: !isTab2Hidden })}>
1610
- {isTab2Hidden ? 'Show' : 'Hide'} tab 2
1611
- </Button>
1612
- <Divider style={{ paddingTop: '1rem', paddingBottom: '1rem' }} />
1613
- <Tabs
1614
- activeKey={this.state.activeTabKey}
1615
- onSelect={this.handleTabClick}
1616
- aria-label="Tabs in the toggled separate content example"
1617
- role="region"
1618
- >
1619
- <Tab
1620
- eventKey={0}
1621
- title="Tab item 1"
1622
- tabContentId="tab1SectionSeparateContent"
1623
- tabContentRef={this.contentRef1}
1624
- />
1625
- {!isTab2Hidden && (
1626
- <Tab
1627
- eventKey={1}
1628
- title="Tab item 2"
1629
- tabContentId="tab2SectionSeparateContent"
1630
- tabContentRef={this.contentRef2}
1631
- />
1632
- )}
1633
- <Tab
1634
- eventKey={2}
1635
- title="Tab item 3"
1636
- tabContentId="tab3SectionSeparateContent"
1637
- tabContentRef={this.contentRef3}
1638
- />
1639
- </Tabs>
1640
- <div>
1641
- <TabContent
1642
- eventKey={0}
1643
- id="tab1SectionSeparateContent"
1644
- ref={this.contentRef1}
1645
- aria-label="This is content for the first toggled separate content tab"
1646
- >
1647
- Tab 1 section
1648
- </TabContent>
1649
- {!isTab2Hidden && (
1650
- <TabContent
1651
- eventKey={1}
1652
- id="tab2SectionSeparateContent"
1653
- ref={this.contentRef2}
1654
- aria-label="This is content for the second toggled separate content tab"
1655
- hidden
1656
- >
1657
- Tab 2 section
1658
- </TabContent>
1659
- )}
1660
- <TabContent
1661
- eventKey={2}
1662
- id="tab3SectionSeparateContent"
1663
- ref={this.contentRef3}
1664
- aria-label="This is content for the third toggled separate content tab"
1665
- hidden
1666
- >
1667
- Tab 3 section
1668
- </TabContent>
1669
- </div>
1670
- </React.Fragment>
1671
- );
1672
- }
1673
- }
137
+ ```ts file="./TabsToggledSeparateContent.tsx"
1674
138
  ```
1675
139
 
1676
140
  ### Dynamic