Popconfirm
A lightweight confirmation popover that appears when clicking a trigger element. It's more lightweight than a Dialog for simple confirm/cancel actions.
Preview
Installation
pnpm dlx brutx-vue@latest add popconfirmUsage
<script setup>
import { Popconfirm, Button } from 'brutx-ui-vue'
function handleConfirm() {
console.log('Confirmed!')
}
function handleCancel() {
console.log('Cancelled!')
}
</script>
<template>
<Popconfirm
title="Are you sure you want to delete this item?"
@confirm="handleConfirm"
@cancel="handleCancel"
>
<Button variant="destructive">Delete</Button>
</Popconfirm>
</template>Custom Button Text
<script setup>
import { Popconfirm, Button } from 'brutx-ui-vue'
</script>
<template>
<Popconfirm
title="Submit this form?"
confirm-button-text="Yes, submit"
cancel-button-text="No, go back"
confirm-button-type="primary"
>
<Button>Submit</Button>
</Popconfirm>
</template>Destructive Action
<script setup>
import { Popconfirm, Button } from 'brutx-ui-vue'
</script>
<template>
<Popconfirm
title="This action cannot be undone."
confirm-button-type="destructive"
:cancelable="false"
>
<Button variant="destructive">Delete Account</Button>
</Popconfirm>
</template>API Reference
| Name | Type | Default | Description |
|---|---|---|---|
titleRequired | string | — | The title text displayed in the confirmation popover. |
DetailsDeclared typestring Default value details
Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | |||
confirmButtonText | string | undefined | undefined | The confirm button label; localized default text is used when omitted. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | |||
cancelButtonText | string | undefined | undefined | The cancel button label; localized default text is used when omitted. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | |||
confirmButtonType | "primary" | "destructive" | undefined | "primary" | Sets the confirm button to the primary or destructive action style. |
DetailsDeclared type"primary" | "destructive" | undefined Literal values
Default value details
Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | |||
icon | Component | undefined | undefined | The Vue icon component replacing the default warning icon; TriangleAlert is shown when omitted. |
DetailsDeclared typeComponent | undefined Default value details
Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | |||
cancelable | boolean | undefined | true | Controls whether the cancel button is rendered. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | |||
class | string | undefined | undefined | Custom CSS classes added to the popover content container. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | |||
open | boolean | undefined | false | The confirmation popover open state, available through v-model:open. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | |||
| Name | Signature or type | Description |
|---|---|---|
@update:open | [value: boolean] | Emits the new boolean value when the popover open state changes. |
DetailsDeclared type[value: boolean] Literal values
Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | ||
@confirm | [] | Closes the popover and emits after the user activates the confirm button. |
DetailsDeclared type[] Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | ||
@cancel | [] | Closes the popover and emits after the user activates the cancel button. |
DetailsDeclared type[] Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | ||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | Provides the element that triggers the confirmation popover. |
DetailsDeclared type{}Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | ||
#icon | {} | Replaces the content of the default warning icon area. |
DetailsDeclared type{}Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | ||
#description | {} | Renders explanatory content below the title and associates it as the alert dialog description. |
DetailsDeclared type{}Sourcepackages/ui/src/components/popconfirm/Popconfirm.vue | ||
Accessibility
- Built on top of
Popoverwhich follows WAI-ARIA dialog pattern - Keyboard:
Escapeto close,Tabto navigate between buttons - Focus Management: Focus is trapped within the popover when open
- ARIA Attributes: Buttons have appropriate labels