Skip to content

Textarea

Labelled multi-line field with a live character counter chip that turns orange near the limit, hint and error states; presses into its shadow on focus.

brutalist/ui/textarea
Open ↗

Source

"use client";

import { useId, useState, type TextareaHTMLAttributes } from "react";
import { cn } from "@/lib/utils";

export interface TextareaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange"> {
  label: string;
  hint?: string;
  error?: string;
  /** Show a live character counter against this limit. */
  maxLength?: number;
  onChange?: (value: string) => void;
  containerClassName?: string;
}

export function Textarea({ label, hint, error, maxLength, onChange, defaultValue, value, id, className, containerClassName, rows = 5, ...props }: TextareaProps) {
  const autoId = useId();
  const fieldId = id ?? autoId;
  const [inner, setInner] = useState(String(defaultValue ?? ""));
  const text = value !== undefined ? String(value) : inner;
  const count = text.length;
  const near = maxLength !== undefined && count > maxLength * 0.9;
  const describedBy = [hint && `${fieldId}-hint`, error && `${fieldId}-error`, maxLength && `${fieldId}-count`].filter(Boolean).join(" ") || undefined;

  return (
    <div className={cn("flex flex-col gap-2", containerClassName)}>
      <div className="flex items-end justify-between gap-4">
        <label htmlFor={fieldId} className="font-da-mono text-xs font-bold tracking-da-label uppercase">
          {label}
        </label>
        {maxLength !== undefined && (
          <span id={`${fieldId}-count`} className={cn("da-stroke px-1.5 font-da-mono text-[11px] font-bold", near ? "bg-da-warning text-da-warning-fg" : "bg-da-surface text-da-surface-fg")}>
            {count}/{maxLength}
          </span>
        )}
      </div>
      <textarea
        id={fieldId}
        rows={rows}
        maxLength={maxLength}
        value={text}
        onChange={(e) => {
          setInner(e.target.value);
          onChange?.(e.target.value);
        }}
        aria-invalid={error ? true : undefined}
        aria-describedby={describedBy}
        className={cn(
          "da-stroke da-transition resize-y bg-da-input p-3 text-base text-da-fg shadow-da-sm outline-none placeholder:text-da-muted-fg",
          "focus-visible:translate-x-[3px] focus-visible:translate-y-[3px] focus-visible:shadow-none focus-visible:outline-[length:var(--da-ring-width)] focus-visible:outline-offset-[var(--da-ring-offset)] focus-visible:outline-da-ring focus-visible:outline-solid",
          error && "shadow-[3px_3px_0_0_var(--da-danger)] [--da-border:var(--da-danger)]",
          className,
        )}
        {...props}
      />
      {hint && !error && (
        <p id={`${fieldId}-hint`} className="text-sm text-da-muted-fg">
          {hint}
        </p>
      )}
      {error && (
        <p id={`${fieldId}-error`} className="text-sm font-bold">
          ! {error}
        </p>
      )}
    </div>
  );
}

export default Textarea;

modules/brutalist/ui/textarea/index.tsx

Props

PropTypeDefaultDescription
label*string—Visible label.
hint / errorstring—Helper or error text (aria-describedby).
maxLengthnumber—Enables the counter and native limit.
onChange(value: string) => void—Receives the new text.
value / defaultValuestring—Controlled / initial text.
...restTextareaHTMLAttributes—Native attributes (rows, name, placeholder…).

Other input variants in Brutalist

Input in other art directions

Combobox

Autocomplete select: a glass pill input that filters a frosted listbox as you type, with arrow-key highlight, Enter to choose, Escape to close, hints and a check on the selection.

GlassInput

Input

Frosted text field with label, hint, error state, leading icon, trailing slot (button, kbd, unit), rounded or pill shape and two sizes. Focus brightens the glass and adds a soft violet halo.

GlassInput

Range Slider

Glass slider on Radix Slider: frosted track, primary→accent range, glowing gradient thumbs with value bubbles on hover/focus and tick labels; single value or range.

GlassInput

Tag Input

Glass chip input: type and press Enter or comma to add gradient chips, Backspace removes the last, × removes one; quick-add suggestion chips and a max counter.

GlassInput

Input

Hairline text field with label (auto "Optional" marker), hint, error with icon, leading icon, text prefix, trailing slot (unit, kbd) and indigo focus ring. Two sizes.

MinimalInput

Search Input

Search field with leading icon, “/” keycap hint that focuses the field, clear button (Escape clears too) and a loading spinner state. Two sizes, controlled or uncontrolled.

MinimalInput

Select Menu

Labelled select built on Radix Select: bordered trigger with chevrons, portalled popover with optional icons, descriptions, groups, separators, disabled items and a check on the selected one.

MinimalInput

Switch Field

Settings row with label and description on the left and a Radix Switch on the right; plain (for divided lists) or bordered card that highlights when on. Disabled state.

MinimalInput

Checkbox Group

Settings checkboxes as ruled rows: square ink check boxes (native inputs), label and muted description; the whole row is clickable.

Mono CleanInput

Input

Underline field: mono uppercase label, a borderless input on a single bottom hairline that turns ink (2px) on focus, optional prefix, hint or red error.

Mono CleanInput

Search Input

Search field with live results: hairline-bordered input with icon and ⌘K hint; matches appear in a ruled list below with the query highlighted and a mono kind label; empty state included.

Mono CleanInput

Select Field

Native select styled as an underline field with a mono label and a custom chevron — reliable on every device and screen reader.

Mono CleanInput

Currency Input

Amount field with currency symbol prefix and an attached currency select; formats with thousands separators on blur, right-aligned mono digits.

Neo CorporateInput

File Upload

Receipt/document dropzone: dashed bordered area with upload icon, click-or-drag, file list with size, per-file size validation errors and remove buttons.

Neo CorporateInput

Input

Form field: label (with optional marker), bordered 40px input with leading/trailing adornments, blue focus ring, hint text or red error with aria-invalid.

Neo CorporateInput

Select Field

Labelled Radix Select styled as a bordered field: grouped options (e.g. GL accounts) with group headings, check on the selected item, portalled popover with data-da.

Neo CorporateInput

Chip Select

Multi-select as soft pill checkboxes: unselected sand pills, selected sage pills with a check that pops in; native checkboxes in a fieldset.

Organic SoftInput

Input

Soft filled text field: rounded sand-filled input that turns cream with a sage ring on focus, optional leading icon and trailing unit, hint or gentle clay error message.

Organic SoftInput

Target Slider

Reduction target picker: a thick rounded sage range (0–60%) with tick labels and a “science-aligned” marker, showing the resulting tonnes and a gentle verdict.

Organic SoftInput

Textarea

Soft note field: rounded sand textarea that auto-grows (field-sizing), with a live character counter that turns clay near the limit.

Organic SoftInput

Checkbox List

Round-checkbox to-do list built on native checkboxes: bouncy mint ticks, strike-through when done, meta line per item and an “x of y” counter with a progress bar.

Soft FlatInput

Day Picker

Week-strip date picker: prev/next week arrows and seven rounded day pills (weekday + number) with task-load dots (red when full); the selected day fills periwinkle.

Soft FlatInput

Input

Soft text field: rounded tinted well that turns white with a thick periwinkle ring on focus, label, optional leading icon and suffix, hint or red error message.

Soft FlatInput

Radio Cards

Native radio group rendered as big pastel cards (emoji, title, text); the chosen card lifts with a periwinkle ring and a filled radio dot.

Soft FlatInput