# 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 Information Personal information form here. Billing Address Billing 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 -*/} Settings Application settings content Preferences User preferences content Advanced Advanced 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 Settings Edit {/*- end highlight -*/} Configure your project settings including name, description, and permissions. Preferences User 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 -*/ )}> Name Type Level {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 `
` element to associate the button with. The value of this attribute must be the id of a `` in the same document. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#form). | | `formAction` | `string | undefined` | — | The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner. | | `formEncType` | `string | undefined` | — | Indicates how to encode the form data that is submitted. | | `formMethod` | `string | undefined` | — | Indicates the HTTP method used to submit the form. | | `formNoValidate` | `boolean | undefined` | — | Indicates that the form is not to be validated when it is submitted. | | `formTarget` | `string | undefined` | — | Overrides the target attribute of the button's form owner. | | `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 the button is disabled. | | `isPending` | `boolean | undefined` | — | Whether the button is in a pending state. This disables press and hover events while retaining focusability, and announces the pending state to screen readers. | | `isQuiet` | `boolean | undefined` | — | Whether the button should be displayed with a [quiet style](https://spectrum.adobe.com/page/action-button/#Quiet). | | `name` | `string | undefined` | — | Submitted as a pair with the button's value as part of the form data. | | `onBlur` | `((e: FocusEvent) => void) | undefined` | — | Handler that is called when the element loses focus. | | `onFocus` | `((e: FocusEvent) => void) | undefined` | — | Handler that is called when the element receives focus. | | `onFocusChange` | `((isFocused: boolean) => void) | undefined` | — | Handler that is called when the element's focus status changes. | | `onKeyDown` | `((e: KeyboardEvent) => void) | undefined` | — | Handler that is called when a key is pressed. | | `onKeyUp` | `((e: KeyboardEvent) => void) | undefined` | — | Handler that is called when a key is released. | | `onPress` | `((e: PressEvent) => void) | undefined` | — | Handler that is called when the press is released over the target. | | `onPressChange` | `((isPressed: boolean) => void) | undefined` | — | Handler that is called when the press state changes. | | `onPressEnd` | `((e: PressEvent) => void) | undefined` | — | Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | | `onPressStart` | `((e: PressEvent) => void) | undefined` | — | Handler that is called when a press interaction starts. | | `onPressUp` | `((e: PressEvent) => void) | undefined` | — | Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | | `preventFocusOnPress` | `boolean | undefined` | — | Whether to prevent focus from moving to the button when pressing it. Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control. | | `size` | `"S" | "M" | "L" | "XL" | "XS" | undefined` | 'M' | The size of the ActionButton. | | `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. | | `staticColor` | `"black" | "white" | "auto" | undefined` | — | The static color style to apply. Useful when the ActionButton appears over a color background. | | `styles` | `StylesProp | undefined` | — | Spectrum-defined styles, returned by the `style()` macro. | | `type` | `"button" | "submit" | "reset" | undefined` | 'button' | The behavior of the button when used in an HTML form. | | `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. | | `value` | `string | undefined` | — | The value associated with the button's name when it's submitted with the form data. | --- # Source: https://react-spectrum.adobe.com/ActionButtonGroup.md # ActionButtonGroup An ActionButtonGroup is a grouping of related ActionButtons. ```tsx import {ActionButtonGroup, ActionButton, Text} from '@react-spectrum/s2'; import Cut from '@react-spectrum/s2/icons/Cut'; import Copy from '@react-spectrum/s2/icons/Copy'; import Paste from '@react-spectrum/s2/icons/Paste'; Cut Copy Paste ``` ## API ```tsx ``` ### ActionButtonGroup | 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` | `ReactNode` | — | The children of the group. | | `density` | `"compact" | "regular" | undefined` | "regular" | Spacing between the buttons. | | `isDisabled` | `boolean | undefined` | — | Whether the group is disabled. | | `isJustified` | `boolean | undefined` | — | Whether the buttons should divide the container width equally. | | `isQuiet` | `boolean | undefined` | — | Whether the button should be displayed with a [quiet style](https://spectrum.adobe.com/page/action-button/#Quiet). | | `orientation` | `"horizontal" | "vertical" | undefined` | 'horizontal' | The axis the group should align with. | | `size` | `"S" | "M" | "L" | "XL" | "XS" | undefined` | "M" | Size of the buttons. | | `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. | | `staticColor` | `"black" | "white" | "auto" | undefined` | — | The static color style to apply. Useful when the ActionButtonGroup appears over a color background. | | `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` | `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/ActionMenu.md # ActionMenu ActionMenu combines an ActionButton with a Menu for simple "more actions" use cases. ```tsx import {ActionMenu, MenuItem, Text, Keyboard} from '@react-spectrum/s2'; import Copy from '@react-spectrum/s2/icons/Copy'; import Cut from '@react-spectrum/s2/icons/Cut'; import Paste from '@react-spectrum/s2/icons/Paste'; alert('copy')}> Copy Copy the selected text ⌘C alert('cut')}> Cut Cut the selected text ⌘X alert('paste')}> Paste Paste the copied text ⌘V ``` ## API ```tsx ``` ### ActionMenu | Name | Type | Default | Description | |------|------|---------|-------------| | `align` | `"start" | "end" | undefined` | 'start' | Alignment of the menu relative to the trigger. | | `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. | | `autoFocus` | `boolean | undefined` | — | Whether the element should receive focus on render. | | `children` | `ReactNode | ((item: T) => ReactNode)` | — | The contents of the collection. | | `defaultOpen` | `boolean | undefined` | — | Whether the overlay is open by default (uncontrolled). | | `direction` | `"top" | "bottom" | "start" | "end" | "left" | "right" | undefined` | 'bottom' | Where the Menu opens relative to its trigger. | | `disabledKeys` | `Iterable | undefined` | — | The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with. | | `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 the button is disabled. | | `isOpen` | `boolean | undefined` | — | Whether the overlay is open by default (controlled). | | `isQuiet` | `boolean | undefined` | — | Whether the button should be displayed with a [quiet style](https://spectrum.adobe.com/page/action-button/#Quiet). | | `items` | `Iterable | undefined` | — | Item objects in the collection. | | `menuSize` | `"S" | "M" | "L" | "XL" | undefined` | 'M' | The size of the Menu. | | `onAction` | `((key: Key) => void) | undefined` | — | Handler that is called when an item is selected. | | `onOpenChange` | `((isOpen: boolean) => void) | undefined` | — | Handler that is called when the overlay's open state changes. | | `shouldFlip` | `boolean | undefined` | true | Whether the menu should automatically flip direction when space is limited. | | `size` | `"S" | "M" | "L" | "XL" | "XS" | undefined` | 'M' | The size of the ActionButton. | | `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/Avatar.md # Avatar An avatar is a thumbnail representation of an entity, such as a user or an organization. ```tsx import {Avatar} from '@react-spectrum/s2'; ``` ## API | Name | Type | Default | Description | |------|------|---------|-------------| | `alt` | `string | undefined` | — | Text description of the avatar. | | `id` | `string | undefined` | — | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). | | `isOverBackground` | `boolean | undefined` | — | Whether the avatar is over a color background. | | `size` | `28 | 16 | 20 | 24 | 32 | 36 | 40 | 44 | 48 | 56 | 64 | 80 | 96 | 112 | (number & {}) | undefined` | 24 | The size of the avatar. | | `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. | | `src` | `string | undefined` | — | The image URL for the avatar. | | `styles` | `StylesPropWithoutWidth | 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/AvatarGroup.md # AvatarGroup An avatar group is a grouping of avatars that are related to each other. ```tsx import {AvatarGroup, Avatar} from '@react-spectrum/s2'; ``` ## API ```tsx ``` ### AvatarGroup | 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` | `ReactNode` | — | Avatar children of the avatar group. | | `id` | `string | undefined` | — | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). | | `label` | `string | undefined` | — | The label for the avatar group. | | `size` | `28 | 16 | 20 | 24 | 32 | 36 | 40 | undefined` | 24 | The size of the avatar group. | | `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` | `StylesPropWithoutWidth | 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/Badge.md # Badge Badges are used for showing a small amount of color-categorized metadata, ideal for getting a user's attention. ```tsx import {Badge} from '@react-spectrum/s2'; ``` ## API ```tsx ``` ### Badge | 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 content to display in the badge. | | `fillStyle` | `"bold" | "subtle" | "outline" | undefined` | 'bold' | The fill of the badge. | | `id` | `string | undefined` | — | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). | | `overflowMode` | `"wrap" | "truncate" | undefined` | 'wrap' | Sets the text behavior for the contents. | | `size` | `"S" | "M" | "L" | "XL" | undefined` | 'S' | The size of the badge. | | `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. | | `variant` | `"accent" | "informative" | "neutral" | "positive" | "notice" | "negative" | "gray" | "red" | "orange" | "yellow" | "chartreuse" | "celery" | "green" | "seafoam" | "cyan" | "blue" | "indigo" | "purple" | "fuchsia" | "magenta" | "pink" | "turquoise" | "brown" | "cinnamon" | "silver" | undefined` | 'neutral' | The variant changes the background color of the badge. When badge has a semantic meaning, they should use the variant for semantic colors. | --- # Source: https://react-spectrum.adobe.com/Breadcrumbs.md # Breadcrumbs Breadcrumbs show hierarchy and navigational context for a user's location within an application. ```tsx import {Breadcrumbs, Breadcrumb} from '@react-spectrum/s2'; Home React Spectrum Breadcrumbs ``` ## Content `Breadcrumbs` follows the [Collection Components API](collections.md?component=Breadcrumbs), accepting both static and dynamic collections. This example shows a dynamic collection, passing a list of objects to the `items` prop, and a function to render the children. The `onAction` event is called when a user presses a breadcrumb. ```tsx import {Breadcrumbs, Breadcrumb, type Key} from '@react-spectrum/s2'; import {useState} from 'react'; function Example() { let [breadcrumbs, setBreadcrumbs] = useState([ {id: 1, label: 'Home'}, {id: 2, label: 'Library'}, {id: 3, label: 'Documents'}, {id: 4, label: 'Annual Reports'} ]); let navigate = (id: Key) => { let i = breadcrumbs.findIndex(item => item.id === id); setBreadcrumbs(breadcrumbs.slice(0, i + 1)); }; return ( /*- begin highlight -*/ {item => {item.label}} /*- end highlight -*/ ); } ``` Accessibility When breadcrumbs are used as a main navigation element for a page, they can be placed in a [navigation landmark](https://www.w3.org/WAI/ARIA/apg/patterns/landmarks/examples/navigation). Landmarks help assistive technology users quickly find major sections of a page. Place breadcrumbs inside a `