IconButton
The IconButton component is a circular, icon-only button for compact actions like edit, delete, or settings.
Keep in mind that the <button> element inherently includes native browser properties like onClick. Cherry UI components introduce custom properties that always begin with a $ to distinguish them from native props.
Because the button has no visible text, the aria-label property is required.
import React from "react";
import { Icon, IconButton } from "cherry-styled-components";
export default function Page() {
return (
<IconButton aria-label="Settings">
<Icon name="Settings" />
</IconButton>
);
}With sizes:
<IconButton $size="small" aria-label="Edit">
<Icon name="Pencil" />
</IconButton>
<IconButton $size="big" aria-label="Add">
<Icon name="Plus" />
</IconButton>For destructive actions, use the error variant:
<IconButton $error aria-label="Delete">
<Icon name="Trash2" />
</IconButton>For toggle-like actions that stay "on" (a dropzone that is open, a preview
that is active), use $active. The button keeps its primary border with a
subtle tint, and the state is exposed to assistive technology via
aria-pressed automatically:
<IconButton $active={isPreviewOpen} aria-label="Toggle preview">
<Icon name="Eye" />
</IconButton>Properties
The icon to render, typically a Cherry Icon. It is sized automatically per
$size (12px, 14px, or 16px).
Accessible label describing the action. Required because the button has no visible text.
Size of the button: 24px (small), 28px (default), or 32px (big).
Renders the button in the theme's error color for destructive actions.
Marks the button as being in an "on" state: primary border, tinted
background, and primary icon color. When set (true or false), the value is
also reflected as aria-pressed so screen readers announce the toggle
state. Ignored while disabled.
Cherry theme object.