<Dialoglet:toggletriggerLabel="Delete Entry"><h2>Are you sure you want to delete the entry?</h2><p>This action can not be reversed.</p><svelte:fragmentslot="dialog-actions"><buttonon:click={toggle}>No</button><buttonon:click="{() => {
deleteEntry();
toggle();
}}">
Yes
</button></svelte:fragment></Dialog>
Styled Dialog
<DialogtriggerProps={{class:'btn'}}triggerLabel="Dialog as Side Pane"dialogIn={fly}dialogInOptions={{x:500}}--as-dialog-left="auto"--as-dialog-right="0"--as-dialog-transform="translateY(-50%)"--as-dialog-border-radius="0"--as-dialog-width="calc(100% - 2em)"--as-dialog-max-width="800px"--as-dialog-height="100%"--as-dialog-max-height="calc(100% - 2em)"><h1>This is a side pane</h1><p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus rem non sunt! Id
necessitatibus veritatis debitis est tempora iure esse. Nisi, dicta alias nobis velit libero
deleniti corporis nihil? Eum.
</p></Dialog>
When creating a confirm dialog, you need to toggle the opening state at different places. For this, a toggle() function is provided via slot props. Simply add let:toggle to the <Dialog> tag and call it when appropriate.
<Dialoglet:toggletriggerLabel="Delete Entry"><h2>Are you sure you want to delete the entry?</h2><p>This action can not be reversed.</p><svelte:fragmentslot="dialogActions"><buttonon:click={toggle}>No</button><buttonon:click={()=>{deleteEntry();toggle();}}>
Yes
</button></svelte:fragment></Dialog>
Above you can see the usage for slot="dialogActions". This can be used to display options / buttons of a dialog dialog in a row.
mandatory
By default the dialog is dismissable (not mandatory) and will close on ESC, by clicking outside or by clicking the x-mark button. If you pass in the mandatory prop the dialog is non-dismissable and won’t close unless you call let:toggle or change the value of bind:open.
To show the notifications, import and place the <Notifications /> component
inside your src/routes/__layout.svelte for SvelteKit
or src/pages/_layout.svelte for Routify, like this:
This is used to display the notifications, so it needs to be rendered wherever you want your notifications
visible.
{...$$restProps} get spread to the underlying <ul> element that shows the notifications.
Notification position
By default, the notifications will be displayed on the top right, i.e. "top-right". You can also place it to either "top-left""top", "bottom-left", "bottom", or "bottom-right" by setting the position prop on the <Notifications /> component.
<Notificationsposition="top-right"/>
notification(msg, {type, removeAfter, action})
To create or add a notification import the notification function from
'as-comps' and call it with a message or any HTML.
The second parameter is a notificationOption object where the the properties type, removeAfter or action can be set:
type controls the type of notification: ‘info’ (default) or ‘warn’
removeAfter controls how long a notification stays on screen in ms, defaulting to 5000
action can be used to attach an action to the component. Pass in an array consisting of two entries: at index 0 a label for the notification action button and at index 1 a callback function that gets called when the action button is pressed. Setting an Action increases the default removeAfter time by two.
import{ notification }from'as-comps';notification('hello notification');notification('<b>yaay!</b> you did it!');notification('a warning notification',{type:'warn'});notification('This notification will display for about 11,574 days.',{removeAfter:9001});notification('You did something undoable.',{action:['undo', undoCallback]});