Toast

Toast notification component

Toast component for displaying temporary notifications. Supports multiple types, positions, swipe-to-dismiss, and custom styling.

Basic Usage

import { Toast } from 'prizmux'
import { useState } from 'react'

export default function App() {
  const [visible, setVisible] = useState(false)

  return (
    <>
      <Button title="Show Toast" onPress={() => setVisible(true)} />
      <Toast
        visible={visible}
        onHide={() => setVisible(false)}
        text="Action completed!"
        type="success"
      />
    </>
  )
}

Props

PropTypeDefaultRequiredDescription
visiblebooleanToast visibility
onHide() => voidHide callback
textstringToast message
descriptionstringAdditional description
type'success' | 'error' | 'info' | 'warning''info'Toast type
position'top' | 'bottom''bottom'Toast position
dismiss'auto' | 'manual' | 'both''auto'Dismiss behavior
durationnumber3000Auto-hide duration (ms)
swipeablebooleantrueEnable swipe to dismiss
swipeDirection'horizontal' | 'vertical' | 'both''vertical'Swipe direction
swipeThresholdnumberSwipe distance threshold
iconReactNodeCustom icon
closeIconReactNodeCustom close icon
backgroundColorstringBackground color
textColorstringText color
descriptionColorstringDescription text color
borderRadiusnumber10Border radius
styleViewStyleContainer styles
textStyleTextStyleText styles
descriptionStyleTextStyleDescription styles
iconContainerStyleViewStyleIcon wrapper styles
closeButtonStyleViewStyleClose button styles
overlayStyleViewStyleOverlay styles

Types

// Success
<Toast text="Saved successfully" type="success" />

// Error
<Toast text="Something went wrong" type="error" />

// Info
<Toast text="This is informational" type="info" />

// Warning
<Toast text="Be careful" type="warning" />

Positions

// Top
<Toast text="Message" position="top" />

// Bottom (default)
<Toast text="Message" position="bottom" />

Dismiss Behavior

// Auto-dismiss (default)
<Toast
  text="Auto dismissing..."
  dismiss="auto"
  duration={3000}
/>

// Manual dismiss
<Toast
  text="Manual only"
  dismiss="manual"
/>

// Both
<Toast
  text="Either way"
  dismiss="both"
/>

With Description

<Toast
  text="Upload complete"
  description="File uploaded successfully to the server"
  type="success"
/>

Custom Icons

import { CheckCircle, AlertCircle } from 'lucide-react-native'

<Toast
  text="Success!"
  type="success"
  icon={<CheckCircle size={24} color="#fff" />}
/>

<Toast
  text="Warning!"
  type="warning"
  icon={<AlertCircle size={24} color="#fff" />}
/>

Custom Styling

<Toast
  text="Styled toast"
  backgroundColor="#00ff00"
  textColor="#000"
  borderRadius={20}
  style={{ paddingVertical: 16 }}
/>

Swipe to Dismiss

<Toast
  text="Swipe me away"
  swipeable={true}
  swipeDirection="horizontal"
  swipeThreshold={100}
/>