When the variant prop is set to gradient , you can control the gradient with the gradient prop, which accepts an object with from , to and deg properties. If the gradient prop is not set, ActionIcon will use theme.defaultGradient which can be configured on the theme object . The gradient prop is ignored when variant is not gradient .
Note that variant="gradient" supports only linear gradients with two colors. If you need a more complex gradient, use the Styles API to modify ActionIcon styles.
You can use any valid CSS value in the size prop, which is used to set the width , min-width , min-height and height properties. Note that the size prop does not control the child icon size – you need to set it manually on the icon component. When size is a number, the value is treated as px units and converted to rem units.
If you want ActionIcon to have the same size as Mantine inputs, use the size="input-sm" prop:
To make ActionIcon disabled, set the disabled prop. This will prevent any interactions with the button and add disabled styles. If you want the button to just look disabled but still be interactive, set the data-disabled prop instead. Note that disabled styles are the same for all variants.
The <a /> element does not support the disabled attribute. To make ActionIcon disabled when it is rendered as a link, set the data-disabled attribute instead and prevent default behavior in the onClick event handler.
To customize disabled styles, it is recommended to use both &:disabled and &[data-disabled] selectors:
The onMouseLeave event is not triggered when ActionIcon is disabled, so if you need to use Tooltip with a disabled ActionIcon , you need to set the data-disabled prop on ActionIcon instead of disabled . Note that it is also required to change the onClick event handler to (event) => event.preventDefault() as ActionIcon is not actually disabled and will still trigger the onClick event.
When the loading prop is set, ActionIcon will be disabled and a Loader with overlay will be rendered in the center of the button. The Loader color depends on the ActionIcon variant.
You can customize the Loader with the loaderProps prop, which accepts all props that the Loader component has:
To add new ActionIcon variants, use the data-variant attribute. Usually new variants are added to the theme . This way they are available in all ActionIcon components in your application.
You can customize colors for ActionIcon and other components variants by adding variantColorResolver to your theme.
ActionIcon supports the autoContrast prop and theme.autoContrast . If autoContrast is set either on ActionIcon or on the theme, the content color will be adjusted to have sufficient contrast with the value specified in the color prop.
Note that the autoContrast feature works only if you use the color prop to change the background color. autoContrast works only with the filled variant.
ActionIcon sizes are defined by --ai-size-{x} CSS variables. The easiest way to add new sizes is to define additional --ai-size-{x} variables on the root element:
ActionIcon.Group renders with role="group" . When the group represents a meaningful set of actions, give it an accessible name with aria-label (or aria-labelledby ) so screen readers can announce its purpose:
Note that you must not wrap child ActionIcon components with any additional elements:
Use the ActionIcon.GroupSection component to render sections that are not ActionIcon inside ActionIcon.Group :
ActionIcon is a polymorphic component – its default root element is button , but it can be changed to any other element or component with the component prop:
You can also use components in the component prop, for example, Next.js Link :
Polymorphic components with TypeScript
Note that polymorphic component prop types are different from regular components – they do not extend HTML element props of the default element. For example, ActionIcon Props does not extend React.ComponentProps '<' div '>' although button is the default element.
If you want to create a wrapper for a polymorphic component that is not polymorphic (does not support the component prop), then your component props interface should extend HTML element props, for example:
If you want your component to remain polymorphic after wrapping, use the polymorphic function described in this guide .
To make ActionIcon accessible for screen readers, you need to either set aria-label or use the VisuallyHidden component: