BetaFeedback

Snackbar

A temporary, controlled message inspired by the legacy Snackbar rather than by the v1 Toast queue. Several messages share a vertical anchor through Snackbar.Stack, so they never overlap.

Overview

A temporary, controlled message inspired by the legacy Snackbar rather than by the v1 Toast queue. Several messages share a vertical anchor through Snackbar.Stack, so they never overlap.

First example

<Snackbar isVisible={isVisible} onVisibleChange={setVisible} duration={4000}>
<Snackbar.Message>Enregistré.</Snackbar.Message>
<Snackbar.Actions>
<Snackbar.Action onPress={undo}>Annuler</Snackbar.Action>
<Snackbar.Close asChild>
<Button variant="tertiary">Fermer</Button>
</Snackbar.Close>
</Snackbar.Actions>
</Snackbar>

Anatomy

  • Snackbar owns visibility and its timer, plus placement and portal when used alone.
  • Snackbar.Stack owns one placement and portal for several snackbars, then lays them out vertically without overlap.
  • Snackbar.Message is the announcement.
  • Snackbar.Actions groups trailing controls.
  • Snackbar.Action runs an action and dismisses by default.
  • Snackbar.ActionLabel is the action text; raw action text is wrapped in it.
  • Snackbar.Close only dismisses.

duration={0} keeps it visible. position, insetHorizontal, insetVertical, maxWidth and isPortalled correspond to the legacy layout controls. The legacy message, actionLabel, showCloseAffordance and customAppearance configuration props become explicit slots and each slot accepts its own style props.

Inside Snackbar.Stack, each Snackbar keeps its own visibility, timer, content and actions; the stack takes over placement, width and portalling. Its position, spacing, insetHorizontal, insetVertical, maxWidth and isPortalled props control the shared anchor. The last child stays closest to the selected edge: a bottom stack grows upward and a top stack grows downward.

The root has the alert role and a polite live region. Entrance and exit run through Reanimated.

Usage

<Snackbar isVisible={isVisible} onVisibleChange={setVisible} duration={4000}>
  <Snackbar.Message>Enregistré.</Snackbar.Message>
  <Snackbar.Actions>
    <Snackbar.Action onPress={undo}>Annuler</Snackbar.Action>
    <Snackbar.Close asChild>
      <Button variant="tertiary">Fermer</Button>
    </Snackbar.Close>
  </Snackbar.Actions>
</Snackbar>

Several independently controlled messages go in one stack:

<Snackbar.Stack position="bottom" spacing={8}>
  <Snackbar isVisible={saved}>Enregistré.</Snackbar>
  <Snackbar isVisible={offline} variant="warning">
    Connexion interrompue.
  </Snackbar>
</Snackbar.Stack>

Root props

SnackbarProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
childrenReactNodeNo
variantSnackbarVariant | undefinedNo
colorstring | undefinedNoA raw tint applied outside the recipe cache.
radiusRadiusKey | undefinedNo
isVisibleboolean | undefinedNo
defaultVisibleboolean | undefinedNo
durationnumber | undefinedNo
onVisibleChange((isVisible: boolean) => void) | undefinedNo
onClose(() => void) | undefinedNo
positionSnackbarPosition | undefinedNo
insetHorizontalnumber | undefinedNo
insetVerticalnumber | undefinedNo
maxWidthnumber | undefinedNo
isPortalledboolean | undefinedNo
asChildboolean | undefinedNo

Slots

SnackbarActionLabelProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
childrenReactNodeNo

SnackbarActionProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
childrenReactNodeNo
isCloseOnPressboolean | undefinedNo
asChildboolean | undefinedNo

SnackbarActionsProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
childrenReactNodeNo

SnackbarCloseProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
childrenReactNodeNo
asChildboolean | undefinedNo

SnackbarMessageProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
childrenReactNodeNo

SnackbarStackProps

The node's inherited React Native props apply too, and so do its style props padding, margin, width and the rest.

PropTypeRequiredDescription
childrenReactNodeNo
positionSnackbarPosition | undefinedNo
spacingnumber | undefinedNoSpace between consecutive snackbars.
insetHorizontalnumber | undefinedNo
insetVerticalnumber | undefinedNo
maxWidthnumber | undefinedNo
isPortalledboolean | undefinedNo
asChildboolean | undefinedNo

Variants, sizes and colour

This component adds no visual axis of its own. The values it does take are in the generated types above and in the live demo.

Accessibility

The source defines no extra rule. Keep the React Native labels, roles, states and focus order your case needs, then check the result with VoiceOver and TalkBack.

Migration from legacy

This component declares no rule of its own. The migration guide covers variants, colours and slots.