Icon Bar
Icon chips that spring open on hover to reveal labels.
Icon Bar
Icon chips that spring open on hover to reveal labels.
Hover or focus any chip and its label springs out from the icon well, then retracts when the pointer leaves. Click a chip to lock it open — the active chip keeps its label and a raised accent surface until you click it again to collapse.
Installation
Install the component with the Craft-UI Blocks CLI — it drops icon-bar.tsx into your project and wires up its runtime dependencies:
npx mvpblocks add icon-barpnpm dlx mvpblocks add icon-baryarn dlx mvpblocks add icon-barbunx mvpblocks add icon-barFile Structure
The CLI saves the component to your project's components/ui folder:
Import it from @/components/ui/icon-bar.
Usage
"use client";
import { Building2, Cloud, GraduationCap, Sun } from "lucide-react";
import { IconBar, IconBarItem } from "@/components/ui/icon-bar";
export function IconBarPreview() {
return (
<IconBar>
<IconBarItem icon={Building2} label="Office" />
<IconBarItem icon={GraduationCap} label="School" />
<IconBarItem icon={Sun} label="Sunny" />
<IconBarItem icon={Cloud} label="Cloudy" />
</IconBar>
);
}Each IconBarItem takes a Lucide icon and a short label. Selection is single-choice: click a chip to select it, click the active chip again to deselect and collapse back to the icon-only row. Use defaultValue to start with a chip open, or make the bar fully controlled with value and onValueChange.
Theming
The bar ships its own Iconiq token set, scoped to the IconBar root and mapped onto the standard shadcn variable names (--color-background, --color-foreground, --color-border, --color-muted, --color-accent, --color-ring, and so on), so colors resolve with no separate theme install. In light mode the tokens are a white surface with #111111 ink and a #e3e7ec hairline; in dark mode they flip to a #111111 surface with #f6f3ec ink and a #2b2a25 hairline, driven entirely by dark: overrides on the same variables.
The chip sits on a soft muted fill with muted-foreground ink that lifts to accent/60 and foreground on hover; the selected chip holds the raised accent surface with foreground ink. The icon stays a fixed 18px at 1.5 stroke inside a 36px well so the well never shifts as the label grows, and focus draws a two-stop ring-ring with a ring-offset-background offset for keyboard users.
Animations
- Label reveal: the label sits in a
motion.divwhose width animates from0to the measured label width. Expanding uses a0.62stween and collapsing a snappier0.48s, both on the[0.16, 1, 0.3, 1]fluid ease — so the chip springs open and tucks away rather than snapping. - Measured width: the label's intrinsic width is read from a hidden
aria-hiddenspan with aResizeObserver, and re-measured oncedocument.fonts.readyresolves so the chip lands on the exact width after a webfont swaps in. A label of0width stays collapsed. - Hover / focus preview: hovering or keyboard-focusing a chip sets a local
hoverPreviewthat expands it; leaving or blurring retracts it. Selecting a chip deselects clears the preview and blurs the button so the collapsed row is clean. - Surface transition: the chip's background and text color ease over
300msoncubic-bezier(0.22, 1, 0.36, 1), matching the fluid feel of the expand without moving layout. - Reduced motion: labels are toggled through width and opacity only; there is no transform or scale on the chip, so the bar degrades gracefully when motion is limited.
Props
IconBar
Prop
Type
IconBarItem
Prop
Type
Registry Bundle
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together. Dependencies: @base-ui/react/toggle, @base-ui/react/toggle-group, motion, lucide-react.
Embedded Iconiq theme tokens ship inside the component, so colors resolve without a separate theme install. This page documents the Base UI install only, because Icon Bar uses Base UI Toggle Group and Toggle for selection.
Contact
If you find any bug or issue, feel free to raise an issue.
Last updated on