BackButton
Takes the user back a step. Pick the icon variant that matches the context: an arrow to go back, a cross to close.
compliant
- Overview
- Props
- Figma
Variants
The BackButton component supports several icon variants to match different navigation and action contexts:
arrowLeft(default) - Use for backward navigation, returning to previous screens or pages. This is the most common variant for back buttons.arrowRight- Use for forward navigation, moving to the next step or page in a sequence.cross- Use for closing dialogs, modals, or dismissing overlays.arrowDropdown- Use to indicate an expandable dropdown menu or collapsible section.arrowDropup- Use to indicate a collapsible section that can be collapsed or a dropdown that is currently expanded.closeAlt- Alternative close icon variant, use when you need a different visual style for closing actions.journal- Use for journal-related actions or accessing journal/log views.refresh- Use for refresh or reload actions, typically to update content or reload data.
Label
As a link
If you provide the href prop, the button will be rendered as a link (web only). In that case, the onPress prop becomes optional.
If your link is not in the same app, you can pass the full url. It is useful when, for example, your flow is integrated in the dashboard and the website.
Client side navigation example:
External link example:
Accessibility
Be sure to provide either a visual label or an aria-label prop to ensure the button is accessible to screen readers.
To read more about the accessible name, check the Accessible Names documentation.
Playground
murray and murray/mobile.BackButton props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| disabled | booleanundefined | Indicated disabled state | ||
| externalPseudoState | "hovered""pressed"undefined | Externally controlled pseudo state for hover/press effects. Use this when the button is wrapped in a component that prevents normal event handling (e.g., Popover triggers with asChild). @internal - Primarily for internal Murray use | ||
| hasDropdownArrow | booleanundefined | Adds an arrow on the right. Use when the button triggers a dropdown or similar | ||
| hitSlop | numberInsetsnullundefined | Defines how far your touch can start away from the button on mobile @platform mobile | ||
| href | stringundefined | If provided, renders as a Link component (react-router-dom) on web | ||
| isActive | booleanundefined | Sets the button in a pressed state. | ||
| label | stringundefined | |||
| onMouseEnter | undefinedMouseEventHandler<HTMLDivElement> | |||
| onMouseLeave | undefinedMouseEventHandler<HTMLDivElement> | |||
| onPress | 2 possibilitiesundefined | null | (event: GestureResponderEvent) => void(e: MouseEvent<HTMLAnchorElement, MouseEvent>) => void | When href is provided, onPress receives a React.MouseEvent<HTMLAnchorElement> | ||
| onPressIn | 3 possibilities((event: GestureResponderEvent) => void)nullundefined | |||
| onPressOut | 3 possibilities((event: GestureResponderEvent) => void)nullundefined | |||
| pressedScale | numberundefined | Scale multiplier applied on press (e.g., 1.1 for 110% scale). When provided, button will animate scale on press. | ||
| progress | booleanundefined | Determines whether the Loader component should be displayed over the button | ||
| success | booleanundefined | Determines whether a success icon should be displayed over the button | ||
| sx | PositionPropsundefined | |||
| title | stringundefined | Tooltip shown on hover (web). Defaults to `aria-label`, so sighted users see what screen readers announce. | ||
| type | "button""submit""reset"undefined | |||
| variant | BackButtonVariantundefined | arrowLeft | Controls which icon is displayed. `arrowLeft` by default |
Undocumented props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| data-testid | any | |||
| ref | any | |||
| testID | any |
Style API
Use sx for one-off adjustments. It accepts these style keys:
Each can be overridden per breakpoint with: