Componentmedia0.5 KB gzipZero dependencies

Truncate

Single/multi-line clamp with optional expand toggle (MORE/LESS)

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add truncate

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { Truncate } from "@/components/ui/truncate" <Truncate lines={2} expandable>...</Truncate>

Source code

truncate.tsx + 1 helper

Zero 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 (      <div

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { Truncate } from "@/components/ui/truncate"; <Truncate />
PropTypeDescription
linesnumberNumber of lines to show before truncation
expandablebooleanWhether to show MORE/LESS toggle
classNamestringOptional Tailwind or custom CSS classes merged with component styles.
childrenReact.ReactNodeChild elements rendered inside the component.