Skip to content

Latest commit

 

History

History
293 lines (196 loc) · 6.83 KB

dialogs.md

File metadata and controls

293 lines (196 loc) · 6.83 KB
title description contributors
Dialogs
UI for grabbing the users attention, prompting for confirmation, choice, input, or credentials.
Ombuweb
rigor789

NativeScript offers various dialogs, available via the Dialogs import from @nativescript/core, or globally.

import { Dialogs } from '@nativescript/core'

Dialogs.alert(options)
Dialogs.action(options)
Dialogs.confirm(options)
Dialogs.prompt(options)
Dialogs.login(options)

// is the same as:
alert(options)
action(options)
confirm(options)
prompt(options)
login(options)

All dialogs take a DialogOptions object with the properties:

  • title: Sets the dialog title.
  • message : Sets the dialog message.
  • cancelable (Android only): Sets if the dialog can be canceled by taping outside of the dialog.
  • theme (Android only): Sets the theme of the Dialog. Usable themes can be found in R.style

See DialogOptions, R.style.

Avialable Dialogs

Alert {#alert}

<<< @/../examples/typescript/src/ui/Dialogs/template.ts#example-alert

::: code-group <<< @/../examples/angular/src/ui/Dialogs/component.html#example-alert [HTML] <<< @/../examples/angular/src/ui/Dialogs/component.ts#example-alert [TypeScript] :::

<<< @/../examples/react/src/components/ui/dialogs.tsx#example-alert

<<< @/../examples/solid/src/ui/dialogs.tsx#example-alert

<<< @/../examples/svelte/app/components/ui/Dialogs.svelte#example-alert

<<< @/../examples/vue/src/ui/Dialogs/component.vue#example-alert

A dialog for alerting the user.

See alert().

Action {#action}

<<< @/../examples/typescript/src/ui/Dialogs/template.ts#example-action

::: code-group <<< @/../examples/angular/src/ui/Dialogs/component.html#example-action [HTML] <<< @/../examples/angular/src/ui/Dialogs/component.ts#example-action [TypeScript] :::

<<< @/../examples/react/src/components/ui/dialogs.tsx#example-action

<<< @/../examples/solid/src/ui/dialogs.tsx#example-action

<<< @/../examples/svelte/app/components/ui/Dialogs.svelte#example-action

<<< @/../examples/vue/src/ui/Dialogs/component.vue#example-action

A dialog for prompting the user to choose.

Note: destructiveActionsIndexes allows setting some actions as destructive - shown in red. iOS only.

See action().

Confirm {#confirm}

<<< @/../examples/typescript/src/ui/Dialogs/template.ts#example-confirm

::: code-group <<< @/../examples/angular/src/ui/Dialogs/component.html#example-confirm [HTML] <<< @/../examples/angular/src/ui/Dialogs/component.ts#example-confirm [TypeScript] :::

<<< @/../examples/react/src/components/ui/dialogs.tsx#example-confirm

<<< @/../examples/solid/src/ui/dialogs.tsx#example-confirm

<<< @/../examples/svelte/app/components/ui/Dialogs.svelte#example-confirm

<<< @/../examples/vue/src/ui/Dialogs/component.vue#example-confirm

A dialog for prompting the user to confirm.

See confirm().

Prompt {#prompt}

<<< @/../examples/typescript/src/ui/Dialogs/template.ts#example-prompt

::: code-group <<< @/../examples/angular/src/ui/Dialogs/component.html#example-prompt [HTML] <<< @/../examples/angular/src/ui/Dialogs/component.ts#example-prompt [TypeScript] :::

<<< @/../examples/react/src/components/ui/dialogs.tsx#example-prompt

<<< @/../examples/solid/src/ui/dialogs.tsx#example-prompt

<<< @/../examples/svelte/app/components/ui/Dialogs.svelte#example-prompt

<<< @/../examples/vue/src/ui/Dialogs/component.vue#example-prompt

A dialog for prompting the user for input.

  • defaultText: Sets the default text to display in the input box.
  • inputType: Sets the prompt input type: email, decimal, phone, number, text, password, or email
  • capitalizationType: Sets the prompt capitalization type. Avalable options: none, allCharacters, sentences, or words.

See prompt(), CoreTypes.AutocapitalizationType

Login {#login}

<<< @/../examples/typescript/src/ui/Dialogs/template.ts#example-login

::: code-group <<< @/../examples/angular/src/ui/Dialogs/component.html#example-login [HTML] <<< @/../examples/angular/src/ui/Dialogs/component.ts#example-login [TypeScript] :::

<<< @/../examples/react/src/components/ui/dialogs.tsx#example-login

<<< @/../examples/solid/src/ui/dialogs.tsx#example-login

<<< @/../examples/svelte/app/components/ui/Dialogs.svelte#example-login

<<< @/../examples/vue/src/ui/Dialogs/component.vue#example-login

A dialog for prompting the user for credentials.

See login().

Native Component