Componentform0.41 KB gzipZero dependencies
Char Counter
Character counter with near-limit and over-limit states.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add char-counterOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { CharCounter } from "@/components/ui/char-counter"; <CharCounter />Source code
char-counter.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxchar-counter.tsx35 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface CharCounterProps extends React.HTMLAttributes<HTMLSpanElement> { value: string; max: number; label?: string;} /** Character counter: threshold warning and limit clamp. */export function CharCounter({ value = "", max = 0, label, className, ...props }: CharCounterProps) { const count = value.length; const over = count > max; const near = !over && count >= max * 0.9; return (Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { CharCounter } from "@/components/ui/char-counter"; <CharCounter />| Prop | Type | Description |
|---|---|---|
| value | string | Controlled value. (Default: "") |
| max | number | Maximum allowed numeric or date bound. (Default: 0) |
| label | string | Accessible label text rendered or attached to the control. |