import { toast } from 'sud-ui';성공, 오류 등의 피드백을 표시할 때
가벼운 메시지를 표시할 때
# 1. Using SoonUIDesign Component
## The SoonUIDesign.jsx component file is written as follows.
## You can use theme system, Toast, and Notification all at once without adding them separately.
"use client";
import { ThemeProvider } from "../theme/ThemeContext";
import { ToastRoot } from "./feedback/ToastRoot";
import { NotificationRoot } from "./feedback/NotificationRoot";
export const SoonUIDesign = ({ children, theme, darkTheme, isDarkMode }) => {
return (
<ThemeProvider theme={theme} darkTheme={darkTheme} isDarkMode={isDarkMode}>
{children}
<ToastRoot />
<NotificationRoot />
</ThemeProvider>
);
};
## Include the SoonUIDesign component in your Root Layout as follows:
"use client";
import { SoonUIDesign } from "sud-ui";
export default function ClientLayout({ children }) {
return (
<SoonUIDesign>
{children}
</SoonUIDesign>
);
}
################################################
# 2. Adding Only ToastRoot
"use client";
import { ToastRoot } from "sud-ui";
export default function ClientLayout({ children }) {
return (
<>
{children}
<ToastRoot />
</>
);
}import { toast, Button } from "sud-ui";
export default function Example() {
const handleOpen = () => {
toast.success("This is a toast message");
};
return (
<Button onClick={handleOpen}>
Open Basic Toast
</Button>
);
}import { toast, Button } from "sud-ui";
export default function Example() {
const handleOpen = () => {
toast.success("This Message will be shown for 1 seconds", {
duration: 1000
});
};
return (
<Button onClick={handleOpen}>
Duration 1 seconds
</Button>
);
}import { toast, Button } from "sud-ui";
export default function Example() {
const type = ["success", "danger", "info", "warning"];
const handleOpen = (type) => () => {
toast[type](`This is a ${type} message`);
};
return (
<div className="flex flex-wrap gap-[10px]">
{type.map((t) => (
<Button key={t} onClick={handleOpen(t)}>
{t}
</Button>
))}
</div>
);
}import { toast, Button } from "sud-ui";
import { LogoSud } from "sud-icons";
export default function Example() {
const handleOpen = () => {
toast.success("Soon UI Design Library", {
icon: <LogoSud />
});
};
return (
<Button onClick={handleOpen}>
Icon Custom
</Button>
);
}속성 이름 | 설명 | 타입 | 기본값 |
|---|
| type | 토스트 타입 | success | danger | info | warning | info |
| message | 토스트 메시지 | ReactNode | - |
| duration | 토스트 지속 시간 (밀리초) | number | 3000 |
| icon | 커스텀 아이콘 (기본 아이콘 대신 사용) | ReactNode | - |