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-white dark:bg-neutral-800' | 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 | |
opened | boolean | false | Allows to open/close Popup and set its initial state |
sizeIos | string | 'w-[16.875rem]' | Tailwind CSS size classes for iOS theme |
sizeMaterial | string | 'w-[19.5rem]' | Tailwind CSS size classes for Material theme |
title | string | Dialog title content | |
titleFontSizeIos | string | 'text-[18px]' | Tailwind CSS classes for title font size iOS theme |
titleFontSizeMaterial | string | 'text-[24px]' | Tailwind CSS classes for title font size Material theme |
translucent | boolean | true | Makes Dialog background translucent (with |
onBackdropClick | function(e) | Click handler on backdrop element |
Name | Type | Default | Description |
---|---|---|---|
colors | object | Object with Tailwind CSS colors classes | |
colors.activeBgIos | string | 'active:bg-black active:bg-opacity-10 dark:active:bg-white dark:active:bg-opacity-10' | Active/pressed state bg color in iOS theme |
colors.disabledTextIos | string | 'text-black text-opacity-30 dark:text-white dark:text-opacity-30' | Disabled button text color in iOS theme |
colors.textIos | string | ''text-primary | Text color in iOS theme |
disabled | boolean | false | Makes button disabled |
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 |
onClick | function(e) | DialogButton click handler |
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 = false;let alertOpened = false;let confirmOpened = false;let listOpened = false;let radioValue = 'batman';</script><Page><Navbar title="Dialog" /><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)}><svelte:fragment slot="title">Dialog Title</svelte:fragment>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.<svelte:fragment slot="buttons"><DialogButton onClick={() => (basicOpened = false)}>Action 2</DialogButton><DialogButton onClick={() => (basicOpened = false)}>Action 1</DialogButton></svelte:fragment></Dialog><Dialog opened={alertOpened} onBackdropClick={() => (alertOpened = false)}><svelte:fragment slot="title">Konsta UI</svelte:fragment>Hello world!<svelte:fragment slot="buttons"><DialogButton onClick={() => (alertOpened = false)}>Ok</DialogButton></svelte:fragment></Dialog><Dialogopened={confirmOpened}onBackdropClick={() => (confirmOpened = false)}><svelte:fragment slot="title">Konsta UI</svelte:fragment>All good today?<svelte:fragment slot="buttons"><DialogButton onClick={() => (confirmOpened = false)}>No</DialogButton><DialogButton strong onClick={() => (confirmOpened = false)}>Yes</DialogButton></svelte:fragment></Dialog><Dialog opened={listOpened} onBackdropClick={() => (listOpened = false)}><svelte:fragment slot="title">Your super hero</svelte:fragment><List nested class="-mx-4"><ListItem label title="Batman"><svelte:fragment slot="after"><Radiocomponent="div"value="batman"checked={radioValue === 'batman'}onChange={() => (radioValue = 'batman')}/></svelte:fragment></ListItem><ListItem label title="Spider-man"><svelte:fragment slot="after"><Radiocomponent="div"value="spiderman"checked={radioValue === 'spiderman'}onChange={() => (radioValue = 'spiderman')}/></svelte:fragment></ListItem><ListItem label title="Hulk"><svelte:fragment slot="after"><Radiocomponent="div"value="hulk"checked={radioValue === 'hulk'}onChange={() => (radioValue = 'hulk')}/></svelte:fragment></ListItem></List><svelte:fragment slot="buttons"><DialogButton onClick={() => (listOpened = false)}>Confirm</DialogButton></svelte:fragment></Dialog></Page>