0
Documentation

Morph

Tactile corner-radius morphing, spring curves, and shared sizing tokens for interactive controls.

A CVA utility module that powers shape morphing, press-state corner contraction, and consistent sizing tokens across interactive controls like Button.

Installation

How It Works

morph.tsx pairs three building blocks that work together via CSS custom properties (--r-full, --r-square, --r-pressed, --icon, --iw):

  1. tautSize sets the height, padding, icon size, and all three radius tokens (--r-full, --r-square, --r-pressed) for each size preset (xs through xl, plus icon-* presets).
  2. morphClasses binds an inline linear() spring curve (--taut-spring) to border-radius alongside a subtle box-shadow transition—intentionally omitting color/background transitions so theme switches stay instant. When press is enabled, holding the control morphs its corners to --r-pressed and subtly adjusts variable font grade (GRAD -50).
  3. morphRadius(shape, selected, enabled) resolves whether a control should display "full" or "square" corners, inverting the resting shape when selected and enabled are both true.

All transitions collapse to 0ms automatically under prefers-reduced-motion: reduce.

Usage

Combining morphClasses, tautSize, and morphRadius

Icon Width Presets

Icon sizes (icon-xs, icon-sm, icon, icon-md, icon-lg, icon-xl) support optional width variants (narrow and wide) that override --iw:

API

morphClasses

VariantValuesDefaultDescription
radius"full" | "square""full"Applies --r-full or --r-square border radius.
pressbooleantrueMorphs corners to --r-pressed and shifts GRAD to -50 while active.

morphRadius

ParameterTypeDefaultDescription
shape"round" | "square"—Resting shape of the control.
selectedbooleanundefinedWhen true and enabled is true, inverts the resolved radius.
enabledbooleantrueEnables selection-based shape inversion.

tautSize

VariantValuesDefaultDescription
size"xs" | "sm" | "default" | "md" | "lg" | "xl" | "icon-xs" | "icon-sm" | "icon" | "icon-md" | "icon-lg" | "icon-xl""default"Sets control height, gap, padding, --icon, and radius variables.
width"narrow" | "wide"—Adjusts --iw width on icon-* size variants.

© taut ui — built with Base UI and Tailwind CSS v4.