utils

PreviousNext
Docs
wigggle-uilib

Preview

Loading preview…
registry/default/lib/utils.ts
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}

export function truncate(text: string, maxLength = 15): string {
  if (typeof text !== "string") return "";
  if (text.length <= maxLength) return text;
  return text.slice(0, maxLength - 3) + "...";
}

Installation

npx shadcn@latest add @wigggle-ui/utils

Usage

import { Utils } from "@/lib/utils"
Utils()