A FAB menu opens from a FAB to show multiple related actions. It can hold two to six items, closely related under a single action, like Share.
For a single action, use a FAB alone. For a menu opened from another button, use a menu.
A FAB menu is written as a menu, with these parts in a MenuTrigger:
| Part | In | Use |
|---|---|---|
FabMenuButton | MenuTrigger | The FAB, first in the trigger. Write its icon as its children. While the menu is open, it shows a close icon instead. |
FabMenuPopover | MenuTrigger | Holds the menu, after the FabMenuButton |
FabMenu | FabMenuPopover | The list of items |
FabMenuItem | FabMenu | One item of the list |
import { FabMenu, FabMenuButton, FabMenuItem, FabMenuPopover, Icon } from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'Basic FAB menu
Put a FabMenuButton first in a MenuTrigger, and a FabMenuPopover after it. In the popover, write a FabMenu with a FabMenuItem for each action.
import { FabMenu, FabMenuButton, FabMenuItem, FabMenuPopover, Icon } from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'
export default function Basic() {
return (
<div className="box-border flex h-80 w-full items-end justify-end p-space-200">
<MenuTrigger>
<FabMenuButton aria-label="Create">
<Icon name="add" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu>
<FabMenuItem textValue="Email">
<Icon name="mail" />
Email
</FabMenuItem>
<FabMenuItem textValue="Message">
<Icon name="chat" />
Message
</FabMenuItem>
<FabMenuItem textValue="Folder">
<Icon name="folder" />
Folder
</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>
</div>
)
}Press the FAB to open the menu. Press the close button, Escape or anywhere outside the menu to close it.
Items
Write an item's icon and then its label as its children. An item looks like a tonal medium button.
Typing finds an item by its textValue. An item whose children are a plain string uses that string. Any other item, such as one with an icon, requires a textValue.
Only the label is required on an item. The icons make each item easy to identify and tell the items apart, so remove them only if necessary.
import { FabMenu, FabMenuButton, FabMenuItem, FabMenuPopover, Icon } from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'
export default function WithoutIcons() {
return (
<div className="box-border flex h-80 w-full items-end justify-end p-space-200">
<MenuTrigger>
<FabMenuButton aria-label="Create">
<Icon name="add" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu>
<FabMenuItem>Email</FabMenuItem>
<FabMenuItem>Message</FabMenuItem>
<FabMenuItem>Folder</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>
</div>
)
}Handling actions
Give each item an id. The onAction of the FabMenu is called with the id of the item that is chosen, and the item's own onAction is called too. Choosing an item closes the menu. Give an item an href to make it a link.
No action yet
import { FabMenu, FabMenuButton, FabMenuItem, FabMenuPopover, Icon } from '@material-web/react'
import { useState } from 'react'
import { MenuTrigger, type Key } from 'react-aria-components'
export default function Actions() {
const [last, setLast] = useState<Key>()
return (
<div className="box-border flex h-80 w-full items-end justify-between p-space-200">
<p className="m-0 text-body-md text-on-surface-variant">
{last ? `Last action: ${last}` : 'No action yet'}
</p>
<MenuTrigger>
<FabMenuButton aria-label="Share">
<Icon name="share" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu onAction={setLast}>
<FabMenuItem id="link" textValue="Copy link">
<Icon name="link" />
Copy link
</FabMenuItem>
<FabMenuItem id="email" textValue="Email">
<Icon name="mail" />
Email
</FabMenuItem>
<FabMenuItem id="print" textValue="Print">
<Icon name="print" />
Print
</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>
</div>
)
}Opening and closing
A FAB menu opens and closes as a menu does. To control it, set isOpen and onOpenChange on the MenuTrigger.
The menu is closed
import { FabMenu, FabMenuButton, FabMenuItem, FabMenuPopover, Icon } from '@material-web/react'
import { useState } from 'react'
import { MenuTrigger } from 'react-aria-components'
export default function Controlled() {
const [isOpen, setOpen] = useState(false)
return (
<div className="box-border flex h-80 w-full items-end justify-between p-space-200">
<p className="m-0 text-body-md text-on-surface-variant">
{isOpen ? 'The menu is open' : 'The menu is closed'}
</p>
<MenuTrigger isOpen={isOpen} onOpenChange={setOpen}>
<FabMenuButton aria-label="Create">
<Icon name="add" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu>
<FabMenuItem textValue="Email">
<Icon name="mail" />
Email
</FabMenuItem>
<FabMenuItem textValue="Message">
<Icon name="chat" />
Message
</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>
</div>
)
}While the menu is open, the rest of the page is inert and hidden from assistive technology.
Tab keeps the focus in the menu. Escape, choosing an item or a press outside the menu closes it, and the focus returns to the FAB.
Loading
Set isPending on the FabMenuButton while an action from the menu is in progress, as on a FAB. A pending FAB shows a loading indicator in place of its icon, sized to the FAB. It keeps its size and colors, so the layout around it does not shift.
import { FabMenu, FabMenuButton, FabMenuItem, FabMenuPopover, Icon } from '@material-web/react'
import { useState } from 'react'
import { MenuTrigger } from 'react-aria-components'
export default function Loading() {
const [isUploading, setUploading] = useState(false)
const upload = async () => {
setUploading(true)
await new Promise((resolve) => setTimeout(resolve, 3000))
setUploading(false)
}
return (
<div className="box-border flex h-80 w-full items-end justify-end p-space-200">
<MenuTrigger>
<FabMenuButton aria-label="Upload" isPending={isUploading}>
<Icon name="upload" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu onAction={upload}>
<FabMenuItem textValue="Photo">
<Icon name="image" />
Photo
</FabMenuItem>
<FabMenuItem textValue="Document">
<Icon name="description" />
Document
</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>
</div>
)
}- Presses: A pending FAB ignores presses and shows no hover, so it does not open the menu.
- Focus: It keeps the focus, so a keyboard user who chose an item stays on the FAB while the action runs.
- Children: Its icon is hidden while it is pending. See Pending content.
Disabled
Set isDisabled on the FabMenuButton to disable the whole menu: the FAB cannot open it. Set isDisabled on a FabMenuItem to disable that item: the keyboard skips it, and it cannot be pressed.
import { FabMenu, FabMenuButton, FabMenuItem, FabMenuPopover, Icon } from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'
export default function Disabled() {
return (
<div className="box-border flex h-80 w-full items-end justify-center gap-space-600 p-space-200">
<MenuTrigger>
<FabMenuButton aria-label="Create, disabled" isDisabled>
<Icon name="add" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu>
<FabMenuItem>Email</FabMenuItem>
<FabMenuItem>Message</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>
<MenuTrigger>
<FabMenuButton aria-label="Create">
<Icon name="add" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu>
<FabMenuItem textValue="Email">
<Icon name="mail" />
Email
</FabMenuItem>
<FabMenuItem textValue="Message" isDisabled>
<Icon name="chat" />
Message
</FabMenuItem>
<FabMenuItem textValue="Folder">
<Icon name="folder" />
Folder
</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>
</div>
)
}Color
Set color to primary (the default), secondary or tertiary. Set it on the FabMenuButton and on the FabMenu, which colors its items, and give both the same value. Use primary with the primary or primary container FAB color styles, secondary with the secondary ones and tertiary with the tertiary ones.
import { FabMenu, FabMenuButton, FabMenuItem, FabMenuPopover, Icon } from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'
const colors = ['primary', 'secondary', 'tertiary'] as const
export default function Colors() {
return (
<div className="box-border flex h-80 w-full items-end justify-center gap-space-600 p-space-200">
{colors.map((color) => (
<MenuTrigger key={color}>
<FabMenuButton color={color} aria-label={`Create, ${color}`}>
<Icon name="add" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu color={color}>
<FabMenuItem textValue="Email">
<Icon name="mail" />
Email
</FabMenuItem>
<FabMenuItem textValue="Message">
<Icon name="chat" />
Message
</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>
))}
</div>
)
}Sizes
Set size on the FabMenuButton to baseline (the default), medium or large, the sizes of a Fab. It sets the size of the FAB only: the close button and the items are the same size for all three.
import { FabMenu, FabMenuButton, FabMenuItem, FabMenuPopover, Icon } from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'
const sizes = ['baseline', 'medium', 'large'] as const
export default function Sizes() {
return (
<div className="box-border flex h-80 w-full items-end justify-center gap-space-600 p-space-200">
{sizes.map((size) => (
<MenuTrigger key={size}>
<FabMenuButton size={size} aria-label={`Create, ${size}`}>
<Icon name="add" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu>
<FabMenuItem textValue="Email">
<Icon name="mail" />
Email
</FabMenuItem>
<FabMenuItem textValue="Message">
<Icon name="chat" />
Message
</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>
))}
</div>
)
}Placement
The FabMenuButton does not position itself. Place it with its className, such as fixed right-space-200 bottom-space-200 z-fab for the corner of the window. The examples on this page put it at the end of a box instead.
<MenuTrigger>
<FabMenuButton
aria-label="Create"
color="tertiary"
className="fixed right-space-200 bottom-space-200 z-fab"
>
<Icon name="add" />
</FabMenuButton>
<FabMenuPopover>
<FabMenu color="tertiary">
<FabMenuItem id="email" textValue="Email" onAction={compose}>
<Icon name="mail" />
Email
</FabMenuItem>
<FabMenuItem id="message" textValue="Message" href="/chats/new">
<Icon name="chat" />
Message
</FabMenuItem>
</FabMenu>
</FabMenuPopover>
</MenuTrigger>The FabMenuPopover opens above the end of the FAB. Set its placement to change that: it is top end by default. It does not flip below the FAB.
Note: The FAB must stay above the items. Place the FabMenuButton where none of its ancestors creates a stacking context, such as fixed at the corner of the window.
Size and scrolling
The menu is as tall as the room above the FAB allows, up to the top edge of the window. When the items do not fit, the list scrolls behind the close button, which stays in view.
The list opens scrolled to the item nearest the FAB, unless the keyboard opened it with the first item focused.
Customization
Pass classes in the className of a part to restyle it. A class of yours replaces the part's own class for the same property. See Styling for the classes, the states and the theme.
- Transitions: To style the
FabMenuPopoverwhile it opens or closes, use theentering:andexiting:variants, or itsdata-enteringanddata-exitingattributes in your own CSS. - Every FAB menu: To restyle all the FAB menus at once, change the theme.
Children as a function
Pass a function as the children of a part to render them from its state:
FabMenuButton:isHovered,isPressed,isFocused,isFocusVisible,isDisabledandisPending.isPressedis alsotruewhile the menu is open. ItsclassNameandstylecan be functions of the same state.FabMenuPopover:isEntering,isExiting,placementandtrigger.FabMenuItem:isHovered,isPressed,isFocused,isFocusVisible,isSelected,isDisabled,hasSubmenuandisOpen. On an item,isFocusedis focus from the keyboard or the pointer, andisFocusVisibleis keyboard focus only.FabMenu: withitems, pass a function that renders each item.
The states' types are exported as FabMenuButtonRenderProps and FabMenuItemRenderProps. See Children as a function.
Limitations
Presses on the FAB
The onPress of the FabMenuButton is not called for every press. A mouse or the keyboard opens the menu without calling it, and a press on the close button closes the menu without calling it. To run code when the menu opens or closes, use onOpenChange on the MenuTrigger.
Pending content
A pending FAB shows only its loading indicator. Children written for the pending state, such as a different icon, are hidden too. For a button that shows other content while pending, build a complex button.
Use cases
Material lists what people should be able to do with assistive technology:
- Navigate and interact with the FAB menu
- Ensure focus is correct when navigating through the menu
Interaction and style
- States: The FAB and the items show a state layer on hover and a ripple on a press. Keyboard focus shows a focus ring on the FAB, and then on the item it moves to, never on the menu itself. An item that the pointer hovers takes the focus, without the ring.
- Touch target: The FAB and the close button are 56dp or larger, and every item is 56dp tall, above the 48dp minimum of a touch target.
- Color contrast: In every
colorset, the FAB's icon keeps 3:1 contrast or more with its container, and an item's label 4.5:1 or more, in the light and dark schemes at every contrast level. - Motion: With reduced motion, the FAB turns into the close button, and the items open and close, without animating.
- Forced colors: In forced colors, the FAB and every item keep an edge.
- Scrolling: When the items do not fit in the room above the FAB, the list scrolls behind the close button, which stays in view over the items, as Material advises. See Size and scrolling.
Focus
- Opened with the keyboard, the menu moves the focus to its first item, or to its last with Up arrow. Opened with a pointer, it moves the focus to the menu itself, and Down arrow or Up arrow then moves it to the first or the last item.
- While the menu is open, the FAB, now the close button, is inert with the rest of the page, so the focus stays in the menu.
- Escape, choosing an item or a press outside the menu closes it, and the focus returns to the FAB.
- A pending FAB keeps the focus, so a keyboard user who chose an item stays on the FAB while the action runs.
Keyboard navigation
| Keys | Actions |
|---|---|
| Tab | Move the focus to the FAB |
| Space or Enter | Open the menu with the first item focused, or select the focused item |
| Down arrow | Open the menu with the first item focused, or move the focus to the next item |
| Up arrow | Open the menu with the last item focused, or move the focus to the previous item |
| Home | Move the focus to the first item |
| End | Move the focus to the last item |
| Letter keys | Move the focus to the next item that starts with the typed letters |
| Escape | Close the menu and return the focus to the FAB |
- The arrow keys go round from the last item to the first, and back.
- Tab does not leave the menu. Leave it by selecting an item, with Escape, or with a press outside it.
Labeling elements
- The FAB has no visible text, so an
aria-labelor anaria-labelledbyis required on theFabMenuButton. Describe the menu that the FAB opens, such as Create, as Material advises. - The FAB reports whether the menu is open with
aria-expanded, and that it opens one witharia-haspopup. The list has themenurole and is named by the FAB, and each item has themenuitemrole. - An item is named by its label, and its icon is hidden from assistive technology. Typing finds an item by its
textValue, which an item with an icon requires. See Items. - While the menu is open, the rest of the page, the FAB with it, is hidden from assistive technology.
- A pending FAB reports that it is unavailable with
aria-disabled. Its loading indicator is hidden from assistive technology, so itsaria-labelstill names it. - When a focused FAB becomes pending, or stops being pending, screen readers announce it.
FabMenuButton
isPendingbooleanWhether the button is in a pending state. This disables press and hover events while retaining focusability, and announces the pending state to screen readers.
color'primary' | 'secondary' | 'tertiary'Default'primary'Available in primary, secondary, and tertiary color sets.
Use the primary FAB menu color set with the primary or primary container FAB color styles.
Use the secondary FAB menu color set with the secondary or secondary container FAB color styles.
Use the tertiary FAB menu color set with the tertiary or tertiary container FAB color styles.
Props of FabMenuButton (47)
formstringThe
<form>element to associate the button with. The value of this attribute must be the id of a<form>in the same document. See MDN.idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
onClick(e: MouseEvent<FocusableElement>) => voidNot recommended – use
onPressinstead.onClickis an alias foronPressprovided for compatibility with other libraries.onPressprovides additional event details for non-mouse interactions.isDisabledbooleanWhether the button is disabled.
onPress(e: PressEvent) => voidHandler that is called when the press is released over the target.
onPressStart(e: PressEvent) => voidHandler that is called when a press interaction starts.
onPressEnd(e: PressEvent) => voidHandler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChange(isPressed: boolean) => voidHandler that is called when the press state changes.
onPressUp(e: PressEvent) => voidHandler that is called when a press is released over the target, regardless of whether it started on the target or not.
autoFocusbooleanWhether the element should receive focus on render.
onFocus(e: FocusEvent<Target>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<Target>) => voidHandler that is called when the element loses focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
onKeyDown(e: KeyboardEvent) => voidHandler that is called when a key is pressed.
onKeyUp(e: KeyboardEvent) => voidHandler that is called when a key is released.
hrefstringA URL to link to if elementType="a".
targetstringThe target window for the link.
relstringThe relationship between the linked resource and the current page. See MDN.
elementTypeT | JSXElementConstructor<any>Default'button'The HTML element or React element used to render the button, e.g. 'div', 'a', or
RouterLink.aria-disabled'true' | 'false' | booleanIndicates whether the element is disabled to users of assistive technology.
aria-expanded'true' | 'false' | booleanIndicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
aria-haspopup'dialog' | 'menu' | 'true' | 'false' | 'grid' | 'listbox' | 'tree' | booleanIndicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
aria-controlsstringIdentifies the element (or elements) whose contents or presence are controlled by the current element.
aria-pressed'true' | 'false' | 'mixed' | booleanIndicates the current "pressed" state of toggle buttons.
aria-current'time' | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | booleanIndicates whether this element represents the current item within a container or set of related elements.
type'button' | 'submit' | 'reset'Default'button'The behavior of the button when used in an HTML form.
preventFocusOnPressbooleanWhether 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.
formActionButtonHTMLAttributes<HTMLButtonElement>['formAction']The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner.
formEncTypestringIndicates how to encode the form data that is submitted.
formMethodstringIndicates the HTTP method used to submit the form.
formNoValidatebooleanIndicates that the form is not to be validated when it is submitted.
formTargetstringOverrides the target attribute of the button's form owner.
namestringSubmitted as a pair with the button's value as part of the form data.
valuestringThe value associated with the button's name when it's submitted with the form data.
excludeFromTabOrderbooleanWhether 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.
onHoverStart(e: HoverEvent) => voidHandler that is called when a hover interaction starts.
onHoverEnd(e: HoverEvent) => voidHandler that is called when a hover interaction ends.
onHoverChange(isHovering: boolean) => voidHandler that is called when the hover state changes.
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.refRef<ComponentRef<T> & Element>classNameClassNameOrFunction<ButtonRenderProps>styleStyleOrFunction<ButtonRenderProps>childrenChildrenOrFunction<ButtonRenderProps>
FabMenuPopover
Props of FabMenuPopover (37)
classNameClassNameOrFunction<PopoverRenderProps>Default'react-aria-Popover'The CSS className for the element. A function may be provided to compute the class based on component state.
triggerstringThe name of the component that triggered the popover. This is reflected on the element as the
data-triggerattribute, and can be used to provide specific styles for the popover depending on which element triggered it.triggerRefRefObject<Element | null>The ref for the element which the popover positions itself with respect to.
When used within a trigger component such as DialogTrigger, MenuTrigger, Select, etc., this is set automatically. It is only required when used standalone.
isEnteringbooleanWhether the popover is currently performing an entry animation.
isExitingbooleanWhether the popover is currently performing an exit animation.
shouldSkipAnimationbooleanWhether the popover should appear and disappear without an entry or exit animation. This is used by components such as PreviewTrigger to skip animations when quickly swapping between overlays.
UNSTABLE_portalContainerdeprecatedElementDefaultdocument.bodyThe container element in which the overlay portal will be placed. This may have unknown behavior depending on where it is portalled to.
offsetnumberDefault8The additional offset applied along the main axis between the element and its anchor element.
placement'start' | 'end' | 'bottom' | 'bottom left' | 'bottom right' | 'bottom start' | 'bottom end' | 'top' | 'top left' | 'top right' | 'top start' | 'top end' | 'left' | 'left top' | 'left bottom' | 'start top' | 'start bottom' | 'right' | 'right top' | 'right bottom' | 'end top' | 'end bottom'Default'bottom'The placement of the element with respect to its anchor element.
containerPaddingnumberDefault12The placement padding that should be applied between the element and its surrounding container.
crossOffsetnumberDefault0The additional offset applied along the cross axis between the element and its anchor element.
shouldFlipbooleanDefaulttrueWhether the element should flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.
shouldCloseOnInteractOutside(element: Element) => booleanWhen user interacts with the argument element outside of the popover ref, return true if onClose should be called. This gives you a chance to filter out interaction with elements that should not dismiss the popover. By default, onClose will always be called on interaction outside the popover ref.
isKeyboardDismissDisabledbooleanDefaultfalseWhether pressing the escape key to close the popover should be disabled.
Most popovers should not use this option. When set to true, an alternative way to close the popover with a keyboard must be provided.
boundaryElementElementDefaultdocument.bodyElement that that serves as the positioning boundary.
arrowRefRefObject<Element | null>A ref for the popover arrow element.
scrollRefRefObject<Element | null>DefaultoverlayRefA ref for the scrollable region within the overlay.
shouldUpdatePositionbooleanDefaulttrueWhether the overlay should update its position automatically.
maxHeightnumberThe maxHeight specified for the overlay element. By default, it will take all space up to the current viewport height.
arrowBoundaryOffsetnumberDefault0The minimum distance the arrow's edge should be from the edge of the overlay element.
getTargetRect(target: Element) => DOMRect | null | undefinedDefaulttarget.getBoundingClientRect()Overrides the target element's bounding rectangle. Useful for positioning relative to a specific point such as the mouse cursor (e.g. context menus) or text selection.
onFocusWithin(e: FocusEvent) => voidHandler that is called when the target element or a descendant receives focus.
onBlurWithin(e: FocusEvent) => voidHandler that is called when the target element and all descendants lose focus.
onFocusWithinChange(isFocusWithin: boolean) => voidHandler that is called when the the focus within state changes.
isNonModalbooleanWhether the popover is non-modal, i.e. elements outside the popover may be interacted with by assistive technologies.
Most popovers should not use this option as it may negatively impact the screen reader experience. Only use with components such as combobox, which are designed to handle this situation carefully.
isOpenbooleanWhether the overlay is open by default (controlled).
defaultOpenbooleanWhether the overlay is open by default (uncontrolled).
onOpenChange(isOpen: boolean) => voidHandler that is called when the overlay's open state changes.
childrenChildrenOrFunction<T>The children of the component. A function may be provided to alter the children based on component state.
styleCSSProperties | (values: PopoverRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
renderDOMRenderFunction<'div', PopoverRenderProps>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
refRef<HTMLElement>
FabMenuPopover also takes the 70 attributes and events of the element it renders.
FabMenu
color'primary' | 'secondary' | 'tertiary'Default'primary'Available in primary, secondary, and tertiary color sets.
Use the primary FAB menu color set with the primary or primary container FAB color styles.
Use the secondary FAB menu color set with the secondary or secondary container FAB color styles.
Use the tertiary FAB menu color set with the tertiary or tertiary container FAB color styles.
Props of FabMenu (26)
classNameClassNameOrFunction<MenuRenderProps>Default'react-aria-Menu'The CSS className for the element. A function may be provided to compute the class based on component state.
renderEmptyState() => ReactNodeProvides content to display when there are no items in the menu.
shouldCloseOnSelectbooleanWhether the menu should close when the menu item is selected.
idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
autoFocus'first' | 'last' | booleanWhere the focus should be set.
selectionMode'none' | 'single' | 'multiple'The type of selection that is allowed in the collection.
itemsIterable<T>Item objects in the collection.
escapeKeyBehavior'none' | 'clearSelection'Default'clearSelection'Whether pressing the escape key should clear selection in the menu or not.
Most experiences should not modify this option as it eliminates a keyboard user's ability to easily clear selection. Only use if the escape key is being handled externally or should not trigger selection clearing contextually.
onAction(key: Key, value: T) => voidHandler that is called when an item is selected.
disabledKeysIterable<Key>The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.
disallowEmptySelectionbooleanWhether the collection allows empty selection.
selectedKeys'all' | Iterable<Key>The currently selected keys in the collection (controlled).
defaultSelectedKeys'all' | Iterable<Key>The initial selected keys in the collection (uncontrolled).
onSelectionChange(keys: Selection) => voidHandler that is called when the selection changes.
shouldFocusWrapbooleanWhether keyboard navigation is circular.
onClose() => voidHandler that is called when the menu should close after selecting an item.
childrenReactNode | ((item: T) => ReactNode)The contents of the collection.
dependenciesReadonlyArray<any>Values that should invalidate the item cache when using dynamic collections.
styleCSSProperties | (values: MenuRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
renderDOMRenderFunction<'div', MenuRenderProps>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.refRef<HTMLDivElement>
FabMenu also takes the 70 attributes and events of the element it renders.
FabMenuItem
Props of FabMenuItem (32)
classNameClassNameOrFunction<MenuItemRenderProps>Default'react-aria-MenuItem'The CSS className for the element. A function may be provided to compute the class based on component state.
idKeyThe unique id of the item.
valueobjectThe object value that this item represents. When using dynamic collections, this is set automatically.
textValuestringA string representation of the item's contents, used for features like typeahead.
aria-labelstringAn accessibility label for this item.
isDisabledbooleanWhether the item is disabled.
onAction() => voidHandler that is called when the item is selected.
shouldCloseOnSelectbooleanWhether the menu should close when the menu item is selected.
styleCSSProperties | (values: MenuItemRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties | undefinedThe inline style for the element. A function may be provided to compute the style based on component state.
childrenChildrenOrFunction<T>The children of the component. A function may be provided to alter the children based on component state.
render(props: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> | DetailedHTMLProps<LinkWithRequiredHref, HTMLAnchorElement>, renderProps: MenuItemRenderProps) => ReactElement<unknown, string | JSXElementConstructor<any>>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Note: You can check if
'href' in propsin order to tell whether to render an<a>element.Requirements:
- You must render the expected element type (e.g. if
<a>is expected, you cannot render a<button>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
hrefHrefA URL to link to. See MDN.
hrefLangstringHints at the human language of the linked URL. SeeMDN.
targetHTMLAttributeAnchorTargetThe target window for the link. See MDN.
relstringThe relationship between the linked resource and the current page. See MDN.
downloadboolean | stringCauses the browser to download the linked URL. A string may be provided to suggest a file name. See MDN.
pingstringA space-separated list of URLs to ping when the link is followed. See MDN.
referrerPolicy'' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'How much of the referrer to send when following the link. See MDN.
routerOptionsOptions for the configured client side router.
onHoverStart(e: HoverEvent) => voidHandler that is called when a hover interaction starts.
onHoverEnd(e: HoverEvent) => voidHandler that is called when a hover interaction ends.
onHoverChange(isHovering: boolean) => voidHandler that is called when the hover state changes.
onFocus(e: FocusEvent<Target>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<Target>) => voidHandler that is called when the element loses focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
onPress(e: PressEvent) => voidHandler that is called when the press is released over the target.
onPressStart(e: PressEvent) => voidHandler that is called when a press interaction starts.
onPressEnd(e: PressEvent) => voidHandler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChange(isPressed: boolean) => voidHandler that is called when the press state changes.
onPressUp(e: PressEvent) => voidHandler that is called when a press is released over the target, regardless of whether it started on the target or not.
onClick(e: MouseEvent<FocusableElement>) => voidNot recommended – use
onPressinstead.onClickis an alias foronPressprovided for compatibility with other libraries.onPressprovides additional event details for non-mouse interactions.refRef<HTMLDivElement>
FabMenuItem also takes the 69 attributes and events of the element it renders.