Debian Codegraph @

node/@patternfly/react-core/src/components/Tabs/examples/TabsFilled.tsx

raw
1 import { useState } from 'react';
2 import { Tabs, Tab, TabTitleText, Checkbox } from '@patternfly/react-core';
3
4 export const TabsFilled: React.FunctionComponent = () => {
5 const [activeTabKey, setActiveTabKey] = useState<string | number>(0);
6 const [isBox, setIsBox] = useState<boolean>(false);
7 // Toggle currently active tab
8 const handleTabClick = (
9 event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent,
10 tabIndex: string | number
11 ) => {
12 setActiveTabKey(tabIndex);
13 };
14
15 const toggleBox = (checked: boolean) => {
16 setIsBox(checked);
17 };
18
19 return (
20 <div>
21 <Tabs
22 isFilled
23 activeKey={activeTabKey}
24 onSelect={handleTabClick}
25 isBox={isBox}
26 aria-label="Tabs in the filled example"
27 role="region"
28 >
29 <Tab eventKey={0} title={<TabTitleText>Users</TabTitleText>} aria-label="Tabs filled example content users">
30 Users
31 </Tab>
32 <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
33 Containers
34 </Tab>
35 <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
36 Database
37 </Tab>
38 </Tabs>
39 <div style={{ marginTop: '20px' }}>
40 <Checkbox
41 label="isBox"
42 isChecked={isBox}
43 onChange={(_event, checked) => toggleBox(checked)}
44 aria-label="show box variation checkbox with filled tabs"
45 id="toggle-box-filled"
46 name="toggle-box-filled"
47 />
48 </div>
49 </div>
50 );
51 };