Skip to content

IconButton

IconButton is a button component that displays only an icon, making it ideal for compact interfaces and actions that don’t require text labels. It provides accessible, interactive icon buttons with hover and focus states.

Variants

Default Variant

The default variant provides a subtle hover state suitable for most icon button use cases.

<IconButton icon={Search} aria-label="Search" />

Action Variant

The action variant provides a more prominent hover state with a blue background, ideal for primary icon actions.

<IconButton icon={Search} variant="action" aria-label="Search" />

Sizes

Small (sm)

Small icon buttons are 30px × 30px, suitable for compact interfaces.

<IconButton icon={Search} size="sm" aria-label="Search" />

Medium (md)

Medium icon buttons are 36px × 36px, the default size for most use cases.

<IconButton icon={Search} size="md" aria-label="Search" />

Seamless

The seamless prop makes the icon button background transparent, useful for overlaying icons on images or colored backgrounds.

<IconButton icon={Search} seamless aria-label="Search" />

Accessibility

IconButton requires an aria-label prop to ensure screen readers can identify the button’s purpose. Always provide a descriptive label that explains what action the button performs.

// Good
<IconButton icon={Search} aria-label="Search" />
// Bad - missing aria-label
<IconButton icon={Search} />

Props

interface IconButtonProps
renderIcon ? (icon: IconButtonIcon, options: { iconClassName?: string; iconSize?: number | undefined; iconStyle?: CSSProperties | undefined; }) => ReactElement<...>

Custom icon renderer function. Allows complete control over icon rendering. Receives the icon and options, should return a React element. If provided, overrides the default icon rendering logic.

isDisabled ? boolean

Whether the button is disabled.

onPress ? (e: PressEvent) => void

Handler that is called when the press is released over the target.

onPressStart ? (e: PressEvent) => void

Handler that is called when a press interaction starts.

onPressEnd ? (e: PressEvent) => void

Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.

onPressChange ? (isPressed: boolean) => void

Handler that is called when the press state changes.

onPressUp ? (e: PressEvent) => void

Handler that is called when a press is released over the target, regardless of whether it started on the target or not.

onClick ? (e: MouseEvent) => void

Not recommended – use onPress instead. onClick is an alias for onPress provided for compatibility with other libraries. onPress provides additional event details for non-mouse interactions.

autoFocus ? boolean

Whether the element should receive focus on render.

onFocus ? (e: FocusEvent) => void

Handler that is called when the element receives focus.

onBlur ? (e: FocusEvent) => void

Handler that is called when the element loses focus.

onFocusChange ? (isFocused: boolean) => void

Handler that is called when the element's focus status changes.

onKeyDown ? (e: KeyboardEvent) => void

Handler that is called when a key is pressed.

onKeyUp ? (e: KeyboardEvent) => void

Handler that is called when a key is released.

type ? "button" | "submit" | "reset"

The behavior of the button when used in an HTML form.

Defaults to 'button'
preventFocusOnPress ? boolean

Whether to prevent focus from moving to the button when pressing it.

Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.

form ? string

The <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.

formAction ? string

The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner.

formEncType ? string

Indicates how to encode the form data that is submitted.

formMethod ? string

Indicates the HTTP method used to submit the form.

formNoValidate ? boolean

Indicates that the form is not to be validated when it is submitted.

formTarget ? string

Overrides the target attribute of the button's form owner.

name ? string

Submitted as a pair with the button's value as part of the form data.

value ? string

The value associated with the button's name when it's submitted with the form data.

excludeFromTabOrder ? boolean

Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available.

id ? string

The element's unique identifier. See MDN.

isPending ? boolean

Whether the button is in a pending state. This disables press and hover events while retaining focusability, and announces the pending state to screen readers.

onHoverStart ? (e: HoverEvent) => void

Handler that is called when a hover interaction starts.

onHoverEnd ? (e: HoverEvent) => void

Handler that is called when a hover interaction ends.

onHoverChange ? (isHovering: boolean) => void

Handler that is called when the hover state changes.

slot ? string | null

A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.

className ? ClassNameOrFunction

The CSS className for the element. A function may be provided to compute the class based on component state.

style ? StyleOrFunction

The inline style for the element. A function may be provided to compute the style based on component state.