forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpandableSectionIndented.tsx
More file actions
34 lines (30 loc) · 1.11 KB
/
ExpandableSectionIndented.tsx
File metadata and controls
34 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { FormEvent, useState } from 'react';
import { ExpandableSection, Checkbox } from '@patternfly/react-core';
export const ExpandableSectionIndented: React.FunctionComponent = () => {
const [isExpanded, setIsExpanded] = useState(true);
const [isDisplayLgChecked, setIsDisplayLgChecked] = useState(false);
const onToggle = (_event: React.MouseEvent, isExpanded: boolean) => {
setIsExpanded(isExpanded);
};
const onDisplaySizeCheck = (_event: FormEvent<HTMLInputElement>, checked: boolean) => setIsDisplayLgChecked(checked);
return (
<>
<Checkbox
id="displaySize-checkbox"
isChecked={isDisplayLgChecked}
label='displaySize="lg"'
onChange={onDisplaySizeCheck}
/>
<br />
<ExpandableSection
toggleText={isExpanded ? 'Show less indented example content' : 'Show more indented example content'}
onToggle={onToggle}
isExpanded={isExpanded}
isIndented
displaySize={isDisplayLgChecked ? 'lg' : 'default'}
>
This content is visible only when the component is expanded.
</ExpandableSection>
</>
);
};