ToolBar
Contextual action bar with docked and floating placements.
Installation
npx axiom add tool-barpnpm dlx axiom add tool-baryarn dlx axiom add tool-barbun x axiom add tool-barAlso copies: icon, text and tappable. Installs react-native-reanimated and react-native-safe-area-context.
Colors come from toolBar.{docked,floating} and toolBar.action.{default,selected,destructive,disabled} in the component tokens.
Usage
import { ToolBar } from "@/components/ui/tool-bar";
<ToolBar placement="floating">
<ToolBar.Action icon="share" label="Share" onPress={share} />
<ToolBar.Action icon="trash" label="Delete" destructive onPress={remove} />
</ToolBar>;Props
ToolBar
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Actions and optional separators. Keep the most useful actions visible. |
placement | 'docked' | 'floating' | 'docked' | Attaches to the bottom edge or renders as an inset capsule over content. |
safeArea | boolean | true | Adds the bottom safe-area inset for a docked bar. Floating bars use an inset margin instead. |
visible | boolean | true | Shows or hides the bar with its enter and exit transition. A hidden bar keeps its space and takes no touches. |
justify | 'start' | 'center' | 'between' | 'around' | 'around' | Distributes actions across the available width. |
accessibilityLabel | string | 'Actions' | Name announced for the toolbar landmark. |
style | StyleProp<ViewStyle> | — | Extra styles for the outer bar. |
ToolBar.Action
| Prop | Type | Default | Description |
|---|---|---|---|
icon | IconName | ReactNode | — | Action icon. Keep icons consistent with the rest of the app. |
label | string | — | Visible action name in a docked bar and the default accessibility label. |
onPress | () => void | — | Runs the action. Use a confirmation dialog when it cannot be undone. |
disabled | boolean | false | Blocks the press and exposes the disabled state. |
destructive | boolean | false | Uses the error color for an action such as Delete. It does not add confirmation by itself. |
selected | boolean | false | Marks a toggle action such as Favorite or Pin as active. |
showLabel | boolean | placement === 'docked' | Controls the visible label. The accessible name stays available when the label is hidden. |
accessibilityLabel | string | label | Spoken action name when the visible label is absent or ambiguous. |
ToolBar.Separator
| Prop | Type | Default | Description |
|---|---|---|---|
style | StyleProp<ViewStyle> | — | Extra styles for a short divider between action groups. |
Use cases
Selection actions
Show a docked bar only while items are selected. Actions apply to the current selection, and the normal bottom navigation should leave the screen at the same time.
<ToolBar visible={selectedIds.length > 0}>
<ToolBar.Action icon="share" label="Share" onPress={shareSelected} />
<ToolBar.Action
icon="download"
label="Download"
onPress={downloadSelected}
/>
<ToolBar.Action
icon="trash"
label="Delete"
destructive
onPress={confirmDelete}
/>
</ToolBar>Floating actions over media
The floating placement keeps controls close to the content without creating a permanent screen edge. Hide labels only when every icon is familiar.
<ToolBar placement="floating">
<ToolBar.Action
icon="share"
label="Share"
showLabel={false}
onPress={share}
/>
<ToolBar.Action icon="edit" label="Edit" showLabel={false} onPress={edit} />
<ToolBar.Action
icon="heart"
label="Favorite"
showLabel={false}
selected={favorite}
onPress={toggleFavorite}
/>
<ToolBar.Action
icon="more"
label="More actions"
showLabel={false}
onPress={openMenu}
/>
</ToolBar>Editor commands
Toolbars can group local editing commands. Disable actions that do not apply instead of removing them, so the row does not jump as the selection changes.
<ToolBar justify="between">
<ToolBar.Action icon="plus" label="Insert" onPress={openInsertMenu} />
<ToolBar.Action icon="check" label="Checklist" onPress={toggleChecklist} />
<ToolBar.Action
icon="arrow-up"
label="Move"
disabled={!canMove}
onPress={moveBlock}
/>
<ToolBar.Action icon="more" label="Format" onPress={openFormatting} />
</ToolBar>Related
- Selection mode
- BottomTabBar
- IconButton
- Dialog, for destructive confirmations