UIModalFooter
UIModalFooter
A footer component designed for use within UIModal components, providing a consistent layout for action buttons and additional content.
<template> <UIModal v-model:show="showModal"> <UIModalHeader title="Save Changes" />
<div class="p-6"> Modal content </div>
<UIModalFooter :align="'right'" :bordered="true" :showDivider="true" > <template #default> <UIButton type="default" @click="handleCancel" > Cancel </UIButton> <UIButton type="primary" :loading="saving" @click="handleSave" > Save Changes </UIButton> </template>
<template #extra> <UIButton type="text" size="small" > Need Help? </UIButton> </template> </UIModalFooter> </UIModal></template>
<script setup lang="ts">const showModal = ref(false)const saving = ref(false)
const handleCancel = () => { showModal.value = false}
const handleSave = async () => { saving.value = true try { // Save changes showModal.value = false } finally { saving.value = false }}</script>Props
align(‘left’ | ‘center’ | ‘right’): Button alignmentbordered(boolean): Show top bordershowDivider(boolean): Show divider above footerpadding(string): Custom paddinggutter(number): Space between buttonsreverse(boolean): Reverse button ordersticky(boolean): Stick to bottomtransparent(boolean): Transparent background
Slots
default: Action buttonsextra: Additional contentdivider: Custom divider content
Usage Examples
- Basic Footer:
<template> <UIModalFooter> <UIButton @click="cancel"> Cancel </UIButton> <UIButton type="primary" @click="confirm"> Confirm </UIButton> </UIModalFooter></template>- Footer with Extra Content:
<template> <UIModalFooter align="right"> <template #extra> <div class="flex items-center space-x-2"> <InfoIcon class="w-4 h-4" /> <span class="text-sm text-gray-500"> Changes will be saved automatically </span> </div> </template>
<UIButton type="primary"> Continue </UIButton> </UIModalFooter></template>- Centered Footer with Multiple Actions:
<template> <UIModalFooter align="center" :gutter="16" > <UIButton type="default"> Back </UIButton> <UIButton type="primary"> Next </UIButton> <UIButton type="link"> Skip </UIButton> </UIModalFooter></template>- Sticky Footer:
<template> <UIModalFooter :sticky="true" :bordered="true" class="bg-white" > <UIButton type="default"> Cancel </UIButton> <UIButton type="primary" :loading="saving" > Save Changes </UIButton> </UIModalFooter></template>Best Practices
-
Button Layout:
- Align buttons consistently
- Order by importance
- Group related actions
- Consider button hierarchy
-
Visual Design:
- Use appropriate spacing
- Show clear separation
- Maintain visual balance
- Consider mobile views
-
Interaction:
- Handle loading states
- Prevent double submission
- Support keyboard navigation
- Provide feedback
-
Accessibility:
- Use descriptive labels
- Support keyboard focus
- Maintain tab order
- Consider screen readers
-
Responsive Design:
- Stack buttons on mobile
- Adjust spacing as needed
- Handle long labels
- Maintain touch targets