UNPKG

@nebulaai/lumina-ui

Version:

Enterprise-grade glass morphism UI components with neural-inspired design system

35 lines (26 loc) 686 B
import { useState } from 'react' export interface Toast { id: string title?: string description?: string variant?: 'default' | 'destructive' } export function useToast() { const [toasts, setToasts] = useState<Toast[]>([]) const toast = (props: Omit<Toast, 'id'>) => { const id = Math.random().toString(36).substring(2, 9) const newToast = { id, ...props } setToasts((prev) => [...prev, newToast]) setTimeout(() => { setToasts((prev) => prev.filter((t) => t.id !== id)) }, 5000) } const dismiss = (id: string) => { setToasts((prev) => prev.filter((t) => t.id !== id)) } return { toasts, toast, dismiss, } }