Dialog Svelte Component

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.

Contents

Dialog Components

There are following components included:

  • Dialog - dialog element
  • DialogButton - dialog button element

Dialog Props

NameTypeDefaultDescription
backdropbooleantrue

Enables Popup backdrop (dark semi transparent layer behind)

buttonsstring

Dialog buttons content

colorsobject

Object with Tailwind CSS colors classes

colors.bgIosstring'bg-ios-light-glass dark:bg-ios-dark-glass'

Dialog bg color in iOS theme

colors.bgMaterialstring'bg-md-light-surface-3 dark:bg-md-dark-surface-3'

Dialog bg color in iOS theme

colors.contentTextIosstring''

Content text color in iOS theme

colors.contentTextMaterialstring'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant'

Content text color in Material theme

colors.titleIosstring''

Title text color in iOS theme

colors.titleMaterialstring'text-md-light-on-surface dark:text-md-dark-on-surface'

Title text color in Material theme

contentstring

Dialog main content

onBackdropClickfunction(e)

Click handler on backdrop element

openedbooleanfalse

Allows to open/close Popup and set its initial state

titlestring

Dialog title content

titleFontSizeIosstring'text-[17px]'

Tailwind CSS classes for title font size iOS theme

titleFontSizeMaterialstring'text-[24px]'

Tailwind CSS classes for title font size Material theme

DialogButton Props

NameTypeDefaultDescription
disabledbooleanfalse

Makes button disabled

onClickfunction(e)

DialogButton click handler

strongbooleanfalse

Makes button bold in iOS theme and fill in Material theme, overwrites

strongIosbooleanfalse

Makes button bold in iOS theme

strongMaterialbooleanfalse

Makes button fill in Material theme

Dialog Snippets

NameDescription
buttons

Dialog buttons content

content

Dialog main content

title

Dialog title content

Examples

Dialog.svelte
<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 to
provide 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 provide
critical 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>
<Dialog
opened={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()}
<Radio
component="div"
value="batman"
checked={radioValue === 'batman'}
onChange={() => (radioValue = 'batman')}
/>
{/snippet}
</ListItem>
<ListItem label title="Spider-man">
{#snippet after()}
<Radio
component="div"
value="spiderman"
checked={radioValue === 'spiderman'}
onChange={() => (radioValue = 'spiderman')}
/>
{/snippet}
</ListItem>
<ListItem label title="Hulk">
{#snippet after()}
<Radio
component="div"
value="hulk"
checked={radioValue === 'hulk'}
onChange={() => (radioValue = 'hulk')}
/>
{/snippet}
</ListItem>
</List>
{#snippet buttons()}
<DialogButton strong onclick={() => (listOpened = false)}
>Confirm</DialogButton
>
{/snippet}
</Dialog>
</Page>
Code licensed under MIT.
2025 © Konsta UI by nolimits4web.