Skip to content

Snackbar

Bottom (or top) feedback bar for short messages and optional actions.

Use Snackbar for lightweight confirmations (“Saved”, “Undo”). For stacked transient toasts, prefer Toast.

import { Snackbar, Button } from '@truongdq01/ui';
function Example() {
const [open, setOpen] = useState(false);
return (
<>
<Button label="Save" onPress={() => setOpen(true)} />
<Snackbar
open={open}
message="Changes saved"
onClose={() => setOpen(false)}
action={<Button label="Undo" variant="ghost" size="sm" onPress={handleUndo} />}
/>
</>
);
}

Snackbar uses an elevated surface (aligned with Toast after Phase 2B):

  • Background: surface.raised + border.subtle
  • Text: text.primary
  • Action text: brand.text
  • Soft shadow — not a heavy inverse (bg.inverse) slab

Confirm readability on the app background in the example app.

PropTypeDefaultDescription
openboolean—Required. Visible state
messageReactNode—Required. Message text
onClose() => void—Close / auto-hide callback
autoHideDurationnumber | null4000ms until auto-hide; null off
actionReactNode—Trailing action element
anchorOrigin{ vertical, horizontal }{ vertical: 'bottom', horizontal: 'center' }Screen position
  • Keep messages to one short line when possible
  • Use action for undo/retry — not a second navigation flow
  • Do not rely on blur or glass behind the snackbar for contrast

Native demos: apps/example → Snackbar screen.

See Example app guide and Visual Baseline.

  • Toast — useToast queue
  • Alert — inline status blocks