Skip to content
Klarhimmel UI

Icon button

npx shadcn add @klarhimmel/icon-button

Examples

  • Variants

  • Toolbar

  • Toggle

DetailsAbout, usage, props and more

A button with only an icon. The label is its accessible name and its tooltip, so it can never be unnamed.

When to use

  • Use for

    Toolbars, table rows and tight corners: close, share, bold.

  • Not for

    Anything a word would explain better. Use Button.

  • Pairs with

    Tooltip (built in), Menu triggers, toolbars.

Preview

Ghost, soft, secondary, primary and disabled. Hover or tab to a button for its name.

icon-button.tsx
import { Bell } from 'lucide-react';
import { Theme } from '@/components/klarhimmel/theme/style';
import { IconButton } from '@/components/klarhimmel/ui/icon-button';

export default function Example() {
  return (
    <Theme theme="brand">
      <IconButton label="Notifications" shortcut="N">
        <Bell aria-hidden className="size-5" />
      </IconButton>
    </Theme>
  );
}

Import

Import

import { IconButton } from '@/components/klarhimmel/ui/icon-button';
Files
icon-button.tsx, in components/klarhimmel/ui/. With it: editing, theme, tooltip, utils.
Render in
Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Limit
Overlays render into the Theme root with position: fixed. A transform on an ancestor re-parents fixed (a dialog centres in the wrapper) and overflow: hidden clips menus. Render <Theme> at the app root, outside any transformed wrapper.

Props

PropTypeDefaultDescription
labelstringrequiredRequired: the accessible name, also shown as the tooltip.
shortcutstring-A shortcut shown next to the label in the tooltip.
size'sm' | 'md' | 'lg''md'The small size is 36 px with a 44 px hit area.
variant'ghost' | 'soft' | 'secondary' | 'primary''ghost'Visual style.
activeboolean-A toggle button: sets aria-pressed and the pressed look.
childrenReactNoderequired
noTooltipboolean-Skip the tooltip when the label is already visible nearby.
tooltipSide'top' | 'right' | 'bottom' | 'left'-Where the tooltip opens and the hover delay in ms.
tooltipDelaynumber-Where the tooltip opens and the hover delay in ms.
native attributesButtonHTMLAttributes-Every native attribute of the element passes through, className included.

Accessibility

KeyDoes
Enter / SpaceActivates the button
TabMoves focus; the tooltip shows with it
EscapeHides the tooltip

The label is required: it is the only name a screen reader hears.

Accessibility