Dark Light
System
Default LBBW Jira Confluence Source Code
Share
Playground

Alert

<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.

Examples #

Variants #

Use the variant attribute to set the alert's semantic variant.

Neutral information alert Brand information alert Accent information alert Info information alert Error information alert Success information alert Warning information alert

Appearance #

Use the appearance attribute to set the alert's appearance style.

Default info alert Filled info alert Outline info alert Outlined filled info alert Plain info alert

Shape #

Use the shape attribute to set the alert's shape style.

Pill info alert Rounded info alert Soft info alert Square info alert

Icon #

The icon property enables the leading icon slot.

This is super informative
You can tell by how pretty the alert is.

Closing Alert #

Alerts can be manually closed using closeable.

Warning: This alert can be closed manually.

Duration #

Use the duration attribute to automatically hide the alert after a given time (in milliseconds).

Show Timed Alert

Toast Notification #

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.

Customizing Toast Position #

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 Toast Heads up: This toast is displayed at the top-right corner using a custom stackId.

Properties

Learn more about properties.

Name Description Reflects
open
Whether the alert is visible
Type boolean
Default false
variant
Variant of the alert
Type
AfpVariant
Name Description
NEUTRAL
The main call-to-action.
BRAND
Less prominent than primary.
ACCENT
Secondary highlight for emphasis.
ERROR
Used for destructive or critical actions.
INFO
Conveys general information.
SUCCESS
Indicates a successful or positive action.
WARNING
Communicates cautionary actions.
AfpVariant
Default AfpVariant.NEUTRAL
appearance
appearance of alert
Type
AfpAppearance
Name Description
DEFAULT
Highlighted, primary action (default).
OUTLINED
Transparent background with a visible border.
PLAIN
Minimal, no border or background.
FILLED
Solid background, no border.
OUTLINED_FILLED
Solid background with a visible border.
AfpAppearance
Default AfpAppearance.OUTLINED_FILLED
shape
shape of alert
Type
AfpShape
Name Description
PILL
Makes the component circular.
ROUNDED
Makes the component rounded.
SOFT
Makes the component have soft edges.
SQUARE
Makes the component square.
AfpShape
Default AfpShape.PILL
closeable
Whether the alert can be closed by the user
Type boolean
Default false
icon
Whether to show an icon
Type boolean
Default false
duration
Duration (in ms) before auto-hide
Type number
speed
Animation speed (in ms)
Type number
Default 150
stackId
stackid
Optional: ID für den Toast-Stack
Type string | undefined

Methods

Learn more about using methods.

Name Description Arguments
show
Show the alert
-
hide
Hide the alert
-
toast
Displays the alert as a toast notification.
-

Events

Learn more about events.

Name Return Description
afp-show void
Emitted when the alert is shown.
afp-after-show void
Emitted after the alert has been shown.
afp-hide void
Emitted when the alert is hidden.
afp-after-hide void
Emitted after the alert has been hidden.
afp-close void
Emitted when the Alert gets closed.

Slots

Learn more about slots.

Name Description
default
The default slot.
icon
Custom leading icon.
close-icon
Custom close icon.

Internationalization

Learn more about internationalization.

Key Description
alert-close.aria-label
The aria-label of the close icon.

CSS Parts

Learn more about CSS Parts.

Name Description Selector
base
The component's base wrapper.
::part(base)
content
The main content area.
::part(content)
icon
The leading icon container.
::part(icon)
close-icon
The close icon container.
::part(close-icon)

Dependencies

The component automatically brings in the listed items, including any nested dependencies that may exist.

afp-icon

Importing

Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.

import '@afp-design-system/core/dist/components/alert/alert.js';
Share
Create a link with a predefined theme that is automatically applied when the generated link is opened. Default LBBW Presentation Mode
Abort Copy Link