Skip to content

Commit f7a25e9

Browse files
committed
add example
Signed-off-by: gitdallas <[email protected]>
1 parent e76636d commit f7a25e9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/react-core/src/components/ExpandableSection/examples/ExpandableSection.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle
2828

2929
```
3030

31+
### Uncontrolled with dynamic toggle content (function)
32+
33+
Use `toggleContent` as a function to dynamically render different content based on the expanded state without managing state yourself.
34+
35+
```ts file="ExpandableSectionUncontrolledDynamicToggleFunction.tsx"
36+
37+
```
38+
3139
### Detached
3240

3341
When passing the `isDetached` property into `<ExpandableSection>`, you must also manually pass in the same `toggleId` and `contentId` properties to both `<ExpandableSection>` and `<ExpandableSectionToggle>`. This will link the content to the toggle via ARIA attributes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ExpandableSection } from '@patternfly/react-core';
2+
3+
export const ExpandableSectionUncontrolledDynamicToggleFunction: React.FunctionComponent = () => (
4+
<ExpandableSection
5+
toggleContent={(isExpanded) =>
6+
isExpanded
7+
? 'Show less uncontrolled dynamic toggle example content'
8+
: 'Show more uncontrolled dynamic toggle example content'
9+
}
10+
>
11+
This content is visible only when the component is expanded.
12+
</ExpandableSection>
13+
);

0 commit comments

Comments
 (0)