| 1 |
--- |
| 2 |
id: Expandable section |
| 3 |
section: components |
| 4 |
--- |
| 5 |
|
| 6 |
import { useState } from 'react'; |
| 7 |
|
| 8 |
## Demos |
| 9 |
|
| 10 |
|
| 11 |
### Expandable text with character truncation |
| 12 |
|
| 13 |
You can truncate long sections of text and add a "Show more" link that allows users to expand and view the full text content. |
| 14 |
|
| 15 |
To specify the number of characters shown prior to truncation, use a `<Truncate>` component and pass a `maxWidth` to the `style` attribute. |
| 16 |
|
| 17 |
```ts file='./examples/ExpandableTextDemo.tsx' |
| 18 |
|
| 19 |
``` |