참고:
https://fkhadra.github.io/react-toastify/introduction
https://fkhadra.github.io/react-toastify/how-to-style/
Css classes as function
You can also provide a function. This is what it looks like with tailwind css
const contextClass = {
success: "bg-blue-600",
error: "bg-red-600",
info: "bg-gray-600",
warning: "bg-orange-400",
default: "bg-indigo-600",
dark: "bg-white-600 font-gray-300"
};
return (
<>
<ToastContainer
position="bottom-center"
autoClose={5000}
hideProgressBar={false}
newestOnTop={false}
closeOnClick
rtl={false}
pauseOnFocusLoss
draggable
pauseOnHover
toastClassName={({ type }) =>
contextClass[type] +
" relative flex p-1 min-h-10 rounded-md justify-between overflow-hidden cursor-pointer"
}
bodyClassName={() =>
"w-full flex justify-center items-center rounded-full"
}
/>
</>
)
//type이 있을경우
toast.error("비밀번호를 다시 확인해주세요.", {
position: "bottom-center",
autoClose: 3000,
hideProgressBar: true,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined
});
//type이 없을 경우
toast("비밀번호를 다시 확인해주세요.", {
position: "bottom-center",
autoClose: 3000,
hideProgressBar: true,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined
});
'NEW(스크립트용)' 카테고리의 다른 글
react input type files 의 이미지 mapping 및 삭제 (dataTransfer.items.add, Array.slice(index,1) 사용) (0) | 2022.03.25 |
---|---|
select react로 custom 하기 (기존 select option 사용 x) (0) | 2022.03.16 |
react useState 로 토글버튼 만들기 (0) | 2022.03.14 |
날짜 앞뒤 *일 이후 이전 값 구하기(javascript) (0) | 2022.03.07 |
{children}사용방법 (0) | 2021.09.12 |