Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
React Native docs
FeedbackReact Native

Toast viewport

Stack timed notifications above the app inside the safe area.

Public APILumenToastViewportReact Native

Native example

Use Toast viewport

Render one viewport at the app root and show toasts through its queue. Keep messages short and actions optional.

Toast viewport rendered in the Expo web renderer Lumen playground

Captured exampleExpo web renderer

Open interactive preview
Open the Toast viewport demo
tsx
import type { ReactNode } from 'react'
import { View } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { LumenButton, LumenToastViewport, useToast } from '@santi020k/lumen-react-native'

export const AppShell = ({ children }: { children: ReactNode }) => {
  const toast = useToast()
  const insets = useSafeAreaInsets()

  return (
    <View style={{ flex: 1 }}>
      {children}
      <LumenButton
        onPress={() =>
          toast.create({
            action: { label: 'Undo', onPress: () => undefined },
            description: 'Three files moved to the archive.',
            title: 'Archived'
          })
        }
      >
        Archive
      </LumenButton>
      <LumenToastViewport insets={insets} toast={toast} />
    </View>
  )
}
React Native
Stacks the `useToast` queue over the app inside the safe area, pausing toasts while they are touched or focused.

Reference

Public API

The primary shared and platform-specific options exposed by LumenToastViewport.

APIValues or typeDefaultDescription
placement / maxCount / durationscreen edge / visible toasts / auto-dismissbottom-center / 3 / 5000 msRender one viewport at the app root and show toasts through its queue.

Native behavior

Design and accessibility

When to use it

Render one viewport at the app root and show toasts through its queue. Keep messages short and actions optional.

Accessibility

Toasts announce by tone, pause while touched, and keep a named dismiss button.

Shared component

Available on other platforms

Apple / SwiftUIAndroid / Compose Web
React Native docsNative primitives