Skip to content

Cancel and confirm buttons - AvCancelConfirmButtons ​

✨ Introduction ​

The AvCancelConfirmButtons is an interaction element with an interface enabling the user to perform a cancel and/or a confirm action.

🏗️ Structure ​

This component consists of two optional buttons:

  • A cancel button, displayed by passing the cancelLabel prop,
  • A confirm button, displayed by passing the confirmLabel prop,

🏷️ Props ​

NameTypeDefaultMandatoryDescription
cancelLabelstringundefinedLabel and title (for accessibility) of the cancel button.
cancelIconstring'mdi:close-circle-outline'Icon name of the cancel button.
cancelDisabledbooleanundefinedAdds a disabled state on the cancel button.
cancelDisabledTooltipstringundefinedAdds a tooltip text to display when the cancel button is disabled.
cancelIsLoadingbooleanundefinedAdds a loading state on the cancel button.
confirmLabelstringundefinedLabel and title (for accessibility) of the confirm button.
confirmIconstring'mdi:check-circle-outline'Icon name of the confirm button.
confirmDisabledbooleanundefinedAdds a disabled state on the confirm button.
confirmDisabledTooltipstringundefinedAdds a tooltip text to display when the confirm button is disabled.
confirmIsLoadingbooleanundefinedAdds a loading state on the confirm button.
iconOnlybooleanfalseIf true, only the icons are displayed on the buttons.
formstringundefinedAssociates the confirm button with a form.

🔊 Events ​

NameData (payload)Description
'cancel'Event emitted when the cancel button is clicked.
'confirm'Event emitted when the confirm button is clicked.

🎨 Slots ​

None.

🛠️ Exposed methods ​

NameParametersDescription
focusCancelMoves focus to the cancel button.
focusConfirmMoves focus to the confirm button.

🚀 Storybook demos ​

You can find examples of use and demo of the component on its dedicated Storybook page.

💡 Examples of use ​

vue
<template>
  <AvCancelConfirmButtons
    cancel-label="Close"
    @cancel="closeModal"
  />
</template>
vue
<template>
  <AvCancelConfirmButtons
    confirm-label="Confirm"
    @confirm="saveData"
  />
</template>
vue
<template>
  <AvCancelConfirmButtons
    cancel-label="Previous step"
    confirm-label="Next step"
    @cancel="goToPrevStep"
    @confirm="goToNextStep"
  />
</template>
vue
<template>
  <AvCancelConfirmButtons
    cancel-label="Previous step"
    confirm-label="Validate form"
    form="some-form"
    @cancel="goToPrevStep"
    @confirm="goToNextStep"
  />
</template>
vue
<template>
  <AvCancelConfirmButtons
    cancel-label="Cancel"
    confirm-label="Submit"
    :confirm-disabled="!isFormValid"
    confirm-disabled-tooltip="Please complete all required fields"
    @cancel="closeModal"
    @confirm="submitForm"
  />
</template>
vue
<script lang="ts" setup>
const buttonsRef = ref<InstanceType<typeof AvCancelConfirmButtons> | null>(null)

onMounted(() => buttonsRef.value?.focusCancel())
</script>

<template>
  <AvCancelConfirmButtons
    ref="buttonsRef"
    cancel-label="Close"
    confirm-label="Confirm"
    @cancel="closeModal"
    @confirm="saveData"
  />
</template>