Toast
Display brief, temporary notifications in an application.
function Basic() { const handlePress = React.useCallback(() => { toast('Lorem ipsum dolor'); }, []); return <Button onPress={handlePress}>Open Toast</Button>; }
Usage
Before calling the toast
function be sure to include the Toaster
component in the root of your
application.
import { Toaster } from '@project44-manifest/react';
function App({ children }) {
return (
<>
<Toaster />
{children}
</>
);
}
Duration
To adjust the time the toast appears on screen, use the duration
prop.
function Duration() { const handlePress = React.useCallback(() => { toast('Lorem ipsum dolor', { description: 'consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', duration: 5000, }); }, []); return <Button onPress={handlePress}>Open Toast</Button>; }
Position
Set toast position on the screen using the position
prop.
function Position() { const handlePress = React.useCallback(() => { toast('Lorem ipsum dolor', { position: 'bottom-left', description: 'consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', }); }, []); return <Button onPress={handlePress}>Open bottom-left toast</Button>; }
Description
Add additional information to a toast using the description
prop.
function Description() { const handlePress = React.useCallback(() => { toast('Lorem ipsum dolor', { description: 'consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', }); }, []); return <Button onPress={handlePress}>Open Toast</Button>; }
Actions
Include additional actions for a user to perform within a toast.
function Actions() { const handlePress = React.useCallback(() => { toast('Lorem ipsum dolor', { action: <Button>Refresh Page</Button>, description: 'consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', }); }, []); return <Button onPress={handlePress}>Open Toast</Button>; }
Info
Create an informational toast using the info
method.
function Info() { const handlePress = React.useCallback(() => { toast.info('Lorem ipsum dolor', { description: 'consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', }); }, []); return <Button onPress={handlePress}>Open Toast</Button>; }
Success
Create an success toast using the success
method.
function Success() { const handlePress = React.useCallback(() => { toast.success('Lorem ipsum dolor', { description: 'consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', }); }, []); return <Button onPress={handlePress}>Open Toast</Button>; }
Warning
Create an warning toast using the warning
method.
function Warning() { const handlePress = React.useCallback(() => { toast.warning('Lorem ipsum dolor', { description: 'consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', }); }, []); return <Button onPress={handlePress}>Open Toast</Button>; }
Error
Create an error toast using the error
method.
function Error() { const handlePress = React.useCallback(() => { toast.error('Lorem ipsum dolor', { description: 'consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', }); }, []); return <Button onPress={handlePress}>Open Toast</Button>; }
Props
as?The root element to be rendered