Toasts provide brief feedback about an operation through a message on the screen.
There are following components included:
Toast
Name | Type | Default | Description |
---|---|---|---|
colors | object | Object with Tailwind CSS colors classes | |
colors.bgIos | string | 'bg-ios-light-glass dark:bg-ios-dark-glass' | |
colors.bgMaterial | string | 'bg-md-light-surface-5 dark:bg-md-dark-surface-5' | |
colors.textIos | string | '' | |
colors.textMaterial | string | 'text-md-light-primary dark:text-md-dark-primary' | |
opened | boolean | false | Allows to open/close Toast and set its initial state |
position | 'left' | 'right' | 'center' | 'left' | Toast position (only on wide screens). Can be |
Name | Description |
---|---|
button | Toast button content |
<script>import {Page,Navbar,NavbarBackLink,Button,Toast,Block,} from 'konsta/svelte';let toastLeftOpened = $state(false);let toastCenterOpened = $state(false);let toastRightOpened = $state(false);const openToast = (setter) => {// close other toasttoastLeftOpened = false;toastCenterOpened = false;toastRightOpened = false;setter();};</script><Page><Navbar title="Toast">{#snippet left()}{#if !isPreview}<NavbarBackLink onclick={() => history.back()} />{/if}{/snippet}</Navbar><Block strong inset class="flex flex-col gap-4"><Toast position="left" opened={toastLeftOpened}>{#snippet button()}<ButtonclearinlinesmallroundedonClick={() => (toastLeftOpened = false)}>Close</Button>{/snippet}<div class="shrink">Hello this is left toast!</div></Toast><Toast position="center" opened={toastCenterOpened}>{#snippet button()}<ButtonclearinlinesmallroundedonClick={() => (toastCenterOpened = false)}>Close</Button>{/snippet}<div class="shrink">Hello this is center toast!</div></Toast><Toast position="right" opened={toastRightOpened}>{#snippet button()}<ButtonclearinlinesmallroundedonClick={() => (toastRightOpened = false)}>Close</Button>{/snippet}<div class="shrink">Hello this is right toast!</div></Toast><p>Toasts provide brief feedback about an operation through a message on thescreen.</p><p><Button rounded onclick={() => openToast(() => (toastLeftOpened = true))}>Toast on Left</Button></p><p><Buttonroundedonclick={() => openToast(() => (toastCenterOpened = true))}>Toast on Center</Button></p><p><Buttonroundedonclick={() => openToast(() => (toastRightOpened = true))}>Toast on Right</Button></p></Block></Page>