MicroClub Sonner
mcoli-ui-registry/mc-sonnerFreeComponent
A toast component for MicroClub UI
Live preview
live · rendered by the registry
Rendered by mcoli-ui-registry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://mcoli-ui.microclub.info/r/mc-sonner.jsonSource
1'use client';23import { Toaster as SonnerComponent, toast as rawToast } from 'sonner';4import { CheckCircle2, AlertCircle } from 'lucide-react';56type ToasterProps = React.ComponentProps<typeof SonnerComponent>;78const toastIcons = {9 success: <CheckCircle2 className="text-muted-foreground shrink-0 h-3.5 w-3.5" />,10 warning: <AlertCircle className="text-muted-foreground shrink-0 h-3.5 w-3.5" />,11 error: <AlertCircle className="text-muted-foreground shrink-0 h-3.5 w-3.5" />,12};1314interface ToastOptions {15 description?: string;16 action?: {17 label: string;18 onClick: () => void;19 };20}2122const mcToastCustom = (23 message: string,24 variant?: 'success' | 'warning' | 'error',25 options?: ToastOptions26) => {27 const Icon = variant ? toastIcons[variant] : null;2829 return rawToast(30 <div className="w-full h-full flex flex-col items-start justify-center gap-0.5">31 <div className="flex items-center gap-1.5 w-full max-w-66.5">32 {Icon}33 <span className="text-sm font-medium tracking-normal leading-5 text-card-foreground">34 {message}35 </span>36 </div>3738 {options?.description && (39 <p className="text-sm font-normal tracking-normal leading-5 text-muted-foreground max-w-66.5">40 {options.description}41 </p>42 )}43 </div>,44 {45 action: options?.action,46 }47 );48};4950export const toast = Object.assign(51 (message: string, options?: ToastOptions) => mcToastCustom(message, undefined, options),52 {53 success: (message: string, options?: ToastOptions) =>54 mcToastCustom(message, 'success', options),55 warning: (message: string, options?: ToastOptions) =>56 mcToastCustom(message, 'warning', options),57 error: (message: string, options?: ToastOptions) => mcToastCustom(message, 'error', options),58 }59);6061const McSonner = ({ ...props }: ToasterProps) => {62 return (63 <SonnerComponent64 className=""65 position="top-center"66 toastOptions={{67 unstyled: true,68 classNames: {69 toast:70 'w-97.5 min-h-18.5 bg-background flex items-center justify-between gap-1.5 p-4 border-[1px] rounded-lg shadow-xs border-border',71 actionButton:72 'flex items-center justify-center bg-primary text-background text-sm py-2 px-3.5 min-w-15.5 max-w-21.5 min-h-9 rounded-[8px] shadow-xs shrink-0 cursor-pointer',73 },74 }}75 {...props}76 />77 );78};7980export default McSonner;
What it pulls in
npm packages
Files it writes
More from mcoli-ui-registry
All 42 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| MicroClub Accordionmc-accordion | mcoli-ui-registry | Components | Free | 2 deps | |
| MicroClub Alertmc-alert | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Alert Dialogmc-alert-dialog | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Avatarmc-avatar | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Badgemc-badge | mcoli-ui-registry | Components | Free | 1 dep | |
| MicroClub Breadcrumbmc-breadcrumb | mcoli-ui-registry | Components | Free | 2 deps | |
| MicroClub Buttonmc-button | mcoli-ui-registry | Components | Free | 2 deps | |
| MicroClub Calendarmc-calendar | mcoli-ui-registry | Components | Free | 3 deps |
