Dialog is a type of modal window that appears in front of app content to provide critical information, or prompt for a decision to be made.
There are following components included:
Dialog
- dialog elementDialogButton
- dialog button elementName | Type | Default | Description |
---|---|---|---|
backdrop | boolean | true | Enables Popup backdrop (dark semi transparent layer behind) |
buttons | string | Dialog buttons content | |
colors | object | Object with Tailwind CSS colors classes | |
colors.bgIos | string | 'bg-ios-light-glass dark:bg-ios-dark-glass' | Dialog bg color in iOS theme |
colors.bgMaterial | string | 'bg-md-light-surface-3 dark:bg-md-dark-surface-3' | Dialog bg color in iOS theme |
colors.contentTextIos | string | '' | Content text color in iOS theme |
colors.contentTextMaterial | string | 'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant' | Content text color in Material theme |
colors.titleIos | string | '' | Title text color in iOS theme |
colors.titleMaterial | string | 'text-md-light-on-surface dark:text-md-dark-on-surface' | Title text color in Material theme |
content | string | Dialog main content | |
onBackdropClick | function(e) | Click handler on backdrop element | |
opened | boolean | false | Allows to open/close Popup and set its initial state |
title | string | Dialog title content | |
titleFontSizeIos | string | 'text-[17px]' | Tailwind CSS classes for title font size iOS theme |
titleFontSizeMaterial | string | 'text-[24px]' | Tailwind CSS classes for title font size Material theme |
Name | Type | Default | Description |
---|---|---|---|
disabled | boolean | false | Makes button disabled |
onClick | function(e) | DialogButton click handler | |
strong | boolean | false | Makes button bold in iOS theme and fill in Material theme, overwrites |
strongIos | boolean | false | Makes button bold in iOS theme |
strongMaterial | boolean | false | Makes button fill in Material theme |
Name | Description |
---|---|
buttons | Dialog buttons content |
content | Dialog main content |
title | Dialog title content |
<script>import {Page,Navbar,NavbarBackLink,Block,Button,Dialog,DialogButton,List,ListItem,Radio,} from 'konsta/svelte';let basicOpened = $state(false);let alertOpened = $state(false);let confirmOpened = $state(false);let listOpened = $state(false);let radioValue = $state('batman');</script><Page><Navbar title="Dialog">{#snippet left()}{#if !isPreview}<NavbarBackLink onclick={() => history.back()} />{/if}{/snippet}</Navbar><Block strong inset class="space-y-4"><p>Dialog is a type of modal window that appears in front of app content toprovide critical information, or prompt for a decision to be made.</p></Block><Block strong inset><p class="grid grid-cols-2 md:grid-cols-4 gap-4"><Button rounded onclick={() => (basicOpened = true)}>Basic</Button><Button rounded onclick={() => (alertOpened = true)}>Alert</Button><Button rounded onclick={() => (confirmOpened = true)}>Confirm</Button><Button rounded onclick={() => (listOpened = true)}>List</Button></p></Block><Dialog opened={basicOpened} onBackdropClick={() => (basicOpened = false)}>{#snippet title()}Dialog Title{/snippet}Dialog is a type of modal window that appears in front of app content to providecritical information, or prompt for a decision to be made.{#snippet buttons()}<DialogButton onclick={() => (basicOpened = false)}>Action 2</DialogButton><DialogButton strong onclick={() => (basicOpened = false)}>Action 1</DialogButton>{/snippet}</Dialog><Dialog opened={alertOpened} onBackdropClick={() => (alertOpened = false)}>{#snippet title()}Konsta UI{/snippet}Hello world!{#snippet buttons()}<DialogButton strong onclick={() => (alertOpened = false)}>Ok</DialogButton>{/snippet}</Dialog><Dialogopened={confirmOpened}onBackdropClick={() => (confirmOpened = false)}>{#snippet title()}Konsta UI{/snippet}All good today?{#snippet buttons()}<DialogButton onclick={() => (confirmOpened = false)}>No</DialogButton><DialogButton strong onclick={() => (confirmOpened = false)}>Yes</DialogButton>{/snippet}</Dialog><Dialog opened={listOpened} onBackdropClick={() => (listOpened = false)}>{#snippet title()}Your super hero{/snippet}<List nested class="-mx-4"><ListItem label title="Batman">{#snippet after()}<Radiocomponent="div"value="batman"checked={radioValue === 'batman'}onChange={() => (radioValue = 'batman')}/>{/snippet}</ListItem><ListItem label title="Spider-man">{#snippet after()}<Radiocomponent="div"value="spiderman"checked={radioValue === 'spiderman'}onChange={() => (radioValue = 'spiderman')}/>{/snippet}</ListItem><ListItem label title="Hulk">{#snippet after()}<Radiocomponent="div"value="hulk"checked={radioValue === 'hulk'}onChange={() => (radioValue = 'hulk')}/>{/snippet}</ListItem></List>{#snippet buttons()}<DialogButton strong onclick={() => (listOpened = false)}>Confirm</DialogButton>{/snippet}</Dialog></Page>