Toaster
An opinionated toast component for React.
Set up the application root in Getting started.
Code
import { Button, toast } from "@falcon/ui-kit";
export function Example() { return ( <Button variant="outline" onClick={() => toast("Order has been created", { description: "Delivery is scheduled for December 3 at 9:00 AM.", action: { label: "Undo", onClick: () => toast.success("Order creation undone"), }, }) } > Show Toast </Button> );}Code
import { Button, toast } from "@falcon/ui-kit";
export function Example() { return ( <div className="tw:flex tw:flex-wrap tw:gap-2"> <Button variant="outline" onClick={() => toast("Order has been created")}> Default </Button> <Button variant="outline" onClick={() => toast.success("Order has been created")} > Success </Button> <Button variant="outline" onClick={() => toast.info("Pickup is available at the north loading area") } > Info </Button> <Button variant="outline" onClick={() => toast.warning("Inventory is below the reorder point")} > Warning </Button> <Button variant="outline" onClick={() => toast.error("Order has not been created")} > Error </Button> <Button variant="outline" onClick={() => { toast.promise<{ name: string }>( () => new Promise((resolve) => setTimeout(() => resolve({ name: "Order" }), 2000), ), { loading: "Loading...", success: (data) => `${data.name} has been created`, error: "Error", }, ); }} > Promise </Button> </div> );}Description
Section titled “Description”Code
import { Button, toast } from "@falcon/ui-kit";
export function Example() { return ( <Button onClick={() => toast("Order has been created", { description: "Delivery is scheduled for January 3 at 6:00 PM.", }) } variant="outline" className="tw:w-fit" > Show Toast </Button> );}Position
Section titled “Position”Use the position option to change the position of the toast.
Code
import { Button, toast } from "@falcon/ui-kit";
export function Example() { return ( <div className="tw:flex tw:h-64 tw:flex-wrap tw:content-center tw:justify-center tw:gap-2"> <Button variant="outline" onClick={() => toast("Order has been created", { position: "top-left" }) } > Top Left </Button> <Button variant="outline" onClick={() => toast("Order has been created", { position: "top-center" }) } > Top Center </Button> <Button variant="outline" onClick={() => toast("Order has been created", { position: "top-right" }) } > Top Right </Button> <Button variant="outline" onClick={() => toast("Order has been created", { position: "bottom-left" }) } > Bottom Left </Button> <Button variant="outline" onClick={() => toast("Order has been created", { position: "bottom-center" }) } > Bottom Center </Button> <Button variant="outline" onClick={() => toast("Order has been created", { position: "bottom-right" }) } > Bottom Right </Button> </div> );}Toaster
Section titled “Toaster”Mounts the toast notification region once at the app root. Renders a
section element.
className
Section titled “className”className?: stringClass name passed to each toast list element.
closeButton
Section titled “closeButton”closeButton?: booleanWhether individual toasts display a close button.
containerAriaLabel
Section titled “containerAriaLabel”containerAriaLabel?: stringAccessible label for the toast container. Defaults to "Notifications".
dir?: "ltr" | "auto"Text direction for the toast container. Right-to-left text is not supported.
duration
Section titled “duration”duration?: numberDefault duration, in milliseconds, before a toast closes. Defaults to
4000.
expand
Section titled “expand”expand?: booleanWhether stacked toasts expand on hover.
gap?: numberSpace, in pixels, between stacked toasts. Defaults to 14.
hotkey
Section titled “hotkey”hotkey?: string[]Keyboard shortcut used to focus the toast container. Defaults to Alt+T.
icons?: ToastIconsIcons rendered for each toast state. Defaults to Falcon status icons.
id?: stringIdentifier used to target this toaster.
invert
Section titled “invert”invert?: booleanWhether toast colors are inverted.
mobileOffset
Section titled “mobileOffset”mobileOffset?: OffsetOffset applied to toasts on mobile screens. Defaults to 16 pixels.
offset
Section titled “offset”offset?: OffsetOffset applied to the toast container. Defaults to 24 pixels.
position
Section titled “position”position?: PositionScreen position of the toast container. Defaults to "bottom-right".
richColors
Section titled “richColors”richColors?: booleanWhether toast types use distinct colors.
style?: React.CSSPropertiesInline styles passed to each toast list element. Replaces Falcon’s defaults.
swipeDirections
Section titled “swipeDirections”swipeDirections?: SwipeDirection[]Directions that dismiss a toast with a swipe. Defaults toward its screen edges.
theme?: "light" | "dark" | "system"Theme used for the toast container. Defaults to "light".
toastOptions
Section titled “toastOptions”toastOptions?: ToastOptionsDefault options applied to every toast. Replaces Falcon’s default toast options.
visibleToasts
Section titled “visibleToasts”visibleToasts?: numberMaximum number of visible toasts. Defaults to 3.