Show More

Truncate long text with an animated Show More / Show Less toggle.

Example

Installation

Install following dependencies:

npm install react-aria-components tw-animate-css tailwindcss-react-aria-components class-variance-authority lucide-react clsx tailwind-merge motion

Add cn helper using clsx and twMerge for conditional class merging in Tailwind components.

lib/utils.ts

Copy and paste the following code into your project.

components/ui/core/show-more.tsx
npx @libravelui@latest add show-more

Anatomy

import { ShowMoreText } from "@/components/ui/core/show-more";
<ShowMoreText text="Lorem ipsum dolor sit amet." maxLength={100} />

Another Examples

Custom Style and Label

You can apply your own styles and labels, allowing each item to match your design preferences or branding.

Serif Font

You can use a serif font to give the text a more classic or elegant appearance, enhancing readability and style.

Props

Loading types…