react-toast-craft
Version:
A simple and customizable React toast notifications library.
173 lines (149 loc) • 2.68 kB
CSS
:root {
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body {
margin: 0;
display: grid;
place-items: center;
min-height: 100vh;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
.container {
display: flex;
flex-direction: column;
gap: 1rem;
}
.toast-container {
position: fixed;
z-index: 9999;
display: flex;
flex-direction: column;
gap: 10px;
transition: all 0.3s ease-in;
}
/* Positioning classes */
.toast-top-right {
top: 20px;
right: 20px;
}
.toast-top-left {
top: 20px;
left: 20px;
}
.toast-top-center {
top: 20px;
left: 50%;
transform: translateX(-50%);
}
.toast-bottom-right {
bottom: 20px;
right: 20px;
}
.toast-bottom-left {
bottom: 20px;
left: 20px;
}
.toast-bottom-center {
bottom: 20px;
left: 50%;
transform: translateX(-50%);
}
/* Toast styling */
.toast {
padding: 10px 20px;
border-radius: 8px;
color: white;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
display: flex;
justify-content: space-between;
align-items: center;
max-width: 300px;
}
.toast span {
display: inline-block;
}
.toast .close-btn {
margin-left: 10px;
cursor: pointer;
}
.toast {
padding: 20px 25px;
border-radius: 4px;
color: white;
margin-bottom: 10px;
gap: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
max-width: 300px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
font-weight: 500;
text-transform: capitalize;
opacity: 0;
transform: translateY(-20px);
transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show {
opacity: 1;
transform: translateY(0);
}
.toast span {
word-break: break-all;
}
.close-btn {
margin-left: 10px;
cursor: pointer;
}
.toast-message {
white-space: nowrap;
}