Skip to content
Pixelbits
Docs / Icon button
Core

Icon button

A square button for a single icon, with the same variants and pixel dissolve as Button. Pass the icon (any SVG, e.g. from lucide-react) as the child; it is sized to the text.

Installation

npm: import
import { IconButton } from "pixelbits/icon-button";
shadcn: copy the source
npx shadcn add https://pixelbits.ali-moradi-develop.com/r/icon-button.json

API

<IconButton>

A square button for a single icon, with the same variants and pixel dissolve as Button. Pass the icon (any SVG, e.g. from lucide-react) as the child; it is sized to the text.

Example
<IconButton aria-label="Close" variant="ghost" onClick={close}>
  <XIcon />
</IconButton>
PropTypeDefaultDescription
size"sm" | "md" | "lg""md"

Square size: "sm" 32 px, "md" 40 px, "lg" 48 px.

aria-label*string—

Accessible name, read by screen readers. Required: an icon alone has no text, e.g. aria-label="Close".

Also accepts every prop of Omit<ButtonProps, "size">.