Skip to content

Toast

Transient notifications powered by useToast and rendered by ToastContainer.

Use Toast for non-blocking feedback (saved, error, undo). For bottom bar actions, see Snackbar.

import { ToastContainer, useToast, Button } from '@truongdq01/ui';
function Example() {
const toast = useToast();
return (
<>
<ToastContainer position="bottom" />
<Button
label="Show toast"
onPress={() =>
toast.success('Profile saved', {
action: { label: 'Undo', onPress: () => {} },
})
}
/>
</>
);
}

Mount ToastContainer once near the app root (inside ThemeProvider + SafeAreaProvider).

  • Surface — elevated card (surface.raised) with subtle border and soft shadow
  • Status variants — semantic fill + left accent border (success, error, warning, info)
  • Action label — brand.text token for readable contrast (not muted brand)

Verify on device — CSS docs previews approximate tokens only.

PropTypeDefaultDescription
position"top" | "bottom""bottom"Screen edge for toasts
horizontalPaddingnumber16Side padding from edges
  • show({ message, variant, duration, persistent, action, icon })
  • success(message, options) · error · warning · info
  • dismiss(id) · dismissAll()
toast.show({
message: 'Item archived',
persistent: true,
action: {
label: 'Undo',
onPress: () => restoreItem(),
},
});
import { Bell } from 'lucide-react-native';
toast.show({
message: 'New notification',
icon: <Bell />,
});

Native demos: apps/example → Toast screen.

See Example app guide and Visual Baseline.

  • Snackbar — modal bottom bar with optional action
  • Alert — inline contextual feedback