- Docs
- Components
- Actions
Icon button
An action shown as an icon. Its name is required, and shows as its tooltip.
- Import
- @qeetrix/react
- Status
- StableSince 0.0.2
- Renders
<button>Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Import
// From the package: a build keeps only what it uses.
import { IconButton } from "@qeetrix/react";
// Or from its own path.
import { IconButton } from "@qeetrix/react/button";02
Props
And every native attribute of the element it renders.
| Prop | Type | Default | What it does |
|---|---|---|---|
icon | IconSource | required | The icon, from @qeetrix/icons, drawn sharp. |
aria-label | string | required | Its name: announced, and shown as its tooltip. |
variant | "ghost" | "soft" | "solid" | "ghost" | Emphasis: tertiary, secondary, primary. |
tone | "brand" | "danger" | "neutral" | "brand" | neutral for utility actions in toolbars and rows. |
size | "sm" | "md" | "lg" | "md" | A square, at a control's height. |
tooltip | ReactNode | false | aria-label | Other text to show, or false where the name is visible nearby. |
tooltipSide | "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end" | "top" | The side it opens on; it flips when there's no room. |
loading | boolean | false | A spinner replaces the icon; clicks are ignored; aria-busy is set. |
disabled | boolean | false | Sets aria-disabled; it stays focusable, and its tooltip still shows. |
render | Button.Props["render"] | — | Renders another element through Base UI, e.g. a router link. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What it is |
|---|---|---|
icon-button | <button> | The root. data-variant, data-tone, data-size; data-loading when set. |
button-icon | <svg> | The icon. |
button-spinner | <span> | In the icon's place while loading. |
04
Beside the value it copies
Where the words are in view, the tooltip would only repeat them.
<Inline gap="xs" align="center">
<Text mono>usr_01J8K2M4PQ</Text>
<IconButton icon={CopyIcon} aria-label="Copy user ID" tooltip={false} />
</Inline>05
As a router link
render swaps the element; it keeps its look, its name and its tooltip.
import { SettingsIcon } from "@qeetrix/icons";
import { IconButton } from "@qeetrix/react";
import { Link } from "@tanstack/react-router";
<IconButton render={<Link to="/settings" />} icon={SettingsIcon} aria-label="Settings" />