ActionButton

ActionButtons allow users to perform an action. They're used for similar, task-based options within a workflow, and are ideal for interfaces where buttons aren't meant to draw a lot of attention.

children 
size 
staticColor 
isQuiet 
isDisabled 
import {ActionButton} from '@react-spectrum/s2';

<ActionButton>Action</ActionButton>

Content

ActionButtons can have a label, an icon, or both. An icon is provided by passing an icon component as a child to the ActionButton. A visible label can be provided by passing a string or a Text component as a child, depending on whether the ActionButton has an accompanying icon.

import {ActionButton, Text} from '@react-spectrum/s2';
import Edit from '@react-spectrum/s2/icons/Edit';

<ActionButton>
  <Edit />
  <Text>Icon + Label</Text>
</ActionButton>

Accessibility

If no visible label is provided (e.g. an icon only button), an alternative text label must be provided to identify the control for accessibility. This should be added using the aria-label prop.

<ActionButton aria-label="Icon only">
  <Edit />
</ActionButton>

Internationalization

In order to internationalize an ActionButton, a localized string should be passed to the children or aria-label prop.

Events

ActionButtons support user interactions via mouse, keyboard, and touch. You can handle all of these via the onPress prop.

The following example uses an onPress handler to update a counter stored in React state.

import {ActionButton} from '@react-spectrum/s2';
import {useState} from 'react';

function Example() {
  let [count, setCount] = useState(0);

  return (
   <ActionButton onPress={() => setCount(c => c + 1)}>{count} Edits</ActionButton>
  );
}

Props

NameTypeDefault
childrenReactNodeDefault:
The content to display in the ActionButton.
isDisabledbooleanDefault:
Whether the button is disabled.
stylesDefault:
Spectrum-defined styles, returned by the style() macro.
size'XS''S''M''L''XL'Default: 'M'
The size of the ActionButton.
staticColor'black''white''auto'Default:
The static color style to apply. Useful when the ActionButton appears over a color background.
isQuietbooleanDefault:
Whether the button should be displayed with a quiet style.