IconButton
HkIconButton is the square, icon-only trigger every chrome row uses: toolbars, page headers, list rows, dialog headers. It comes in six box sizes from 16px to 40px and five inks, and it can carry a status dot of its own.
- Several related icon buttons that act as one control — a view switcher, a toggle set, a tight toolbar — belong in an HkIconButtonGroup, which adds the tooltip and the shared track.
- A text button that happens to hold only a glyph collapses to the same square; keep it a Button when a caption may return.
Import
import { HkIconButton } from "@celestia-island/hikari";
use hikari_components::*; use hikari_components::prelude::*;
Variants
The variant is the ink: ghost (the default) draws only the glyph, primary, secondary, danger and success fill the square. An icon button always needs an accessible name — pass aria-label.
import { HkIconButton } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "12px", alignItems: "center" };
export default () => (
<div style={row}>
<HkIconButton icon="Plus" aria-label="Add" />
<HkIconButton icon="Plus" variant="primary" aria-label="Add" />
<HkIconButton icon="Plus" variant="secondary" aria-label="Add" />
<HkIconButton icon="Plus" variant="danger" aria-label="Remove" />
<HkIconButton icon="Plus" variant="success" aria-label="Approve" />
</div>
);
rsx! {
div { style: "display:flex;gap:12px;align-items:center",
IconButton { icon: Some(MdiIcon::Plus), aria_label: Some("Add".to_string()) }
IconButton { icon: Some(MdiIcon::Plus), variant: IconButtonVariant::Primary, aria_label: Some("Add".to_string()) }
IconButton { icon: Some(MdiIcon::Plus), variant: IconButtonVariant::Secondary, aria_label: Some("Add".to_string()) }
IconButton { icon: Some(MdiIcon::Plus), variant: IconButtonVariant::Danger, aria_label: Some("Remove".to_string()) }
IconButton { icon: Some(MdiIcon::Plus), variant: IconButtonVariant::Success, aria_label: Some("Approve".to_string()) }
}
}
import { HkIconButton } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "12px", alignItems: "center" };
export default () => (
<div style={row}>
<HkIconButton icon="Plus" aria-label="Add" />
<HkIconButton icon="Plus" variant="primary" aria-label="Add" />
<HkIconButton icon="Plus" variant="secondary" aria-label="Add" />
<HkIconButton icon="Plus" variant="danger" aria-label="Remove" />
<HkIconButton icon="Plus" variant="success" aria-label="Approve" />
</div>
);rsx! {
div { style: "display:flex;gap:12px;align-items:center",
IconButton { icon: Some(MdiIcon::Plus), aria_label: Some("Add".to_string()) }
IconButton { icon: Some(MdiIcon::Plus), variant: IconButtonVariant::Primary, aria_label: Some("Add".to_string()) }
IconButton { icon: Some(MdiIcon::Plus), variant: IconButtonVariant::Secondary, aria_label: Some("Add".to_string()) }
IconButton { icon: Some(MdiIcon::Plus), variant: IconButtonVariant::Danger, aria_label: Some("Remove".to_string()) }
IconButton { icon: Some(MdiIcon::Plus), variant: IconButtonVariant::Success, aria_label: Some("Approve".to_string()) }
}
}Sizes
Six box steps in pixels: 16, 24, 28, 32 (the default), 36 and 40. The 28px step matches the header chrome; the glyph grows with the box. In the Vue form icon is a registry name (a lucide export name such as "Search"); in the Rust form it is a typed MdiIcon.
import { HkIconButton } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "12px", alignItems: "center" };
export default () => (
<div style={row}>
<HkIconButton icon="Search" size={16} aria-label="Search" />
<HkIconButton icon="Search" size={24} aria-label="Search" />
<HkIconButton icon="Search" size={28} aria-label="Search" />
<HkIconButton icon="Search" size={32} aria-label="Search" />
<HkIconButton icon="Search" size={36} aria-label="Search" />
<HkIconButton icon="Search" size={40} aria-label="Search" />
</div>
);
rsx! {
div { style: "display:flex;gap:12px;align-items:center",
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S16, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S24, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S28, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S32, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S36, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S40, aria_label: Some("Search".to_string()) }
}
}
import { HkIconButton } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "12px", alignItems: "center" };
export default () => (
<div style={row}>
<HkIconButton icon="Search" size={16} aria-label="Search" />
<HkIconButton icon="Search" size={24} aria-label="Search" />
<HkIconButton icon="Search" size={28} aria-label="Search" />
<HkIconButton icon="Search" size={32} aria-label="Search" />
<HkIconButton icon="Search" size={36} aria-label="Search" />
<HkIconButton icon="Search" size={40} aria-label="Search" />
</div>
);rsx! {
div { style: "display:flex;gap:12px;align-items:center",
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S16, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S24, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S28, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S32, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S36, aria_label: Some("Search".to_string()) }
IconButton { icon: Some(MdiIcon::Magnify), size: IconButtonSize::S40, aria_label: Some("Search".to_string()) }
}
}Status dot, title and disabled state
dot draws a small status mark inside the button's own box, in the bottom-right corner; dotVariant picks its tone. The dot is decoration unless dotLabel names it. A native title adds a tooltip on hover — it is not an accessible name, so it complements aria-label rather than replacing it. In the Rust form title is an explicit prop; in the Vue form the component's declared props do not list it, which is why the TSX example leaves it out.
import { HkIconButton } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "12px", alignItems: "center" };
export default () => (
<div style={row}>
<HkIconButton icon="Bell" aria-label="Notifications" dot dotLabel="3 unread" />
<HkIconButton icon="Bell" aria-label="Alerts" dot dotVariant="error" />
<HkIconButton icon="Pencil" aria-label="Rename" disabled />
</div>
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
rsx! {
div { style: "display:flex;gap:12px;align-items:center",
IconButton {
icon: Some(MdiIcon::Bell),
aria_label: Some("Notifications".to_string()),
dot: true,
dot_label: Some("3 unread".to_string()),
}
IconButton {
icon: Some(MdiIcon::Bell),
aria_label: Some("Alerts".to_string()),
dot: true,
dot_variant: IconButtonDotVariant::Error,
}
IconButton { icon: Some(MdiIcon::Pencil), aria_label: Some("Rename".to_string()), disabled: true }
}
}
import { HkIconButton } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const row: CSSProperties = { display: "flex", gap: "12px", alignItems: "center" };
export default () => (
<div style={row}>
<HkIconButton icon="Bell" aria-label="Notifications" dot dotLabel="3 unread" />
<HkIconButton icon="Bell" aria-label="Alerts" dot dotVariant="error" />
<HkIconButton icon="Pencil" aria-label="Rename" disabled />
</div>
);rsx! {
div { style: "display:flex;gap:12px;align-items:center",
IconButton {
icon: Some(MdiIcon::Bell),
aria_label: Some("Notifications".to_string()),
dot: true,
dot_label: Some("3 unread".to_string()),
}
IconButton {
icon: Some(MdiIcon::Bell),
aria_label: Some("Alerts".to_string()),
dot: true,
dot_variant: IconButtonDotVariant::Error,
}
IconButton { icon: Some(MdiIcon::Pencil), aria_label: Some("Rename".to_string()), disabled: true }
}
}A glyph of your own
The default slot wins over the icon prop, so any renderable glyph can sit in the square — a custom SVG, an image component, an icon of another set.
import { HkIcon, HkIconButton } from "@celestia-island/hikari";
export default () => (
<HkIconButton aria-label="Information">
<HkIcon name="Info" size={20} />
</HkIconButton>
);
rsx! {
IconButton {
aria_label: Some("Information".to_string()),
children: rsx! { Icon { icon: MdiIcon::Information, size: 20 } },
}
}
import { HkIcon, HkIconButton } from "@celestia-island/hikari";
export default () => (
<HkIconButton aria-label="Information">
<HkIcon name="Info" size={20} />
</HkIconButton>
);rsx! {
IconButton {
aria_label: Some("Information".to_string()),
children: rsx! { Icon { icon: MdiIcon::Information, size: 20 } },
}
}Interaction
click carries the native MouseEvent. The example is a mute toggle: the glyph, the ink and the accessible name all follow one piece of state.
import { ref } from "vue";
import { HkIconButton } from "@celestia-island/hikari";
export default () => {
const muted = ref(false);
return (
<HkIconButton
icon={muted.value ? "VolumeX" : "Volume2"}
variant={muted.value ? "primary" : "ghost"}
aria-label={muted.value ? "Unmute" : "Mute"}
onClick={() => {
muted.value = !muted.value;
}}
/>
);
};
import { ref } from "vue";
import { HkIconButton } from "@celestia-island/hikari";
export default () => {
const muted = ref(false);
return (
<HkIconButton
icon={muted.value ? "VolumeX" : "Volume2"}
variant={muted.value ? "primary" : "ghost"}
aria-label={muted.value ? "Unmute" : "Mute"}
onClick={() => {
muted.value = !muted.value;
}}
/>
);
};
API
Vue
Props
Emits
Rust
Props — IconButton
Accessibility
- Always pass aria-label: a glyph alone names nothing, and a title tooltip does not count as an accessible name.
- The button is a real <button> with type="button" by default, so it never submits a surrounding form by accident.
- The status dot is aria-hidden decoration unless dotLabel gives it a name; describe the state the dot stands for in that label.
- Attributes such as aria-expanded and aria-describedby fall through to the button element; in the Rust form they are explicit props.
Related components