Skip to content
Haze UI

Icon morph

A named native checkbox with a menu, playback or favorite icon that moves into its checked state.

pnpm dlx shadcn@latest add @haze/icon-morph
Open preview in a new tab
Liveno JavaScript

When to use

  • A small toggle needs a recognizable visual change without a changing layout
  • A navigation, preview or favorite control already has a meaningful checked state

When not to use

  • Use action-swap when the action needs visible text beside its icon
  • Use button for an icon action that does not retain a selected state

Installation

Add the Haze registry to components.json once, then install Icon morph with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/icon-morph
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique caller-supplied prefix for this component and its related elements.
namestringidForm submission name.
labelstring"Toggle navigation"Accessible label describing the checked state.
variant"menu" | "play" | "favorite""menu"Icon pair to draw.
checkedbooleanfalseInitial native checked state.
disabledboolean–Disables the native control and its enhancement.
classstring–Additional classes for the component root.
...attributesnative control attributes–Other attributes are forwarded to the real form control.

Keyboard interactions

Tab, Space
Reach the icon control and toggle its checked state.

Accessibility

  • Only the checkbox is exposed as a control; the drawn icon is decorative.
  • A persistent text label names the toggle, and its checked state is available without JavaScript.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Icon morph" with `npx shadcn@latest add @haze/icon-morph`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import IconMorph from "@/components/haze/ui/icon-morph.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/icon-morph.md

  • Customize with real content

    Adapt the Haze icon-morph ui for our product. Replace the demo values of these props with our real content: id, name, label, variant, checked, disabled, class, ...attributes. Keep the layout, the heading level rules and these accessibility details: Only the checkbox is exposed as a control; the drawn icon is decorative. A persistent text label names the toggle, and its checked state is available without JavaScript. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using icon-morph, check it fits: use it when a small toggle needs a recognizable visual change without a changing layout; a navigation, preview or favorite control already has a meaningful checked state. Avoid it when use action-swap when the action needs visible text beside its icon; use button for an icon action that does not retain a selected state. Alternatives: @haze/action-swap, @haze/toggle, @haze/button.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog