# React Aria
> An accordion is a container for multiple accordion items.
---
# Source: https://react-spectrum.adobe.com/Accordion.md
# Accordion
An accordion is a container for multiple accordion items.
```tsx
import {Accordion, AccordionItem, AccordionItemTitle, AccordionItemPanel} from '@react-spectrum/s2';
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
Personal InformationPersonal information form here.Billing AddressBilling address form here.
```
## Expanding
Use the `defaultExpandedKeys` or `expandedKeys` prop to set the expanded items, and `onExpandedChange` to handle user interactions. The expanded keys correspond to the `id` prop of each ``.
```tsx
import {Accordion, AccordionItem, AccordionItemTitle, AccordionItemPanel, type Key} from '@react-spectrum/s2';
import {useState} from 'react';
function Example() {
let [expandedKeys, setExpandedKeys] = useState(new Set(['settings']));
return (
{/*- end highlight -*/}
SettingsApplication settings contentPreferencesUser preferences contentAdvancedAdvanced configuration options
);
}
```
## Content
Use `AccordionItemHeader` to add additional elements alongside the title, such as action buttons or icons.
```tsx
import {Accordion, AccordionItem, AccordionItemTitle, AccordionItemPanel, AccordionItemHeader, ActionButton} from '@react-spectrum/s2';
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
{/*- begin highlight -*/}
Project SettingsEdit
{/*- end highlight -*/}
Configure your project settings including name, description, and permissions.
PreferencesUser preferences content
```
## API
```tsx
```
### Accordion
| Name | Type | Default | Description |
|------|------|---------|-------------|
| `allowsMultipleExpanded` | `boolean | undefined` | â | Whether multiple accordion items can be expanded at the same time. |
| `children` | `React.ReactNode` | â | The accordion item elements in the accordion. |
| `defaultExpandedKeys` | `Iterable | undefined` | â | The initial expanded keys in the accordion (uncontrolled). |
| `density` | `"compact" | "regular" | "spacious" | undefined` | 'regular' | The amount of space between the accordion items. |
| `expandedKeys` | `Iterable | undefined` | â | The currently expanded keys in the accordion (controlled). |
| `id` | `string | undefined` | â | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). |
| `isDisabled` | `boolean | undefined` | â | Whether all accordion items are disabled. |
| `isQuiet` | `boolean | undefined` | â | Whether the accordion should be displayed with a quiet style. |
| `onExpandedChange` | `((keys: Set) => any) | undefined` | â | Handler that is called when accordion items are expanded or collapsed. |
| `size` | `"S" | "M" | "L" | "XL" | undefined` | 'M' | The size of the accordion. |
| `slot` | `string | null | undefined` | â | 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. |
| `styles` | `StylesPropWithHeight | undefined` | â | Spectrum-defined styles, returned by the `style()` macro. |
| `UNSAFE_className` | `UnsafeClassName | undefined` | â | Sets the CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
| `UNSAFE_style` | `React.CSSProperties | undefined` | â | Sets inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
### AccordionItem
| Name | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `React.ReactNode` | â | The contents of the accordion item, consisting of a accordion item title and accordion item panel. |
| `defaultExpanded` | `boolean | undefined` | â | Whether the accordion item is expanded by default (uncontrolled). |
| `density` | `"compact" | "regular" | "spacious" | undefined` | 'regular' | The amount of space between the accordion item. |
| `id` | `Key | undefined` | â | An id for the accordion item, matching the id used in `expandedKeys`. |
| `isDisabled` | `boolean | undefined` | â | Whether the accordion item is disabled. |
| `isExpanded` | `boolean | undefined` | â | Whether the accordion item is expanded (controlled). |
| `isQuiet` | `boolean | undefined` | â | Whether the accordion item should be displayed with a quiet style. |
| `onExpandedChange` | `((isExpanded: boolean) => void) | undefined` | â | Handler that is called when the accordion item's expanded state changes. |
| `size` | `"S" | "M" | "L" | "XL" | undefined` | 'M' | The size of the accordion item. |
| `slot` | `string | null | undefined` | â | 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. |
| `styles` | `StylesProp | undefined` | â | Spectrum-defined styles, returned by the `style()` macro. |
| `UNSAFE_className` | `UnsafeClassName | undefined` | â | Sets the CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
| `UNSAFE_style` | `React.CSSProperties | undefined` | â | Sets inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
### AccordionItemHeader
| Name | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `React.ReactNode` | â | The contents of the accordion item header. |
| `id` | `string | undefined` | â | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). |
| `UNSAFE_className` | `UnsafeClassName | undefined` | â | Sets the CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
| `UNSAFE_style` | `React.CSSProperties | undefined` | â | Sets inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
### AccordionItemTitle
| Name | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `React.ReactNode` | â | The contents of the accordion item title. |
| `id` | `string | undefined` | â | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). |
| `level` | `number | undefined` | 3 | The heading level of the accordion item title. |
| `UNSAFE_className` | `UnsafeClassName | undefined` | â | Sets the CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
| `UNSAFE_style` | `React.CSSProperties | undefined` | â | Sets inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
### AccordionItemPanel
| Name | Type | Default | Description |
|------|------|---------|-------------|
| `aria-describedby` | `string | undefined` | â | Identifies the element (or elements) that describes the object. |
| `aria-details` | `string | undefined` | â | Identifies the element (or elements) that provide a detailed, extended description for the object. |
| `aria-label` | `string | undefined` | â | Defines a string value that labels the current element. |
| `aria-labelledby` | `string | undefined` | â | Identifies the element (or elements) that labels the current element. |
| `children` | `React.ReactNode` | â | The contents of the accordion item panel. |
| `id` | `string | undefined` | â | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). |
| `role` | `"region" | "group" | undefined` | 'group' | The accessibility role for the accordion item panel. |
| `UNSAFE_className` | `UnsafeClassName | undefined` | â | Sets the CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
| `UNSAFE_style` | `React.CSSProperties | undefined` | â | Sets inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
---
# Source: https://react-spectrum.adobe.com/ActionBar.md
# ActionBar
Action bars are used for single and bulk selection patterns when a user needs to perform actions on one or more items at the same time.
```tsx
import {ActionBar, ActionButton, TableView, TableHeader, TableBody, Column, Row, Cell, Text} from '@react-spectrum/s2';
import Edit from '@react-spectrum/s2/icons/Edit';
import Copy from '@react-spectrum/s2/icons/Copy';
import Delete from '@react-spectrum/s2/icons/Delete';
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
let rows = [
{id: 1, name: 'Charizard', type: 'Fire, Flying', level: '67'},
{id: 2, name: 'Blastoise', type: 'Water', level: '56'},
{id: 3, name: 'Venusaur', type: 'Grass, Poison', level: '83'},
{id: 4, name: 'Pikachu', type: 'Electric', level: '100'}
];
function Example(props) {
return (
(
/*- begin focus -*/
alert('Edit action')}>
Edit alert('Copy action')}>
Copy alert('Delete action')}>
Delete
/*- end focus -*/
)}>
NameTypeLevel
{item => (
{item.name}{item.type}{item.level}
)}
);
}
```
## API
```tsx
```
### ActionBar
| Name | Type | Default | Description |
|------|------|---------|-------------|
| `children` | `ReactNode` | â | A list of ActionButtons to display. |
| `id` | `string | undefined` | â | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). |
| `isEmphasized` | `boolean | undefined` | â | Whether the ActionBar should be displayed with a emphasized style. |
| `onClearSelection` | `(() => void) | undefined` | â | Handler that is called when the ActionBar clear button is pressed. |
| `scrollRef` | `RefObject | undefined` | â | A ref to the scrollable element the ActionBar appears above. |
| `selectedItemCount` | `number | "all" | undefined` | â | The number of selected items that the ActionBar is currently linked to. If 0, the ActionBar is hidden. |
| `slot` | `string | null | undefined` | â | 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. |
| `styles` | `StylesProp | undefined` | â | Spectrum-defined styles, returned by the `style()` macro. |
| `UNSAFE_className` | `UnsafeClassName | undefined` | â | Sets the CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
| `UNSAFE_style` | `CSSProperties | undefined` | â | Sets inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. Only use as a **last resort**. Use the `style` macro via the `styles` prop instead. |
---
# Source: https://react-spectrum.adobe.com/ActionButton.md
# 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.
```tsx
import {ActionButton} from '@react-spectrum/s2';
```
## Events
Use the `onPress` prop to handle interactions via mouse, keyboard, and touch. The `onPressStart`, `onPressEnd`, and `onPressChange` events are also emitted as the user interacts with the button.
```tsx
import {ActionButton} from '@react-spectrum/s2';
import {useState} from 'react';
function Example() {
let [count, setCount] = useState(0);
return (
/*- begin highlight -*/
setCount(c => c + 1)}>
{/*- end highlight -*/}
{count} Edits
);
}
```
## Pending
Use the `isPending` prop to display a pending state. Pending buttons remain focusable, but are otherwise disabled. After a 1 second delay, an indeterminate spinner will be displayed in place of the button label and icon.
```tsx
import {ActionButton} from '@react-spectrum/s2';
import {useState} from 'react';
function PendingButton() {
let [isPending, setPending] = useState(false);
return (
{
setPending(true);
setTimeout(() => {
setPending(false);
}, 5000);
}}>
Save
);
}
```
## API
```tsx
or
```
### ActionButton
| Name | Type | Default | Description |
|------|------|---------|-------------|
| `aria-controls` | `string | undefined` | â | Identifies the element (or elements) whose contents or presence are controlled by the current element. |
| `aria-current` | `boolean | "time" | "true" | "false" | "page" | "step" | "location" | "date" | undefined` | â | Indicates whether this element represents the current item within a container or set of related elements. |
| `aria-describedby` | `string | undefined` | â | Identifies the element (or elements) that describes the object. |
| `aria-details` | `string | undefined` | â | Identifies the element (or elements) that provide a detailed, extended description for the object. |
| `aria-disabled` | `boolean | "true" | "false" | undefined` | â | Indicates whether the element is disabled to users of assistive technology. |
| `aria-expanded` | `boolean | "true" | "false" | undefined` | â | Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. |
| `aria-haspopup` | `boolean | "dialog" | "menu" | "true" | "false" | "listbox" | "tree" | "grid" | undefined` | â | Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. |
| `aria-label` | `string | undefined` | â | Defines a string value that labels the current element. |
| `aria-labelledby` | `string | undefined` | â | Identifies the element (or elements) that labels the current element. |
| `aria-pressed` | `boolean | "true" | "false" | "mixed" | undefined` | â | Indicates the current "pressed" state of toggle buttons. |
| `autoFocus` | `boolean | undefined` | â | Whether the element should receive focus on render. |
| `children` | `ReactNode` | â | The content to display in the ActionButton. |
| `excludeFromTabOrder` | `boolean | undefined` | â | 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. |
| `form` | `string | undefined` | â | The `