# Icon Button

A compact icon-only native button.

A compact icon-only native button.

```tsx
import { CopyIcon, DotsThreeIcon, PlusIcon } from "@phosphor-icons/react";
import { IconButton, Stack } from "@zentara-co/zenos-ui";

function IconButtonPreviewExample() {
  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap" className="justify-center">
      <IconButton aria-label="Add item" variant="primary">
        <PlusIcon />
      </IconButton>
      <IconButton aria-label="Copy item" variant="primary">
        <CopyIcon />
      </IconButton>
      <IconButton aria-label="More actions" variant="ghost">
        <DotsThreeIcon />
      </IconButton>
    </Stack>
  );
}
```

## Import

```tsx
import { IconButton } from "@zentara-co/zenos-ui";
```

Icon-only buttons require an accessible name through `aria-label`. Pass `tooltip` to show a visible label on hover and keyboard focus. `IconButton` supports the shared `variant` and `size="sm | md | lg"` conventions, native button attributes, and ref forwarding.

## Sizes

```tsx
import { PlusIcon } from "@phosphor-icons/react";
import { IconButton, Stack } from "@zentara-co/zenos-ui";

function IconButtonSizesExample() {
  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap">
      {(["sm", "md", "lg"] as const).map((size) => (
        <IconButton key={size} aria-label={`Add item (${size})`} size={size}>
          <PlusIcon />
        </IconButton>
      ))}
    </Stack>
  );
}
```

## Variants

Icon buttons share the Button visual variants.

```tsx
import { PlusIcon } from "@phosphor-icons/react";
import { IconButton, Stack } from "@zentara-co/zenos-ui";

const buttonVariants = [
  "default",
  "primary",
  "ghost",
  "outline",
  "warning",
  "destructive",
  "link",
  "secondary",
  "grey",
  "green",
  "blue",
  "purple",
  "orange",
  "teal",
  "pink",
] as const;

type CatalogVariantProps = { limit?: number };

const limited = <T,>(items: readonly T[], limit?: number) =>
  limit === undefined ? items : items.slice(0, limit);

function IconButtonVariantsExample({ limit }: CatalogVariantProps = {}) {
  if (limit !== undefined) {
    return (
      <Stack direction="row" gap="3" align="center" wrap="wrap" className="justify-center">
        {limited(buttonVariants, limit).map((variant) => (
          <IconButton key={variant} aria-label={variant} variant={variant}>
            <PlusIcon />
          </IconButton>
        ))}
      </Stack>
    );
  }

  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap">
      {buttonVariants.map((variant) => (
        <IconButton key={variant} aria-label={variant} variant={variant}>
          <PlusIcon />
        </IconButton>
      ))}
    </Stack>
  );
}
```

## Custom styling

Like Button, `IconButton` accepts your own appearance through the usual `className` prop. No custom `variant` or `variantClassName` is required. Define the surface, foreground, and interaction states you want to replace while retaining an accessible label and visible keyboard focus.

```tsx
import { PlusIcon } from "@phosphor-icons/react";
import { Button, IconButton, Stack } from "@zentara-co/zenos-ui";

function CustomButtonVariantExample() {
  const campaignButtonClassName =
    "rounded-full border border-transparent bg-background-accent-purple-bolder-hover text-text-contrary hover:bg-background-accent-purple-bolder-pressed active:bg-background-accent-purple-bolder-pressed";

  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap">
      <Button className={campaignButtonClassName}>Launch campaign</Button>
      <IconButton aria-label="Campaign options" className={campaignButtonClassName}>
        <PlusIcon />
      </IconButton>
    </Stack>
  );
}
```

## States

Loading replaces the icon with a spinner, disables activation, and exposes `aria-busy`.

```tsx
import { PlusIcon } from "@phosphor-icons/react";
import { IconButton, Stack } from "@zentara-co/zenos-ui";

function IconButtonStatesExample() {
  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap">
      <IconButton aria-label="Add item" variant="primary">
        <PlusIcon />
      </IconButton>
      <IconButton aria-label="Add item (disabled)" variant="primary" disabled>
        <PlusIcon />
      </IconButton>
      <IconButton aria-label="Adding item" variant="primary" isLoading>
        <PlusIcon />
      </IconButton>
    </Stack>
  );
}
```

## Tooltip

`tooltip` shows a visible label on hover and keyboard focus, and closes with Escape. It opens immediately. `tooltipVariant` uses the same surfaces as Tooltip: `default` for a short label, `solid` for a longer note.

`aria-label` stays the accessible name. The tooltip does not replace it.

```tsx
import { CopyIcon, TrashIcon } from "@phosphor-icons/react";
import { IconButton, Stack } from "@zentara-co/zenos-ui";

function IconButtonTooltipExample() {
  return (
    <Stack direction="row" gap="3" align="center" wrap="wrap">
      <IconButton aria-label="Copy link" tooltip="Copy link" variant="outline">
        <CopyIcon />
      </IconButton>
      <IconButton
        aria-label="Remove file"
        tooltip="Remove this file from the list"
        tooltipVariant="solid"
        variant="ghost"
      >
        <TrashIcon />
      </IconButton>
    </Stack>
  );
}
```

A disabled or loading icon button cannot be hovered or focused, so its tooltip stays closed. Keep any required explanation in text that remains on the page.

## Motion

Icon buttons use the same short pressed-state scale as Button and automatically remove it for reduced-motion preferences. Set `disableMotion` when another interaction already supplies feedback or the control must remain spatially still:

```tsx
<IconButton aria-label="Add item" disableMotion>
  <PlusIcon />
</IconButton>
```

Pressed color, keyboard focus, and native activation remain available when motion is disabled. Icon buttons placed inside `SplitButton` disable pressed motion by default.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| aria-label | string | — | Required accessible name. |
| Button / Link.variant | ButtonVariant \| custom string | default | Visual treatment. |
| variantClassName | string | — | Defines or refines the selected variant appearance. |
| Button / Link.size | sm \| md \| lg | md | Square control size. |
| isLoading | boolean | false | Shows progress and prevents activation. |
| disableMotion | boolean | false | Disables the pressed-state scale and transition. Defaults to true inside SplitButton. |
| tooltip | ReactNode | — | Visible label on hover and keyboard focus. Blank content is ignored. Disabled and loading buttons do not open it. |
| tooltipVariant | default \| solid | default | Tooltip surface. Matches Tooltip variants. |
| native props | React.ButtonHTMLAttributes<HTMLButtonElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

Source: https://zenos-ui.pages.dev/components/icon-button/