Toast

The Toast component displays brief notification messages that appear temporarily and then disappear.

Import

<script>
  import { Toast } from 'svelte-fluentui';
</script>
svelte

Basic Usage

<Toast show={showToast} on:dismiss={() => showToast = false}>
  Operation completed successfully!
</Toast>
svelte

Different Variants

<Toast variant="success" show={showSuccess}>
  Success message
</Toast>

<Toast variant="warning" show={showWarning}>
  Warning message
</Toast>

<Toast variant="error" show={showError}>
  Error message
</Toast>
svelte

With Action Button

<Toast show={showToast}>
  Message sent successfully
  <Button slot="action" size="small">Undo</Button>
</Toast>
svelte

Auto Dismiss

<Toast show={showToast} duration={5000} autoDismiss>
  This will disappear after 5 seconds
</Toast>
svelte

Properties

PropertyTypeDefaultDescription
showbooleanfalseWhether the toast is visible
variant'default' | 'success' | 'warning' | 'error''default'Toast type
durationnumber4000Display duration in milliseconds
autoDismissbooleanfalseAuto dismiss after duration
position'top' | 'bottom''bottom'Toast position

Slots

SlotDescription
defaultToast message content
actionAction button

Events

EventDescription
on:dismissFired when toast is dismissed