Pages are now available as full-screen example templates that showcase real-world use cases and best practices for composing interfaces with the aFP Design System.
<afp-alert>Since 1.0.0
stable
This component uses the light DOM, so its markup and styles are part of the regular document flow.
A dismissible alert component that can also appear as a toast notification.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad atque eveniet hic perferendis placeat quidem temporibus. At dolore et exercitationem molestias neque nostrum temporibus voluptas. Ab at nemo quo rem.
<afp-alertopen>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad atque eveniet hic perferendis placeat quidem temporibus. At dolore et exercitationem molestias neque nostrum temporibus voluptas. Ab at nemo quo rem.
</afp-alert>
<afp-alertopen>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad atque eveniet hic perferendis placeat quidem temporibus. At dolore et exercitationem molestias neque nostrum temporibus voluptas. Ab at nemo quo rem.
</afp-alert>
<AfpAlertopen>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad atque eveniet hic perferendis placeat quidem temporibus. At dolore et exercitationem molestias neque nostrum temporibus voluptas. Ab at nemo quo rem.
</AfpAlert>
<AfpAlertopen>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad atque eveniet hic perferendis placeat quidem temporibus. At dolore et exercitationem molestias neque nostrum temporibus voluptas. Ab at nemo quo rem.
</AfpAlert>
Use the variant attribute to set the alert's semantic variant.
Neutral information alertBrand information alertAccent information alertInfo information alertError information alertSuccess information alertWarning information alert
<divclass="afp-grid"><afp-alertvariant="neutral"open>Neutral information alert</afp-alert><afp-alertvariant="brand"open>Brand information alert</afp-alert><afp-alertvariant="accent"open>Accent information alert</afp-alert><afp-alertvariant="info"open>Info information alert</afp-alert><afp-alertvariant="error"open>Error information alert</afp-alert><afp-alertvariant="success"open>Success information alert</afp-alert><afp-alertvariant="warning"open>Warning information alert</afp-alert></div>
<divclass="afp-grid"><afp-alert[variant]="'neutral'"open>Neutral information alert</afp-alert><afp-alert[variant]="'brand'"open>Brand information alert</afp-alert><afp-alert[variant]="'accent'"open>Accent information alert</afp-alert><afp-alert[variant]="'info'"open>Info information alert</afp-alert><afp-alert[variant]="'error'"open>Error information alert</afp-alert><afp-alert[variant]="'success'"open>Success information alert</afp-alert><afp-alert[variant]="'warning'"open>Warning information alert</afp-alert></div>
<divclass="afp-grid"><AfpAlertvariant="neutral"open>Neutral information alert</AfpAlert><AfpAlertvariant="brand"open>Brand information alert</AfpAlert><AfpAlertvariant="accent"open>Accent information alert</AfpAlert><AfpAlertvariant="info"open>Info information alert</AfpAlert><AfpAlertvariant="error"open>Error information alert</AfpAlert><AfpAlertvariant="success"open>Success information alert</AfpAlert><AfpAlertvariant="warning"open>Warning information alert</AfpAlert></div>
<divclass="afp-grid"><AfpAlert:variant="'neutral'"open>Neutral information alert</AfpAlert><AfpAlert:variant="'brand'"open>Brand information alert</AfpAlert><AfpAlert:variant="'accent'"open>Accent information alert</AfpAlert><AfpAlert:variant="'info'"open>Info information alert</AfpAlert><AfpAlert:variant="'error'"open>Error information alert</AfpAlert><AfpAlert:variant="'success'"open>Success information alert</AfpAlert><AfpAlert:variant="'warning'"open>Warning information alert</AfpAlert></div>
Use the appearance attribute to set the alert's appearance style.
Default info alertFilled info alertOutline info alertOutlined filled info alertPlain info alert
<divclass="afp-grid"><afp-alertappearance="default"variant="info"open>Default info alert</afp-alert><afp-alertappearance="filled"variant="info"open>Filled info alert</afp-alert><afp-alertappearance="outlined"variant="info"open>Outline info alert</afp-alert><afp-alertappearance="outlined-filled"variant="info"open>Outlined filled info alert</afp-alert><afp-alertappearance="plain"variant="info"open>Plain info alert</afp-alert></div>
<divclass="afp-grid"><afp-alert[appearance]="'default'"[variant]="'info'"open>Default info alert</afp-alert><afp-alert[appearance]="'filled'"[variant]="'info'"open>Filled info alert</afp-alert><afp-alert[appearance]="'outlined'"[variant]="'info'"open>Outline info alert</afp-alert><afp-alert[appearance]="'outlined-filled'"[variant]="'info'"open>Outlined filled info alert</afp-alert><afp-alert[appearance]="'plain'"[variant]="'info'"open>Plain info alert</afp-alert></div>
<divclass="afp-grid"><AfpAlertappearance="default"variant="info"open>Default info alert</AfpAlert><AfpAlertappearance="filled"variant="info"open>Filled info alert</AfpAlert><AfpAlertappearance="outlined"variant="info"open>Outline info alert</AfpAlert><AfpAlertappearance="outlined-filled"variant="info"open>Outlined filled info alert</AfpAlert><AfpAlertappearance="plain"variant="info"open>Plain info alert</AfpAlert></div>
<divclass="afp-grid"><AfpAlert:appearance="'default'":variant="'info'"open>Default info alert</AfpAlert><AfpAlert:appearance="'filled'":variant="'info'"open>Filled info alert</AfpAlert><AfpAlert:appearance="'outlined'":variant="'info'"open>Outline info alert</AfpAlert><AfpAlert:appearance="'outlined-filled'":variant="'info'"open>Outlined filled info alert</AfpAlert><AfpAlert:appearance="'plain'":variant="'info'"open>Plain info alert</AfpAlert></div>
Use the shape attribute to set the alert's shape style.
Pill info alertRounded info alertSoft info alertSquare info alert
<divclass="afp-grid"><afp-alertshape="pill"open>Pill info alert</afp-alert><afp-alertshape="rounded"open>Rounded info alert</afp-alert><afp-alertshape="soft"open>Soft info alert</afp-alert><afp-alertshape="square"open>Square info alert</afp-alert></div>
<divclass="afp-grid"><afp-alert[shape]="'pill'"open>Pill info alert</afp-alert><afp-alert[shape]="'rounded'"open>Rounded info alert</afp-alert><afp-alert[shape]="'soft'"open>Soft info alert</afp-alert><afp-alert[shape]="'square'"open>Square info alert</afp-alert></div>
<divclass="afp-grid"><AfpAlertshape="pill"open>Pill info alert</AfpAlert><AfpAlertshape="rounded"open>Rounded info alert</AfpAlert><AfpAlertshape="soft"open>Soft info alert</AfpAlert><AfpAlertshape="square"open>Square info alert</AfpAlert></div>
<divclass="afp-grid"><AfpAlert:shape="'pill'"open>Pill info alert</AfpAlert><AfpAlert:shape="'rounded'"open>Rounded info alert</AfpAlert><AfpAlert:shape="'soft'"open>Soft info alert</AfpAlert><AfpAlert:shape="'square'"open>Square info alert</AfpAlert></div>
This is super informative
You can tell by how pretty the alert is.
<afp-alertvariant="info"openicon><afp-iconslot="icon"name="info-circle"></afp-icon><b>This is super informative</b><br/>
You can tell by how pretty the alert is.
</afp-alert>
<afp-alert[variant]="'info'"openicon><afp-icon[slot]="'icon'"[name]="'info-circle'"></afp-icon><b>This is super informative</b><br/>
You can tell by how pretty the alert is.
</afp-alert>
<AfpAlertvariant="info"openicon><AfpIconslot="icon"name="info-circle"></AfpIcon><b>This is super informative</b><br/>
You can tell by how pretty the alert is.
</AfpAlert>
<AfpAlert:variant="'info'"openicon><AfpIcon:slot="'icon'":name="'info-circle'"></AfpIcon><b>This is super informative</b><br/>
You can tell by how pretty the alert is.
</AfpAlert>
<afp-alertid="closeableAlert"variant="warning"appearance="filled"openiconcloseable><afp-iconslot="icon"name="exclamation-triangle"></afp-icon><strong>Warning:</strong> This alert can be closed manually.
</afp-alert><script>
closeableAlert.addEventListener('afp-after-hide',()=>{setTimeout(()=> closeableAlert.show(),3000);});</script>
<afp-alert[id]="'closeableAlert'"[variant]="'warning'"[appearance]="'filled'"openiconcloseable><afp-icon[slot]="'icon'"[name]="'exclamation-triangle'"></afp-icon><strong>Warning:</strong> This alert can be closed manually.
</afp-alert><script>
closeableAlert.addEventListener('afp-after-hide',()=>{setTimeout(()=> closeableAlert.show(),3000);});</script>
<AfpAlertid="closeableAlert"variant="warning"appearance="filled"openiconcloseable><AfpIconslot="icon"name="exclamation-triangle"></AfpIcon><strong>Warning:</strong> This alert can be closed manually.
</AfpAlert><script>
closeableAlert.addEventListener('afp-after-hide',()=>{setTimeout(()=> closeableAlert.show(),3000);});</script>
<AfpAlert:id="'closeableAlert'":variant="'warning'":appearance="'filled'"openiconcloseable><AfpIcon:slot="'icon'":name="'exclamation-triangle'"></AfpIcon><strong>Warning:</strong> This alert can be closed manually.
</AfpAlert><script>
closeableAlert.addEventListener('afp-after-hide',()=>{setTimeout(()=> closeableAlert.show(),3000);});</script>
Use the toast() method to display an alert as a toast notification.
Show Success Toast
Show Error Toast
Show Info Toast
Success: Your toast notification!
Error: Something went wrong!
Info: This is an informational toast.
<divclass="afp-cluster"><afp-buttononclick="toastSuccess.toast()"variant="success">
Show Success Toast
</afp-button><afp-buttononclick="toastError.toast()"variant="error">
Show Error Toast
</afp-button><afp-buttononclick="toastInfo.toast()"variant="accent">
Show Info Toast
</afp-button></div><afp-alertid="toastSuccess"icon="true"closeablevariant="success"><afp-iconslot="icon"name="check-square"></afp-icon><strong>Success:</strong> Your toast notification!
</afp-alert><afp-alertid="toastError"icon="true"closeablevariant="error"><afp-iconslot="icon"name="x-circle"></afp-icon><strong>Error:</strong> Something went wrong!
</afp-alert><afp-alertid="toastInfo"icon="true"closeablevariant="accent"><afp-iconslot="icon"name="info-circle"></afp-icon><strong>Info:</strong> This is an informational toast.
</afp-alert>
<divclass="afp-cluster"><afp-button[onclick]="'toastSuccess.toast()'"[variant]="'success'">
Show Success Toast
</afp-button><afp-button[onclick]="'toastError.toast()'"[variant]="'error'">
Show Error Toast
</afp-button><afp-button[onclick]="'toastInfo.toast()'"[variant]="'accent'">
Show Info Toast
</afp-button></div><afp-alert[id]="'toastSuccess'"[icon]=truecloseable[variant]="'success'"><afp-icon[slot]="'icon'"[name]="'check-square'"></afp-icon><strong>Success:</strong> Your toast notification!
</afp-alert><afp-alert[id]="'toastError'"[icon]=truecloseable[variant]="'error'"><afp-icon[slot]="'icon'"[name]="'x-circle'"></afp-icon><strong>Error:</strong> Something went wrong!
</afp-alert><afp-alert[id]="'toastInfo'"[icon]=truecloseable[variant]="'accent'"><afp-icon[slot]="'icon'"[name]="'info-circle'"></afp-icon><strong>Info:</strong> This is an informational toast.
</afp-alert>
<divclass="afp-cluster"><AfpButtononclick="toastSuccess.toast()"variant="success">
Show Success Toast
</AfpButton><AfpButtononclick="toastError.toast()"variant="error">
Show Error Toast
</AfpButton><AfpButtononclick="toastInfo.toast()"variant="accent">
Show Info Toast
</AfpButton></div><AfpAlertid="toastSuccess"icon="true"closeablevariant="success"><AfpIconslot="icon"name="check-square"></AfpIcon><strong>Success:</strong> Your toast notification!
</AfpAlert><AfpAlertid="toastError"icon="true"closeablevariant="error"><AfpIconslot="icon"name="x-circle"></AfpIcon><strong>Error:</strong> Something went wrong!
</AfpAlert><AfpAlertid="toastInfo"icon="true"closeablevariant="accent"><AfpIconslot="icon"name="info-circle"></AfpIcon><strong>Info:</strong> This is an informational toast.
</AfpAlert>
<divclass="afp-cluster"><AfpButton:onclick="'toastSuccess.toast()'":variant="'success'">
Show Success Toast
</AfpButton><AfpButton:onclick="'toastError.toast()'":variant="'error'">
Show Error Toast
</AfpButton><AfpButton:onclick="'toastInfo.toast()'":variant="'accent'">
Show Info Toast
</AfpButton></div><AfpAlert:id="'toastSuccess'":icon=truecloseable:variant="'success'"><AfpIcon:slot="'icon'":name="'check-square'"></AfpIcon><strong>Success:</strong> Your toast notification!
</AfpAlert><AfpAlert:id="'toastError'":icon=truecloseable:variant="'error'"><AfpIcon:slot="'icon'":name="'x-circle'"></AfpIcon><strong>Error:</strong> Something went wrong!
</AfpAlert><AfpAlert:id="'toastInfo'":icon=truecloseable:variant="'accent'"><AfpIcon:slot="'icon'":name="'info-circle'"></AfpIcon><strong>Info:</strong> This is an informational toast.
</AfpAlert>
By default, toast notifications appear in the bottom-right corner of the screen.
You can create multiple stacks on the same page using the stackId property. Each stack can have its own CSS positioning, allowing different toast positions or styles. If no stackId is provided, the default bottom-right stack is used.
The example below shows how to display a toast in the top-right corner:
Show Top-Right ToastHeads up: This toast is displayed at the top-right corner using a custom stackId.
<afp-buttononclick="toastTopRight.toast()">Show Top-Right Toast</afp-button><afp-alertid="toastTopRight"stackid="topRight"iconcloseablevariant="accent"><afp-iconslot="icon"name="info-circle"></afp-icon><strong>Heads up:</strong> This toast is displayed at the top-right corner using a custom stackId.
</afp-alert><style>/* Move only the stack with ID topRight to top-right */#topRight{top:calc(var(--topbar-height) + var(--afp-space-m));right:var(--afp-space-m);bottom: auto;}</style>
<afp-button[onclick]="'toastTopRight.toast()'">Show Top-Right Toast</afp-button><afp-alert[id]="'toastTopRight'"[stackid]="'topRight'"iconcloseable[variant]="'accent'"><afp-icon[slot]="'icon'"[name]="'info-circle'"></afp-icon><strong>Heads up:</strong> This toast is displayed at the top-right corner using a custom stackId.
</afp-alert><style>/* Move only the stack with ID topRight to top-right */#topRight{top:calc(var(--topbar-height) + var(--afp-space-m));right:var(--afp-space-m);bottom: auto;}</style>
<AfpButtononclick="toastTopRight.toast()">Show Top-Right Toast</AfpButton><AfpAlertid="toastTopRight"stackid="topRight"iconcloseablevariant="accent"><AfpIconslot="icon"name="info-circle"></AfpIcon><strong>Heads up:</strong> This toast is displayed at the top-right corner using a custom stackId.
</AfpAlert><style>/* Move only the stack with ID topRight to top-right */#topRight{top:calc(var(--topbar-height) + var(--afp-space-m));right:var(--afp-space-m);bottom: auto;}</style>
<AfpButton:onclick="'toastTopRight.toast()'">Show Top-Right Toast</AfpButton><AfpAlert:id="'toastTopRight'":stackid="'topRight'"iconcloseable:variant="'accent'"><AfpIcon:slot="'icon'":name="'info-circle'"></AfpIcon><strong>Heads up:</strong> This toast is displayed at the top-right corner using a custom stackId.
</AfpAlert><style>/* Move only the stack with ID topRight to top-right */#topRight{top:calc(var(--topbar-height) + var(--afp-space-m));right:var(--afp-space-m);bottom: auto;}</style>