Icon Button
- Stable
- WCAG 2.2 evidence
- RTL
- Web · iOS · Android
A square, icon-only button for compact actions such as Settings, Close or Delete row. Built on React Aria Button: Enter and Space activate, disabled buttons leave the tab order,
and keyboard focus shows the focus ring (WCAG 2.1.1, 2.4.7, 4.1.2). Every size meets the 24 px target minimum on web
and the 44 pt / 48 dp touch targets on iOS and Android (2.5.8). Consumer duties: a specific, translated aria-label; a Tooltip with the same text when the icon's meaning is not
obvious; and explaining why an action is unavailable instead of only disabling it. Use Button with a label when the
icon is not universally understood.
import { IconButton } from "@nexera-ui/react";- 5
- examples
- 23
- props
- 5
- live controls
- 3
- platforms
- 8
- WCAG criteria
- 14
- blocks use it
Try every prop. Copy the code.
Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.
import { IconButton } from "@nexera-ui/react";
<IconButton />Examples 4
The same examples as Storybook, rendered live. Open Code to copy one.
Variants and sizes
Every Figma Variant and Size on the web platform. Hover, press and focus the buttons to see the other states.
import { IconButton } from "@nexera-ui/react";
import { LuSettings } from "react-icons/lu";
const variants = ["primary", "secondary", "ghost", "destructive"] as const;
const sizes = ["sm", "md", "lg"] as const;
export function VariantsAndSizes() {
return (
<div className="flex flex-col gap-4">
{variants.map((variant) => (
<div key={variant} className="flex flex-wrap items-center gap-4">
{sizes.map((size) => (
<IconButton
key={size}
icon={<LuSettings />}
variant={variant}
size={size}
aria-label={`Settings (${variant}, ${size})`}
/>
))}
</div>
))}
</div>
);
}
Disabled and loading
Figma Disabled state (isDisabled) and Loading state (isLoading, the name becomes "Settings Loading").
import { IconButton } from "@nexera-ui/react";
import { LuSettings } from "react-icons/lu";
const variants = ["primary", "secondary", "ghost", "destructive"] as const;
export function DisabledAndLoading() {
return (
<div className="flex flex-col gap-4">
{variants.map((variant) => (
<div key={variant} className="flex flex-wrap items-center gap-4">
<IconButton aria-label="Settings" icon={<LuSettings />} variant={variant} isDisabled />
<IconButton aria-label="Settings" icon={<LuSettings />} variant={variant} isLoading />
</div>
))}
</div>
);
}
In context
Typical toolbar use: ghost buttons named by aria-label, and one named by visible text through aria-labelledby.
import { IconButton } from "@nexera-ui/react";
import { LuPencil, LuTrash2, LuX } from "react-icons/lu";
export function InContext() {
return (
<div className="flex flex-wrap items-center gap-2">
<IconButton aria-label="Edit" icon={<LuPencil />} variant="ghost" />
<IconButton aria-label="Close" icon={<LuX />} variant="ghost" />
<span id="iconbutton-row" className="text-body-default text-primary ms-4">
Delete Jordan Lee
</span>
<IconButton aria-labelledby="iconbutton-row" icon={<LuTrash2 />} variant="destructive" />
</div>
);
}
Platforms
Figma IconButton Mobile: platform="ios" raises the square to 44/50/56 pt (radius 12), platform="android" to 48/52/56 dp and makes it round; icons grow to 18/20/24.
import { IconButton } from "@nexera-ui/react";
import { LuSettings } from "react-icons/lu";
const variants = ["primary", "secondary", "ghost", "destructive"] as const;
const sizes = ["sm", "md", "lg"] as const;
const platforms = ["web", "ios", "android"] as const;
export function Platforms() {
return (
<div className="flex flex-col gap-6">
{platforms.map((platform) => (
<div key={platform} className="flex flex-wrap items-center gap-4">
<span className="text-body-caption text-secondary w-16">{platform}</span>
{variants.map((variant) =>
sizes.map((size) => (
<IconButton
key={`${variant}${size}`}
icon={<LuSettings />}
platform={platform}
variant={variant}
size={size}
aria-label={`Settings (${platform}, ${variant}, ${size})`}
/>
)),
)}
</div>
))}
</div>
);
}
Props 23
Press "Try it" on a card to load that prop into the playground.
23 props shown
icon*NexeraReactNodeThe icon. Decorative: the accessible name comes
from aria-label or aria-labelledby. Wrap direction-bearing glyphs in DirectionalIcon so they flip in RTL.
variantNexera"primary" | "secondary" | "ghost" | "destructive"Visual emphasis. destructive is reserved for irreversible actions.
sizeNexera"sm" | "md" | "lg"Square size: 32 / 40 / 48 px on web, 44 / 50 / 56 pt on iOS, 48 / 52 / 56 dp on Android.
platformNexera"web" | "ios" | "android"Platform look. Defaults to the NexeraProvider
platform. iOS and Android raise the size to the touch targets, use larger icons, and Android is fully round.
isLoadingNexerabooleanLoading state. Replaces the icon with a spinner, stops presses and form submission, keeps
focus and the square size, and adds loadingLabel to the accessible name (announced while focused).
loadingLabelNexerastringText added to the accessible name while isLoading is true ("Settings Loading"). Translate it for your locale.
classNameNexerastringExtra classes, merged last so they win over the defaults.
styleNexeraCSSPropertiesInline style.
aria-labelNexerastringAccessible name. Required unless aria-labelledby is set.
Name the outcome ("Settings", "Delete row"), translate it, and show the same text in a Tooltip when the icon is not
universally understood.
Accessible name. Optional when aria-labelledby is set.
aria-labelledbyNexerastringId(s) of element(s) that name the button; wins over aria-label when both are set.
Id(s) of visible element(s) that name the button. Required unless aria-label is set.
isDisabledReact AriabooleanWhether the button is disabled.
onPressReact Aria(e: PressEvent) => voidHandler that is called when the press is released over the target.
onPressStartReact Aria(e: PressEvent) => voidHandler that is called when a press interaction starts.
onPressEndReact Aria(e: PressEvent) => voidHandler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChangeReact Aria(isPressed: boolean) => voidHandler that is called when the press state changes.
onPressUpReact Aria(e: PressEvent) => voidHandler that is called when a press is released over the target, regardless of whether it started on the target or not.
autoFocusReact AriabooleanWhether the element should receive focus on render.
typeReact Aria"button" | "submit" | "reset"The behavior of the button when used in an HTML form.
formReact AriastringThe <form> element to associate the button with.
The value of this attribute must be the id of a <form> in the same document.
See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#form).
nameReact AriastringSubmitted as a pair with the button's value as part of the form data.
valueReact AriastringThe value associated with the button's name when it's submitted with the form data.
idReact AriastringThe element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
aria-describedbyReact AriastringIdentifies the element (or elements) that describes the object.
* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.
Accessible by default.
Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.
WCAG 2.2 evidence
6 direct · 2 supporting- 1.1.1Non-text ContentLevel A · tested directly
- 1.3.1Info and RelationshipsLevel A · tested directly
- 1.4.11Non-text ContrastLevel AA · supporting test
- 2.1.1KeyboardLevel A · tested directly
- 2.4.7Focus VisibleLevel AA · tested directly
- 2.5.8Target Size (Minimum)Level AA · supporting test
- 4.1.2Name, Role, ValueLevel A · tested directly
- 4.1.3Status MessagesLevel AA · tested directly
Fits any width.
Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.
Styling hooks
Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.
data-disableddata-focus-visibledata-hovereddata-pendingdata-pressed
<IconButton className="data-disabled:opacity-90 shadow-sm" />Used in blocks
- Top bar with tabsApp shells and navigation
- Mobile app shellApp shells and navigation
- Data tableLists, tables and records
- Billing and planSettings and preferences
- ChatMessaging and collaboration
- InboxMessaging and collaboration
- Helpdesk assistantMessaging and collaboration
- Notification centreMessaging and collaboration
- Month calendarScheduling and calendar
- Week calendarScheduling and calendar
- Event detailsScheduling and calendar
- Document previewMedia and content
- ToastsStates and system messages
- Pull to refresh feedMobile patterns
Related components
- BoardCardA Kanban card: avatar, name, role, drag handle and a detail line.
- ButtonTriggers an action such as Save, Submit, Approve or Delete.
- ButtonGroupItemOne toggle in a joined row of buttons, for example a List / Grid view switch or a set of filters.
- ContextMenuThe menu of actions for an element, opened where the user asks for it: right-click, long-press on touch screens, and from the keyboard with Shift+F10 or the ContextMenu key (the browser reports both as a `contextmenu` event on the focused element; on macOS, Control+Enter).
- DragHandleGrip that starts a drag of the collection item it sits in.
- DropIndicatorInsertion line shown between two items while something is dragged over a `GridList` or `ListBox`.
- MenuA list of actions or options that opens from a trigger.
- MenuDividerSeparates groups of items in a `Menu` or `ContextMenu`.