Componentmedia0.5 KB gzipZero dependencies
Truncate
Single/multi-line clamp with optional expand toggle (MORE/LESS)
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add truncateOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { Truncate } from "@/components/ui/truncate" <Truncate lines={2} expandable>...</Truncate>Source code
truncate.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxtruncate.tsx64 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export type TruncateProps = { lines?: number; expandable?: boolean; className?: string; children: React.ReactNode;}; const Truncate = ({ lines = 1, expandable = true, className, children }: TruncateProps) => { const [showMore, setShowMore] = React.useState(false); if (!expandable) { return ( <divProps
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { Truncate } from "@/components/ui/truncate"; <Truncate />| Prop | Type | Description |
|---|---|---|
| lines | number | Number of lines to show before truncation |
| expandable | boolean | Whether to show MORE/LESS toggle |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |
| children | React.ReactNode | Child elements rendered inside the component. |