confirmationDialog
Show a set of actions to choose from.
confirmationDialog(options) shows a system action list that slides up from the bottom on iPhone. Tapping a button runs its action first, then calls onDismiss.
import { Button, Modifier, useState } from "onescript/views"
function ShareButton() {
const [shown, setShown] = useState(false)
return (
<Button
action={() => setShown(true)}
modifier={Modifier.confirmationDialog({
title: "Share via",
titleVisibility: "visible",
isPresented: shown,
onDismiss: () => setShown(false),
actions: [
<Button action={() => share("messages")}>Messages</Button>,
<Button action={() => share("mail")}>Mail</Button>,
<Button
role="cancel"
action={() => {}}
>
Cancel
</Button>,
],
})}
>
Share
</Button>
)
}| Option | Type | Description |
|---|---|---|
title | string | The title. |
titleVisibility | "automatic" | "visible" | "hidden" | Optional. Whether the title is shown. Defaults to "automatic". |
message | string | Optional. Text below the title. |
isPresented | boolean | Whether the dialog is shown. |
onDismiss | () => void | Called when the dialog closes; set isPresented to false here. |
actions | ViewChild | The action buttons. |
actions only accepts Button with a plain text label, and the buttons can't have a modifier.
How is this guide?
Last updated on