Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(toasts): colour the close button from the theme tokens

EtienneLescot159c982e6b5a
diff --git a/src/components/ui/sonner.tsx b/src/components/ui/sonner.tsx
index f12071cc0..83e5e37a0 100644
--- a/src/components/ui/sonner.tsx
+++ b/src/components/ui/sonner.tsx
@@ -32,7 +32,8 @@ const Toaster = ({ className, style, ...props }: ToasterProps) => {
// against the reader: an error with a long description is dismissed before it is
// finished, and a stack of them hides the editor with no way to clear it. The
// cross is placed on the END side by `src/index.css` — sonner puts it on the
- // start side, which is not where anything else in this app closes.
+ // start side, which is not where anything else in this app closes. Its colours live
+ // there too: from `classNames` they lose to sonner's own rule.
closeButton
toastOptions={{
// Sonner's default is the untranslated "Close toast"; the rest of the app
@@ -46,8 +47,6 @@ const Toaster = ({ className, style, ...props }: ToasterProps) => {
"!h-7 !rounded-[8px] !bg-[var(--accent)] !px-2.5 !text-[13px] !text-[var(--accent-on)]",
cancelButton:
"!h-7 !rounded-[8px] !bg-[var(--surface-3)] !px-2.5 !text-[13px] !text-[var(--fg)]",
- // The button's placement lives in src/index.css; only its colours follow the tokens.
- closeButton: "!text-[var(--muted)] hover:!text-[var(--fg)]",
},
}}
{...props}
diff --git a/src/i18n/locales/de/common.json b/src/i18n/locales/de/common.json
index 112273d50..a30957f90 100644
--- a/src/i18n/locales/de/common.json
+++ b/src/i18n/locales/de/common.json
@@ -48,7 +48,8 @@
"unhide": "Alle einblenden",
"saveDiagnostics": "Diagnosedaten speichern",
"starOnGithub": "Stern auf GitHub geben",
- "permissions": "Berechtigungen …"
+ "permissions": "Berechtigungen …",
+ "closeNotification": "Benachrichtigung schließen"
},
"updates": {
"available": "OpenScreen {{latestVersion}} ist verfügbar. Du verwendest {{currentVersion}}.",
diff --git a/src/index.css b/src/index.css
index 71b8fd853..784b8a24f 100644
--- a/src/index.css
+++ b/src/index.css
@@ -375,14 +375,20 @@ html [data-sonner-toaster] [data-sonner-toast][data-styled="true"] {
/* Inside the box, the chrome sonner gives the button stops making sense: a bordered,
opaque chip reads as a badge stuck on the corner when it is overhanging, and as a second
- surface floating on the toast when it is not. Plain icon, weight on hover only. */
+ surface floating on the toast when it is not. Plain icon, weight on hover only.
+
+ The colours are here and not in the Toaster's `classNames`: sonner sets the button's
+ colour at (0,4,0), which a Tailwind utility at (0,3,0) cannot beat, while the leading
+ `html` puts this rule at (0,4,1). Tokens, so the cross follows the toast's theme. */
html [data-sonner-toaster] [data-sonner-toast][data-styled="true"] [data-close-button] {
top: 8px;
border-color: transparent;
background: transparent;
+ color: var(--muted);
transition: background 0.12s ease-out, color 0.12s ease-out;
}
html [data-sonner-toaster] [data-sonner-toast][data-styled="true"] [data-close-button]:hover {
- background: rgb(255 255 255 / 10%);
+ background: color-mix(in oklab, var(--fg) 10%, transparent);
+ color: var(--fg);
}