Home / Function/ toast() — ui Function Reference

toast() — ui Function Reference

Architecture documentation for the toast() function in use-toast.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  e082734e_c4d5_f91f_d9e4_b72e8e678602["toast()"]
  bba373ff_472d_b9de_12be_a7a606cb2977["use-toast.ts"]
  e082734e_c4d5_f91f_d9e4_b72e8e678602 -->|defined in| bba373ff_472d_b9de_12be_a7a606cb2977
  b0765e77_43b6_3663_b98f_e5450ee3d22c["genId()"]
  e082734e_c4d5_f91f_d9e4_b72e8e678602 -->|calls| b0765e77_43b6_3663_b98f_e5450ee3d22c
  23a8ce30_00a5_617f_ac96_6badbe20ecf5["dispatch()"]
  e082734e_c4d5_f91f_d9e4_b72e8e678602 -->|calls| 23a8ce30_00a5_617f_ac96_6badbe20ecf5
  style e082734e_c4d5_f91f_d9e4_b72e8e678602 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

deprecated/www/registry/new-york/hooks/use-toast.ts lines 145–172

function toast({ ...props }: Toast) {
  const id = genId()

  const update = (props: ToasterToast) =>
    dispatch({
      type: "UPDATE_TOAST",
      toast: { ...props, id },
    })
  const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id })

  dispatch({
    type: "ADD_TOAST",
    toast: {
      ...props,
      id,
      open: true,
      onOpenChange: (open) => {
        if (!open) dismiss()
      },
    },
  })

  return {
    id: id,
    dismiss,
    update,
  }
}

Subdomains

Frequently Asked Questions

What does toast() do?
toast() is a function in the ui codebase, defined in deprecated/www/registry/new-york/hooks/use-toast.ts.
Where is toast() defined?
toast() is defined in deprecated/www/registry/new-york/hooks/use-toast.ts at line 145.
What does toast() call?
toast() calls 2 function(s): dispatch, genId.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free