Skip to content

Icon Button

A Button that shows only an icon, with a required accessible label and a tooltip-ready target.

0.6 kB gzipSource Registry JSON

IconButton playground

Props

variant
size

Installation

npx shadcn@latest add https://sproutboat.com/ikada/r/icon-button.json

The CLI writes components/ikada/icon-button.tsx and merges the ikada theme into your CSS. It also installs the components it is built from: Button and Tooltip. Or take it from the package: import { IconButton } from "@sproutboat/ikada";

Usage

import { IconButton } from "@/components/ikada/icon-button";

<IconButton label="Refresh" variant="secondary">
  <RefreshIcon />
</IconButton>

Examples

Variants

Ghost is the default: icon buttons sit in toolbars and rows. The label is the name and the tooltip.

Sizes

Without a tooltip

Set tooltip={false} when a parent already explains the button. The label is still its accessible name.

Disabled

Props

IconButtonProps
PropTypeDescription
labelrequiredstringRequired. Becomes the accessible name and the tooltip text.
childrenrequiredReactNodeThe icon. The accessible name comes from `label`.
tooltipbooleanSet false when a parent already explains the button. Default `true`.
classNamestringClasses merged onto the root element, after ikada's own.
styleCSSProperties | ((state: ButtonState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
variant"danger" | "primary" | "secondary" | "ghost" | nullDefault `ghost`.
size"sm" | "md" | "lg" | null—
loadingbooleanShows a spinner, sets aria-busy, ignores clicks, keeps the width and focus.

Also takes every prop of Omit<ButtonProps, "children" | "aria-label">.

Source: src/components/icon-button.tsx