Action Bar
The <ActionBar> component is a floating toolbar that provides actions related to the current selection. Pass it a message and icon to display a status related to the current selection. Pass in <ActionBarIconButton> and <ActionBarButton> components as children to display the available actions.
import { ActionBar, ActionBarIconButton, ActionBarButton,} from "stylus-ui/ActionBar";import { Button } from "stylus-ui/Button";import { faCheck, faCopy, faShare } from "@fortawesome/pro-regular-svg-icons";import { useState } from "react";
export default () => { const [isOpen, setIsOpen] = useState(false);
return ( <> <Button onClick={() => setIsOpen(true)} disabled={isOpen} variant="secondary" > {!isOpen ? "Open Action Bar" : "Action Bar is open"} </Button> <ActionBar open={isOpen} onOpenChange={setIsOpen} message="3 items selected" icon={faCheck} > <ActionBarIconButton tooltip="Copy" icon={faCopy} /> <ActionBarIconButton tooltip="Share" icon={faShare} /> <ActionBarButton onClick={() => setIsOpen(false)}> Cancel </ActionBarButton> </ActionBar> </> );};Actions only
Section titled “Actions only”To display only actions, omit the message and icon props from <ActionBar>.
import { ActionBar, ActionBarIconButton, ActionBarButton,} from "stylus-ui/ActionBar";import { Button } from "stylus-ui/Button";import { faCopy, faShare } from "@fortawesome/pro-regular-svg-icons";import { useState } from "react";
export default () => { const [isOpen, setIsOpen] = useState(false);
return ( <> <Button onClick={() => setIsOpen(true)} disabled={isOpen} variant="secondary" > {!isOpen ? "Open Action Bar" : "Action Bar is open"} </Button> <ActionBar open={isOpen} onOpenChange={setIsOpen}> <ActionBarIconButton tooltip="Copy" icon={faCopy} /> <ActionBarIconButton tooltip="Share" icon={faShare} /> <ActionBarButton onClick={() => setIsOpen(false)}> Reject </ActionBarButton> <ActionBarButton onClick={() => setIsOpen(false)} variant="primary"> Approve </ActionBarButton> </ActionBar> </> );};Position
Section titled “Position”By default, the <ActionBar> will be positioned at the bottom of the screen. You can change this by setting the side prop to top.
import { ActionBar, ActionBarButton } from "stylus-ui/ActionBar";import { Button } from "stylus-ui/Button";import { useState } from "react";
export default () => { const [isOpen, setIsOpen] = useState(false);
return ( <> <Button onClick={() => setIsOpen(true)} disabled={isOpen} variant="secondary" > {!isOpen ? "Open Action Bar" : "Action Bar is open"} </Button> <ActionBar open={isOpen} onOpenChange={setIsOpen} message="Top action bar" side="top" > <ActionBarButton onClick={() => setIsOpen(false)}> Close </ActionBarButton> </ActionBar> </> );};API Reference
Section titled “API Reference”ActionBar
Section titled “ActionBar”A toolbar which floats at the top or bottom of the viewport.
children
Action buttons (e.g. ActionBarIconButton, ActionBarButton) shown at the end.
className
Classes applied to the bar container.
container
DOM node to portal the bar into.
defaultOpen
icon
Icon shown before the message.
iconClassName
Classes applied to the message icon.
message
Short message shown at the start of the bar.
modal
onOpenChange
open
side
Position of the bar: bottom or top of viewport.
ActionBarIconButton
Section titled “ActionBarIconButton”An icon button with a tooltip that is used within ActionBar.
icon
Icon displayed in the button.
tooltip
Tooltip text shown on hover (also used as aria-label).
disabled
Disable the button, preventing it from being clicked.
dropdown
Display a caret icon to indicate that this button opens a dropdown menu.
href
Navigate to a URL when clicked. If provided, the button will render as an anchor element.
iconEnd
Display an icon at the end of the button.
iconEndProps
Props to pass to the icon component at the end of the button.
iconProps
Props to pass to the icon component at the start of the button.
loading
Display a loading indicator to the left of the button.
size
The size of the button.
theme
The theme of the button.
variant
The variant of the button.
primary: A primary button with a brand gradient background. Limit usage to one per page.secondary: A secondary button with a plain stroke. Use for most buttons.ghost: A ghost button with a transparent background. Use for buttons that should blend into the background.danger: A danger button with a red background. Use for destructive actions.
ActionBarButton
Section titled “ActionBarButton”A text button that is used within an ActionBar. Should come last when used alongside multiple icon buttons.
children
Button label (text).
disabled
Disable the button, preventing it from being clicked.
dropdown
Display a caret icon to indicate that this button opens a dropdown menu.
href
Navigate to a URL when clicked. If provided, the button will render as an anchor element.
icon
Display an icon at the start of the button.
iconEnd
Display an icon at the end of the button.
iconEndProps
Props to pass to the icon component at the end of the button.
iconProps
Props to pass to the icon component at the start of the button.
loading
Display a loading indicator to the left of the button.
size
The size of the button.
theme
The theme of the button.
tooltip
Optional tooltip shown on hover.
variant
The variant of the button.
primary: A primary button with a brand gradient background. Limit usage to one per page.secondary: A secondary button with a plain stroke. Use for most buttons.ghost: A ghost button with a transparent background. Use for buttons that should blend into the background.danger: A danger button with a red background. Use for destructive actions.