Skip to content

Confirm

The nuke will be launched after 10s. Are you sure?

Example

Basic

Show Code
vue
<script lang="ts" setup>
import { RButton, RToast } from 'roughness'
import { ref } from 'vue'

let open = ref(false)

function show() {
  open.value = true
}
</script>

<template>
  <RButton @click="show">Show</RButton>
  <RConfirm v-model:open="open">Are you sure you want to cancel?</RConfirm>
</template>
Are you sure you want to cancel?

Composition

Show Code
vue
<script lang="ts" setup>
import { RConfirmProvider } from 'roughness'
</script>

<template>
  <RConfirmProvider>
    <App />
  </RConfirmProvider>
</template>
vue
<script lang="ts" setup>
import { useConfirm, useToast } from 'roughness'

const confirm = useConfirm()
const toast = useToast()

async function ask() {
  const result = await confirm({
    title: () => 'Hey Guys',
    default: () => 'Let\'s go for a walk outside!',
  })
  toast(result ? 'Hooray!' : 'OK...', {
    type: result ? 'success' : 'comment',
  })
}
</script>

<template>
  <RButton @click="ask">Ask</RButton>
</template>

Usage

Props

NameTypeDefault ValueDescription
...

See Dialog Props.

Events

NameTypeDescription
cancel
confirm
...

See Dialog Events.

Slots

NameTypeDescription
title
default

ConfirmProvider Slots

NameTypeDescription
default

Compositions

ts
import type { ComponentProps, ComponentRenderable } from 'roughness'

export declare function useConfirm(): (
  renderable: ComponentRenderable<typeof RConfirm>,
  props?: ComponentProps<typeof RConfirm>,
) => Promise<boolean>

Released under the ISC License.