Getting Started
Components
- Accordion
- Advanced Toast
- AlertMessage
- ArrowButton
- Arrows
- Avatar
- Backdrop
- Basic Toast
- Breadcrumb
- Button
- CardBackground
- Card
- Carousel
- Chapters
- ChatBody
- ChatButton
- ChatHeader
- ChatInput
- ChatMessageActions
- ChatMessageEditor
- ChatMessage
- ChatTypingIndicator
- ChatWindowCsatPrompt
- ChatWindowQuote
- ChatWindow
- CheckboxSelect
- Checkbox
- Checkboxes
- Chip
- ChoiceExpander
- Clickable
- ContentReview
- Countdown
- CriteriaDates
- CriteriaParticipants
- CriteriaTransports
- Date Field
- Datepicker
- Dropdown
- ElasticHeight
- ExpandableCard
- ExpandableText
- Filter
- FloatingLabelTextField
- Form Control
- Form Label
- Frame
- HamburgerIcon
- Heading
- Image
- JourneyCard
- LayerHeader
- Layer
- Link
- Loader
- Number Field
- PageNavigation
- Pagination
- Paragraph
- Password
- Phone Field
- Popin
- Portal
- ProductThumbnail
- Promises
- Prose
- Radio Group
- RadioSelect
- Radio
- Range
- Scrollbar
- Select
- SidebarLayout
- SliderFrame
- SparkleWrapper
- Spinner
- Switch
- Table
- Tabs
- Tag
- TextField
- Toggle
- Tooltip
- ValidationMessage
Nestled between the Mediterranean Sea and the mountains, our resort offers an unforgettable all-inclusive experience. Enjoy world-class cuisine, daily activities, and breathtaking views every morning. Our dedicated G.Os are here to ensure every moment of your stay is filled with joy and discovery. From water sports to evening shows, there is something for every member of the family. Book now and create memories that last a lifetime.
'use client';
import { ExpandableText } from '@/ui/ExpandableText';
export function ExpandableTextDemo() {
return (
<div className="max-w-prose space-y-12">
<ExpandableText
id="desc"
labels={{ expand: 'Read more', reduce: 'Show less' }}
lineClamps="line-clamp-3"
>
<p>
Nestled between the Mediterranean Sea and the mountains, our resort offers an
unforgettable all-inclusive experience. Enjoy world-class cuisine, daily activities, and
breathtaking views every morning. Our dedicated G.Os are here to ensure every moment of
your stay is filled with joy and discovery. From water sports to evening shows, there is
something for every member of the family. Book now and create memories that last a
lifetime.
</p>
</ExpandableText>
</div>
);
}
Installation
npx shadcn@latest add https://develop.trident-ui.pro.clubmed/r/expandable-text.json
Usage
import { ExpandableText } from '@/ui/ExpandableText';
export function Component() {
return (
<ExpandableText
id="product-description"
labels={{ expand: 'Read more', reduce: 'Show less' }}
lineClamps="line-clamp-3"
>
<p>Your long text content here…</p>
</ExpandableText>
);
}API Reference
ExpandableText
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | — | Required. ID applied to the inner content wrapper (used by aria-controls). |
labels | ExpandableTextLabels | — | Required. Object with expand and reduce strings for the toggle button. |
lineClamps | string | "line-clamp-3" | A Tailwind line-clamp-* class used to truncate the content when collapsed. |
buttonClassName | string | undefined | Additional classes for the toggle button. |
className | string | undefined | Additional classes for the outer height-animated container. |
children | ReactNode | undefined | The content to display. Renders nothing when absent. |
ExpandableTextLabels
| Field | Type | Description |
|---|---|---|
expand | string | Label for the button when collapsed. |
reduce | string | Label for the button when expanded. |
Notes
- Uses
ResizeObserverinternally to detect when the content overflows — the toggle button only appears when the text actually overflows the clamped height - Height transition is animated via a CSS
--heightcustom property - The component renders nothing when
childrenis falsy - The toggle button uses
aria-controlspointing to theidprop andaria-expandedto communicate state - Works correctly with SSR: height CSS only applies on the client (
useIsClientguard)