forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpandableSectionDetached.tsx
More file actions
33 lines (30 loc) · 1.1 KB
/
ExpandableSectionDetached.tsx
File metadata and controls
33 lines (30 loc) · 1.1 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
import { useState } from 'react';
import { ExpandableSection, ExpandableSectionToggle, Stack, StackItem } from '@patternfly/react-core';
export const ExpandableSectionDetached: React.FunctionComponent = () => {
const [isExpanded, setIsExpanded] = useState(false);
const onToggle = (isExpanded: boolean) => {
setIsExpanded(isExpanded);
};
const contentId = 'detached-expandable-section-content';
const toggleId = 'detached-expandable-section-toggle';
return (
<Stack hasGutter>
<StackItem>
<ExpandableSection isExpanded={isExpanded} isDetached toggleId={toggleId} contentId={contentId}>
This content is visible only when the component is expanded.
</ExpandableSection>
</StackItem>
<StackItem>
<ExpandableSectionToggle
isExpanded={isExpanded}
onToggle={onToggle}
toggleId={toggleId}
contentId={contentId}
direction="up"
>
{isExpanded ? 'Show less detached example content' : 'Show more detached example content'}
</ExpandableSectionToggle>
</StackItem>
</Stack>
);
};