Alert component displays card-style popup notifications, suitable for scenarios requiring richer content presentation, such as operation feedback and system notifications.
In STDF, Toast, Alert, Modal, and Dialog all provide user feedback, but they emphasize different interaction levels.
Set different alert types via type property:
'success': Success alert with green icon'error': Error alert with red icon'warning': Warning alert with orange icon'info': Info alert with blue iconnull: No type, no default icon displayedBy default slides in from the top. Set position to 'bottom' to slide in from the bottom. Adjust distance from top/bottom via py property.
Automatically closes after 3 seconds by default. Adjust display duration via duration property. Set to 0 to disable auto close and require manual closing.
Set transition animation via transitionType property, supports all svelte/transition functions applicable to regular DOM elements:
'fly': Fly-in animation (default), slides in from top/bottom'scale': Scale animation'fade': Fade-in animation'slide': Slide animation'blur': Blur animationnull: No animationSet animation parameters via transitionParams property, where duration represents the enter animation duration (default 300ms).
For supported parameters in transitionParams, please refer to svelte/transition.
For example, you can customize the Y value for fly animation:
<Alert transitionType="fly" transitionParams={{ y: 200, delay: 100 }} />
For better user experience, the alert appears with a short animation (default 300ms) to catch user attention. You can set the exit animation duration via outDuration property (default 300ms).
Exit animation only allows setting the duration. Other parameters will inherit from the enter animation to ensure the animation effect "goes back to where it came from".
Set the easing function for enter animation via easeType property, and easeOutType for exit animation. Supports all svelte/easing easing functions:
'linear': Linear'cubicOut': Cubic ease-out (default)'bounceOut': Bounce ease-out'elasticOut': Elastic ease-out'backOut': Back ease-outFor example, using elastic easing effect:
<Alert easeType="elasticOut" easeOutType="elasticOut" />
Pass Card component configuration via card property to customize shadow, radius, border, and other styles.
Use children Snippet to fully customize alert content for more complex interactions.
Click-through is enabled by default (clickable is true), meaning content below can be clicked while the alert is displayed. Set to false to prevent click-through.
Inject CSS class names to the component's outer container via injClass parameter.
If the injected class doesn't take effect, add "!" before the class name. Refer to Tailwind Important modifier.