Prebuilt Layer Layer III

Notification Area

A generic fixed viewport container managing lifecycle timers, screen edge positioning, and animations, rendering custom user snippets for each notification item.

01

Props

PropTypeDefaultDescription
idstringrequired

The unique identifier for the notification area element.

itemsT[][]

Bindable generic array of items extending { id: string | number; duration?: number }.

position'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right''top-right'

The fixed screen edge zone where notifications are positioned.

variantstring''

User-defined variant name, added to the root element. Style it with a CSS rule that starts from the root.

itemSnippetSnippet<[item: T, dismiss: () => void]>required

Generic snippet function receiving (item: T, dismiss: () => void).

02

Samples

Notification Area

A generic fixed viewport container supporting 8 controllable screen edge zones, automatic timer management, and generic type-inferred item snippets.

1. Interactive Screen Edge & Generic Snippet Demo

Choose screen edge position and trigger custom notifications.

Screen Edge Position

Spawn Notifications

<script lang="ts">
  import { NotificationArea } from 'fluid-ui-svelte/prebuilt';
  import { Button, Text } from 'fluid-ui-svelte/base';
 
  type ToastItem = {
    id: number;
    message: string;
    type: 'info' | 'success' | 'warning' | 'error';
    duration?: number;
  };
 
  let notifications = $state<ToastItem[]>([]);
 
  function add() {
    notifications = [...notifications, {
      id: Date.now(),
      message: 'New generic notification!',
      type: 'success',
      duration: 4000
    }];
  }
</script>
 
<Button onclick={async () => add()}>Notify</Button>
 
<NotificationArea
  id="my-notifications"
  position="bottom-right"
  bind:items={notifications}
>
  {#snippet itemSnippet(item, dismiss)}
    <div class="fluid-notification fluid-notification-{item.type}">
      <Text>{item.message}</Text>
      <Button onclick={async () => dismiss()} class="fluid-notification-close p-0!">&times;</Button>
    </div>
  {/snippet}
</NotificationArea>