Modal/Dialog Generator
Create beautiful, accessible modal dialogs and popups with customizable animations and styles
Presets
Size & Position
Animation
Backdrop
Modal Styling
Header
Close Button
Content
Footer
Click to see your modal in action with animations
Quick Preview
Modal Titlex
Content area
Generated CSS
/* Modal Overlay */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
opacity: 0;
visibility: hidden;
transition: all 300ms ease;
}
.modal-overlay.open {
opacity: 1;
visibility: visible;
}
/* Modal Container */
.modal {
position: relative;
width: 500px;
max-width: 90%;
max-height: 80vh;
background: #ffffff;
border-radius: 8px;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
overflow: hidden;
display: flex;
flex-direction: column;
opacity: 0;
transition: all 300ms ease-out;
}
.modal-overlay.open .modal {
opacity: 1;
}
/* Modal Header */
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24px;
background: transparent;
border-bottom: 1px solid #e0e0e0;
}
.modal-title {
margin: 0;
font-size: 1.25rem;
font-weight: 600;
color: #333333;
}
/* Close Button */
.modal-close {
background: none;
border: none;
cursor: pointer;
padding: 8px;
display: flex;
align-items: center;
justify-content: center;
color: #666666;
border-radius: 4px;
transition: all 0.2s ease;
}
.modal-close:hover {
color: #333333;
background: rgba(0, 0, 0, 0.05);
}
.modal-close svg {
width: 20px;
height: 20px;
}
/* Modal Content */
.modal-content {
padding: 24px;
color: #333333;
flex: 1;
overflow-y: auto;
}
/* Modal Footer */
.modal-footer {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 12px;
padding: 24px;
background: transparent;
border-top: 1px solid #e0e0e0;
}
.modal-btn {
padding: 10px 20px;
border-radius: 6px;
font-size: 0.9375rem;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
}
.modal-btn-primary {
background: #2563eb;
color: white;
border: none;
}
.modal-btn-primary:hover {
opacity: 0.9;
transform: translateY(-1px);
}
.modal-btn-secondary {
background: transparent;
color: #6b7280;
border: 1px solid #6b7280;
}
.modal-btn-secondary:hover {
background: #6b7280;
color: white;
}Generated HTML
<!-- Modal Trigger Button -->
<button onclick="openModal()">Open Modal</button>
<!-- Modal -->
<div class="modal-overlay" id="modal">
<div class="modal">
<div class="modal-header">
<h2 class="modal-title">Modal Title</h2>
<button class="modal-close" onclick="closeModal()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M18 6L6 18M6 6l12 12"/>
</svg>
</button>
</div>
<div class="modal-content">
<p>This is the modal content. You can add any content here including forms, images, or other components.</p>
</div>
<div class="modal-footer">
<button class="modal-btn modal-btn-secondary" onclick="closeModal()">Cancel</button>
<button class="modal-btn modal-btn-primary" onclick="handleConfirm()">Confirm</button>
</div>
</div>
</div>Generated JavaScript
// Modal Functions
const modal = document.getElementById('modal');
function openModal() {
modal.classList.add('open');
document.body.style.overflow = 'hidden';
}
function closeModal() {
modal.classList.remove('open');
document.body.style.overflow = '';
}
function handleConfirm() {
// Add your confirmation logic here
closeModal();
}
// Close on backdrop click
modal.addEventListener('click', (e) => {
if (e.target === modal) {
closeModal();
}
});
// Close on Escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && modal.classList.contains('open')) {
closeModal();
}
});Modal Design Tips
Accessibility
- Always provide a way to close the modal (close button, ESC key)
- Trap focus inside the modal when open
- Return focus to trigger element when closed
- Use proper ARIA attributes (role="dialog", aria-modal="true")
User Experience
- Keep modal content focused and concise
- Use clear action buttons with descriptive labels
- Consider mobile users - use full-width or bottom sheets
- Animate entrance and exit for smooth transitions
Best Practices
- Don't nest modals - use one at a time
- Prevent background scrolling when modal is open
- Make backdrop dismissal optional for important actions
- Use consistent sizing across your application
Modal Types
- Alert: Simple message with single action
- Confirm: Yes/No decision with two actions
- Dialog: Complex content with form or details
- Drawer: Side panel for settings or navigation
Need Custom Modal Components?
Brix340 specializes in building beautiful, accessible UI components for your web applications. Let us help you create the perfect user experience!
Get a Free Quote