Action Sheet Svelte Component

Action Sheet is a slide-up pane for presenting the user with a set of alternatives for how to proceed with a given task.

You can also use action sheets to prompt the user to confirm a potentially dangerous action.

The action sheet contains an optional title and one or more buttons, each of which corresponds to an action to take.

Action Sheet Components

There are following components included:

  • Actions
  • ActionsButton
  • ActionsLabel
  • ActionsGroup

Actions Props

NameTypeDefaultDescription
backdropbooleantrue

Enables Action Sheet backdrop (dark semi transparent layer behind)

openedbooleanfalse

Allows to open/close Action Sheet and set its initial state

onBackdropClickfunction(e)

Click handler on backdrop element

ActionsButton Props

NameTypeDefaultDescription
boldbooleanundefined

Makes button text bold. Overwrites boldIos and boldMaterial

boldIosbooleanfalse

Makes button text bold in iOS theme

boldMaterialbooleanfalse

Makes button text bold in Material theme

colorsobject

Object with Tailwind CSS colors classes

colors.activeBgIosstring'active:bg-neutral-200 dark:active:bg-neutral-700'
colors.activeBgMaterialstring''
colors.bgIosstring'bg-white dark:bg-neutral-800'
colors.bgMaterialstring'bg-md-light-surface-3 dark:bg-md-dark-surface-3'
colors.textIosstring'text-primary'
colors.textMaterialstring'text-md-light-on-surface dark:text-md-dark-on-surface'
dividersbooleanundefined

Renders button outer hairlines (borders). If not specified, will be enabled for iOS theme

fontSizeIosstring'text-xl'

Button text font size in iOS theme

fontSizeMaterialstring'text-base'

Button text font size in Material theme

hrefstring

Link's href attribute, when specified will also be rendered as <a> element

touchRipplebooleantrue

Enables touch ripple effect in Material theme

onClickfunction(e)

click event handler

ActionsLabel Props

NameTypeDefaultDescription
colorsobject

Object with Tailwind CSS colors classes

colors.bgIosstring'bg-white dark:bg-neutral-800'
colors.bgMaterialstring'bg-md-light-surface-3 dark:bg-md-dark-surface-3'
colors.textIosstring'text-black text-opacity-55 dark:text-white dark:text-opacity-55'
colors.textMaterialstring'text-md-light-primary dark:text-md-dark-primary'
dividersbooleanundefined

Renders button outer hairlines (borders). If not specified, will be enabled in iOS theme

fontSizeIosstring'text-sm'

Button text font size in iOS theme

fontSizeMaterialstring'text-sm'

Button text font size in Material theme

ActionsGroup Props

NameTypeDefaultDescription
dividersbooleantrue

Renders group outer hairlines (borders). (in Material theme only)

Examples

ActionSheet.svelte
<script>
import {
Page,
Navbar,
NavbarBackLink,
BlockTitle,
Block,
Button,
Actions,
ActionsButton,
ActionsLabel,
ActionsGroup,
} from 'konsta/svelte';
let actionsOneOpened = false;
let actionsTwoOpened = false;
</script>
<Page>
<Navbar title="Action Sheet" />
<Block strong inset class="space-y-4">
<p>
Action Sheet is a slide-up pane for presenting the user with a set of
alternatives for how to proceed with a given task.
</p>
</Block>
<BlockTitle>Open Action Sheet</BlockTitle>
<Block strong inset class="flex space-x-4">
<Button onClick={() => (actionsOneOpened = true)}>One group</Button>
<Button onClick={() => (actionsTwoOpened = true)}>Two groups</Button>
</Block>
<Actions
opened={actionsOneOpened}
onBackdropClick={() => (actionsOneOpened = false)}
>
<ActionsGroup>
<ActionsLabel>Do something</ActionsLabel>
<ActionsButton onClick={() => (actionsOneOpened = false)} bold>
Button 1
</ActionsButton>
<ActionsButton onClick={() => (actionsOneOpened = false)}>
Button 2
</ActionsButton>
<ActionsButton onClick={() => (actionsOneOpened = false)}>
Cancel
</ActionsButton>
</ActionsGroup>
</Actions>
<Actions
opened={actionsTwoOpened}
onBackdropClick={() => (actionsTwoOpened = false)}
>
<ActionsGroup>
<ActionsLabel>Do something</ActionsLabel>
<ActionsButton onClick={() => (actionsTwoOpened = false)} bold>
Button 1
</ActionsButton>
<ActionsButton onClick={() => (actionsTwoOpened = false)}>
Button 2
</ActionsButton>
</ActionsGroup>
<ActionsGroup>
<ActionsButton onClick={() => (actionsTwoOpened = false)}>
Cancel
</ActionsButton>
</ActionsGroup>
</Actions>
</Page>
Code licensed under MIT.
2022 © Konsta UI by nolimits4web.