Componentform0.41 KB gzipZero dependencies

Char Counter

Character counter with near-limit and over-limit states.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

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

npx bigbullui add char-counter

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { CharCounter } from "@/components/ui/char-counter"; <CharCounter />

Source code

char-counter.tsx + 1 helper

Zero 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 />
PropTypeDescription
valuestringControlled value. (Default: "")
maxnumberMaximum allowed numeric or date bound. (Default: 0)
labelstringAccessible label text rendered or attached to the control.