Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
emilkowalski committed Nov 20, 2023
1 parent b5024f8 commit a192b37
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,14 @@ const Toast = (props: ToastProps) => {
role="status"
tabIndex={0}
ref={toastRef}
className={cn(className, toastClassname, classNames?.toast, toast?.classNames?.toast)}
className={cn(
className,
toastClassname,
classNames?.toast,
toast?.classNames?.toast,
classNames?.[toastType],
toast?.classNames?.[toastType],
)}
data-sonner-toast=""
data-styled={!Boolean(toast.jsx || toast.unstyled)}
data-mounted={mounted}
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export interface ToastClassnames {
closeButton?: string;
cancelButton?: string;
actionButton?: string;
success?: string;
error?: string;
info?: string;
warning?: string;
}

export interface ToastT {
Expand Down
15 changes: 15 additions & 0 deletions website/src/pages/styling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ toast('Hello World', {
});
```

Styling per toast type is also possible.

```jsx
<Toaster
toastOptions={{
classNames: {
error: '!bg-red-400',
success: '!text-green-400',
warning: '!text-yellow-400',
info: '!bg-blue-400',
},
}}
/>
```

## No styles

You can also disable default styles by going headless.
Expand Down

0 comments on commit a192b37

Please sign in to comment.