Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,7 @@ ion-toast,css-prop,--start
ion-toast,css-prop,--white-space
ion-toast,css-prop,--width
ion-toast,part,button
ion-toast,part,button-cancel
ion-toast,part,container
ion-toast,part,header
ion-toast,part,icon
Expand Down
13 changes: 12 additions & 1 deletion core/src/components/toast/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type { ToastAttributes, ToastPosition, ToastLayout } from './toast-interf
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
*
* @part button - Any button element that is displayed inside of the toast.
* @part button-cancel - Any button element with role "cancel" that is displayed inside of the toast.
* @part container - The element that wraps all child elements.
* @part header - The header text of the toast.
* @part message - The body text of the toast.
Expand Down Expand Up @@ -283,7 +284,13 @@ export class Toast implements ComponentInterface, OverlayInterface {
return (
<div class={buttonGroupsClasses}>
{buttons.map((b) => (
<button type="button" class={buttonClass(b)} tabIndex={0} onClick={() => this.buttonClick(b)} part="button">
<button
type="button"
class={buttonClass(b)}
tabIndex={0}
onClick={() => this.buttonClick(b)}
part={buttonPart(b)}
>
<div class="toast-button-inner">
{b.icon && (
<ion-icon
Expand Down Expand Up @@ -396,5 +403,9 @@ const buttonClass = (button: ToastButton): CssClassMap => {
};
};

const buttonPart = (button: ToastButton): string => {
return isCancel(button.role) ? 'button-cancel' : 'button';
};

type ToastPresentOptions = ToastPosition;
type ToastDismissOptions = ToastPosition;