Icon Button
Use icon buttons for compact, accessible icon-only interactions. Icon buttons are essential for space-efficient interfaces while maintaining accessibility compliance.View source →Use icon buttons for compact, accessible icon-only interactions. Icon buttons are essential for space-efficient interfaces while maintaining accessibility compliance.
This is an enhanced version of the IconButton component from Radix Themes. For the original API reference, see the Radix Themes IconButton documentation.
Playground
Installation
shellUsage
tsxProps
Accessibility Requirements
Icon buttons must have an accessible name to meet WCAG guidelines. Provide accessibility through one of these methods:
aria-label
Direct descriptive text that explains the button's action.
tsxaria-labelledby
Reference to a label element for more complex descriptions.
tsxVisible Text Children
Fallback when visible text is included alongside the icon.
tsxVariants
Use the variant prop to set button style.
Classic
Elevated style with subtle shadow for maximum visual impact.
tsxSolid
Filled background for primary actions.
tsxSoft
Subtle background for secondary actions.
tsxOutline
Bordered style for secondary actions.
tsxSurface
Elevated surface for content-heavy UIs.
tsxGhost
Minimal style for utility actions.
tsxSizes
Set size for button density. Icon buttons maintain square aspect ratios for consistent visual alignment.
Size 1
Compact for toolbars and dense interfaces.
tsxSize 2
Standard for most interface contexts.
tsxSize 3
Large for important actions and mobile touch targets.
tsxSize 4
Extra large for hero sections and maximum impact.
tsxColors
Use the color prop with semantic colors to communicate action intent.
tsxTooltips
Use the tooltip prop to add context to icon button actions. Always provide a tooltip for icon-only buttons to help users understand the action.
tsxTooltip Position
Control tooltip placement with tooltipSide and tooltipAlign props.
tsxStates
Loading
Set loading to show a spinner and disable the button.
tsxDisabled
Set disabled to prevent interaction.
tsxPolymorphism
As
Use the as prop to render as different HTML elements while maintaining icon button styling.
tsxAsChild
Use the asChild prop to merge props with a child element using the Radix Slot pattern.
tsxResponsive
Use responsive objects with the size prop to adapt sizing across breakpoints.
tsxAccessibility
Kookie UI's IconButton enforces accessibility requirements with runtime validation.
Enforced Accessible Name
IconButton throws an error in development if no accessible name is provided. This ensures WCAG compliance and catches accessibility issues early.
Keyboard Navigation
- Full keyboard support with Enter and Space keys
- Visible focus indicators for all variants
- Enhanced focus management for Windows High Contrast mode
Screen Readers
- Semantic button elements with proper roles
- Loading state announcements
- Tooltip associations via
aria-describedby - Disabled state announcements
Enhancements
Kookie UI extends Radix Themes IconButton with practical improvements:
Built-in Tooltip Support
Native tooltip prop eliminates need for wrapper components. Tooltips automatically provide accessibility through aria-describedby associations.
Runtime Accessibility Validation
Enforced accessibility requirements with helpful error messages in development. Ensures all icon buttons have proper accessible names.
Enhanced Loading State
Loading state automatically disables interaction and displays spinner with proper accessibility announcements.
Changelog
Added
- Built-in tooltip support through
tooltip,tooltipSide,tooltipAlignprops - Runtime accessibility validation for missing accessible names
- New
materialprop for solid/translucent theme contexts - Enhanced form integration with complete HTML form attribute support
Changed
- Improved 3D shadow system for classic variant
- Better contrast relationships in both light and dark themes
Fixed
- Better color saturation and brightness in high contrast mode
- Enhanced focus indicators for improved accessibility