From 119b053a9b4fd43740fa563c05132f54c891137e Mon Sep 17 00:00:00 2001
From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Date: Mon, 30 Nov 2026 23:07:59 -0800
Subject: [PATCH] fix(toast): toast --button-color also applies to the cancel
button in md mode
Fixes #21818
---
.../components/toast/test/custom/toast.e2e.ts | 34 +++++++++++++++++++
core/src/components/toast/toast.md.scss | 13 +++++--
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/core/src/components/toast/test/custom/toast.e2e.ts b/core/src/components/toast/test/custom/toast.e2e.ts
index a607e3e238b..780bcdc98a1 100644
--- a/core/src/components/toast/test/custom/toast.e2e.ts
+++ b/core/src/components/toast/test/custom/toast.e2e.ts
@@ -129,5 +129,39 @@ configs({ directions: ['ltr'] }).forEach(({ config, title }) => {
expect(buttonCancelColor).toBe('rgb(0, 0, 255)');
});
+
+ test('should apply --button-color to all buttons including the cancel button', async ({ page }) => {
+ await page.setContent(
+ `
+
+
+
+
+
+ `,
+ config
+ );
+
+ const colors = await page.locator('ion-toast').evaluate((el: any) => {
+ const button = el.shadowRoot?.querySelector('.toast-button:not(.toast-button-cancel)') as HTMLElement | null;
+ const cancel = el.shadowRoot?.querySelector('.toast-button-cancel') as HTMLElement | null;
+ return [
+ button ? getComputedStyle(button).color : null,
+ cancel ? getComputedStyle(cancel).color : null,
+ ];
+ });
+
+ expect(colors).toEqual(['rgb(255, 0, 0)', 'rgb(255, 0, 0)']);
+ });
});
});
diff --git a/core/src/components/toast/toast.md.scss b/core/src/components/toast/toast.md.scss
index 968afe913ab..d32f60cb417 100644
--- a/core/src/components/toast/toast.md.scss
+++ b/core/src/components/toast/toast.md.scss
@@ -8,7 +8,6 @@
--background: #{$toast-md-background};
--border-radius: #{$toast-md-border-radius};
--box-shadow: #{$toast-md-box-shadow};
- --button-color: #{ion-color(primary, base)};
--color: #{$toast-md-color};
--max-width: #{$toast-max-width};
--start: 8px;
@@ -73,6 +72,8 @@
background-color: $toast-md-button-background-color;
+ color: var(--button-color, #{ion-color(primary, base)});
+
font-family: var(--ion-font-family);
font-size: $toast-md-button-font-size;
font-weight: $toast-md-button-font-weight;
@@ -85,7 +86,15 @@
}
.toast-button-cancel {
- color: $toast-md-button-cancel-text-color;
+ color: var(--button-color, #{$toast-md-button-cancel-text-color});
+}
+
+/**
+ * When a color is set, the buttons should inherit
+ * the contrast color unless --button-color is set.
+ */
+:host(.ion-color) .toast-button {
+ color: var(--button-color);
}
.toast-button-icon-only {