Actions are essential building blocks for the interface that perform inline operations.
Overview
Typically living within other components, Actions are flexible buttons that have an icon, can have a text label, notification style indicator, active state, and other useful properties.
Actions are distinct components, since they are more visually prominent. Whereas, Buttons are suited well for primary operations and call-to-actions such as "Save", "Cancel", "Back", and "Next".
Sample
Usage
-
Various basic operations, such as:
- Add
- Edit
- Sort
- Filter
-
Commonly used in other components, such as:
Component comparison
Action and Button can both trigger operations, but are designed for different contexts.
Accessibility
ARIA attributes
It is recommended to limit the use of ARIA attributes to ensure access and interactivity with your solutions. Developers should evaluate each specified attribute to support more audiences. For instance, if Action toggles another component's visibility on interaction, the expanded property name could be specified to provide additional context to assisitive technologies.
let actionElExpanded = false;
actionEl.addEventListener("click", () => {
actionElExpanded = !actionElExpanded;
actionEl.aria = {
expanded: actionElExpanded
}
});Keyboard navigation
| Key | Function |
|---|---|
Space | Presses the component. |
Enter | Presses the component. |
Tab | Moves focus in and out of the component. |
Tab and Shift | Moves focus in and out of the component. |
Writing and copy
- Keep text for Action labels simple and succinct
- Avoid using more than two words in each item
- Do not use punctuation like commas or periods in Action label text
- Do not use contractions (you're, aren't, can't, haven't) in order to reduce confusion
- Avoid writing Action text as questions
- Recommended character maximum for each item: 15
API reference
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
| active | active | When | boolean | false |
| alignment | alignment | Specifies the horizontal alignment of button elements with text content. | Alignment | undefined | |
| appearance | appearance | Specifies the appearance of the component. | Extract<"solid" | "transparent", Appearance> | "transparent" |
| aria | When specified, overrides or extends ARIA properties and attributes on the component's button. Refer to the component's accessibility section for configuration considerations. | Partial<Pick<AriaAttributesCamelCased, "controlsElements" | "describedByElements" | "expanded" | "hasPopup" | "labelledByElements" | "ownsElements" | "pressed" | "checked"> & Pick<LuminaJsx.HTMLAttributes, "role">> | undefined | ||
| compact | compact | When | boolean | false |
| disabled | disabled | When | boolean | false |
| form | form | Specifies the When not set, the component is associated with its ancestor form element, if one exists. | string | undefined | |
| icon | icon | Specifies an icon to display. | IconName | undefined | |
| iconFlipRtl | icon-flip-rtl | When | boolean | false |
| indicator | indicator | When | boolean | false |
| label | label | Specifies an accessible label for the component. If no label is provided, the label inherits what's provided for the | string | undefined | |
| loading | loading | When | boolean | false |
| messageOverrides | Overrides individual strings used by the component. | Record<string, unknown> | undefined | ||
| overflowDisabled | overflow-disabled | When | boolean | false |
| scale | scale | Specifies the size of the component. | Scale | "m" |
| text | text | Specifies text that accompanies the icon. | string | |
| textEnabled | text-enabled | When When | boolean | false |
| type | type | Specifies the default behavior of the component. | HTMLButtonElement["type"] | "button" |
Slots
| Name | Description |
|---|---|
| default (unnamed) | A slot for adding non-interactive content, such as a |
Styles
| Name | Description |
|---|---|
| --calcite-action-background-color-hover | Specifies the component's background color when hovered. |
| --calcite-action-background-color-press | Specifies the component's background color when active. |
| --calcite-action-background-color-pressed | --calcite-action-background-color-press instead. Specifies the component's background color when active. |
| --calcite-action-background-color | Specifies the component's background color. |
| --calcite-action-corner-radius-end-end | --calcite-action-corner-radius instead. Specifies the component's corner radius end end. |
| --calcite-action-corner-radius-end-start | --calcite-action-corner-radius instead. Specifies the component's corner radius end start. |
| --calcite-action-corner-radius-start-end | --calcite-action-corner-radius instead. Specifies the component's corner radius start end. |
| --calcite-action-corner-radius-start-start | --calcite-action-corner-radius instead. Specifies the component's corner radius start start. |
| --calcite-action-corner-radius | Specifies the component's corner radius. |
| --calcite-action-indicator-color | Specifies the component's indicator color. |
| --calcite-action-text-color-press | Specifies the component's text color when pressed or hovered. |
| --calcite-action-text-color-pressed | --calcite-action-text-color-press instead. Specifies the component's text color when hovered. |
| --calcite-action-text-color | Specifies the component's text color. |
Methods
| Name | Description | Signature |
|---|---|---|
| componentOnReady | Creates a promise that resolves once the component is fully loaded. | componentOnReady(): Promise<this> |
| setFocus | Sets focus on the component. | setFocus(options?: FocusOptions): Promise<void> |