UIModalHeader
UIModalHeader
A header component designed for use within UIModal components, providing a consistent layout for modal titles, descriptions, and close buttons.
<template> <UIModal v-model:show="showModal"> <UIModalHeader :title="'Confirm Action'" :description="'Are you sure you want to proceed?'" :showClose="true" @close="handleClose" > <template #icon> <AlertTriangleIcon class="w-6 h-6 text-warning-500" /> </template>
<template #extra> <UIBadge type="warning"> Important </UIBadge> </template> </UIModalHeader>
<div class="p-6"> Modal content </div>
<UIModalFooter> <UIButton @click="handleClose"> Cancel </UIButton> <UIButton type="primary" @click="handleConfirm"> Confirm </UIButton> </UIModalFooter> </UIModal></template>
<script setup lang="ts">const showModal = ref(false)
const handleClose = () => { showModal.value = false}
const handleConfirm = () => { // Handle confirmation showModal.value = false}</script>Props
title(string): Modal titledescription(string): Modal descriptionshowClose(boolean): Show close buttoncloseIcon(Component): Custom close iconbordered(boolean): Show bottom bordersize(‘small’ | ‘medium’ | ‘large’): Header sizealign(‘left’ | ‘center’ | ‘right’): Content alignmentdivider(boolean): Show divider below header
Events
close: Emitted when close button is clicked
Slots
default: Custom header contenttitle: Custom title contentdescription: Custom description contenticon: Icon before titleextra: Additional content after titleclose: Custom close button content
Usage Examples
- Basic Header:
<template> <UIModalHeader title="Settings" description="Configure your preferences" /></template>- Custom Icon and Badge:
<template> <UIModalHeader title="Delete Account"> <template #icon> <TrashIcon class="w-6 h-6 text-error-500" /> </template> <template #extra> <UIBadge type="error"> Destructive Action </UIBadge> </template> </UIModalHeader></template>- Centered Header:
<template> <UIModalHeader title="Welcome" description="Get started with your account" align="center" > <template #icon> <LogoIcon class="w-8 h-8" /> </template> </UIModalHeader></template>- Custom Title:
<template> <UIModalHeader> <template #title> <div class="flex items-center space-x-2"> <UserIcon class="w-5 h-5" /> <span>User Profile</span> <UIBadge type="success"> Pro </UIBadge> </div> </template> </UIModalHeader></template>Best Practices
-
Content:
- Keep titles clear and concise
- Use descriptions for context
- Include relevant icons
- Show important metadata
-
Layout:
- Maintain consistent spacing
- Align content appropriately
- Use dividers when needed
- Consider mobile views
-
Interaction:
- Provide clear close button
- Handle keyboard navigation
- Support touch targets
- Consider animations
-
Accessibility:
- Use semantic headings
- Include ARIA labels
- Support screen readers
- Maintain focus management
-
Visual Hierarchy:
- Use appropriate sizing
- Maintain contrast
- Group related elements
- Consider visual weight