forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpandableSectionCustomToggle.tsx
More file actions
44 lines (40 loc) · 1.54 KB
/
ExpandableSectionCustomToggle.tsx
File metadata and controls
44 lines (40 loc) · 1.54 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
35
36
37
38
39
40
41
42
43
44
import { useState } from 'react';
import { ExpandableSection, Badge, Stack, StackItem } from '@patternfly/react-core';
import RhUiCheckCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-check-circle-fill-icon';
export const ExpandableSectionCustomToggle: React.FunctionComponent = () => {
const [isExpanded, setIsExpanded] = useState(false);
const onToggle = (_event: React.MouseEvent, isExpanded: boolean) => {
setIsExpanded(isExpanded);
};
return (
<Stack hasGutter>
<StackItem>
<h3>Custom Toggle Content</h3>
<p>You can use custom content such as icons and badges in the toggle:</p>
<ExpandableSection
toggleContent={
<div>
<span>You can also use icons </span>
<RhUiCheckCircleFillIcon />
<span> or badges </span>
<Badge isRead={true}>4</Badge>
<span> !</span>
</div>
}
onToggle={onToggle}
isExpanded={isExpanded}
>
This content is visible only when the component is expanded.
</ExpandableSection>
</StackItem>
<StackItem>
<h3>Accessibility Note</h3>
<p>
<strong>Important:</strong> If you need the toggle text to function as a heading in the document structure, do
NOT put heading elements (h1-h6) inside the <code>toggleContent</code> prop, as this creates invalid HTML
structure. Instead, use the <code>toggleWrapper</code> prop.
</p>
</StackItem>
</Stack>
);
};