A lightweight, customizable, and feature-rich modal plugin that combines the power of jQuery with the elegance of Tailwind CSS. Perfect for modern web applications requiring beautiful and responsive modal dialogs.
- Multiple Modal Types: Standard modals, slide panels, image viewers, and video modals
- Responsive Design: Fully responsive with mobile-first approach
- Tailwind CSS Integration: Seamlessly works with Tailwind CSS utility classes
- Smooth Animations: CSS3-powered transitions and animations
- Multiple Sizes: Small, medium, and large modal variants
- Slide Panels: Left and right sliding panels for navigation and settings
- Media Modals: Dedicated image and video modal support
- YouTube Integration: Direct YouTube video embedding
- Image Zoom: Built-in image zoom functionality
- Keyboard Support: ESC key to close modals
- Backdrop Closing: Click outside to close (configurable)
- Programmatic Control: Full JavaScript API for modal management
- Event Callbacks: Comprehensive event system
- Lightweight: Minimal footprint with no external dependencies except jQuery
-
Download the files:
git clone https://github.com/iamitpkumar/tailwind-jquery-modal.git
-
Include the required dependencies:
<!-- jQuery --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <!-- Tailwind CSS --> <script src="https://cdn.tailwindcss.com"></script> <!-- Plugin Files --> <link rel="stylesheet" href="tailwind-jquery-modal.css"> <script src="tailwind-jquery-modal.js"></script>
-
Create a modal trigger:
<button data-modal-target="#myModal" class="bg-blue-500 text-white px-4 py-2 rounded"> Open Modal </button>
-
Define your modal:
<div id="myModal" class="modal" data-size="medium"> <h3 class="text-xl font-semibold mb-4">Modal Title</h3> <p class="mb-4">Your modal content goes here...</p> <button data-modal-close class="bg-gray-500 text-white px-4 py-2 rounded"> Close </button> </div>
-
Initialize the plugin:
$(document).ready(function() { $('.modal').TailwindModal(); });
<!-- Small Modal -->
<div id="smallModal" class="modal" data-size="small">
<!-- Content -->
</div>
<!-- Medium Modal (default) -->
<div id="mediumModal" class="modal" data-size="medium">
<!-- Content -->
</div>
<!-- Large Modal -->
<div id="largeModal" class="modal" data-size="large">
<!-- Content -->
</div><!-- Left Slide Panel -->
<div id="leftPanel" class="modal" data-type="slide-left" data-width="400">
<!-- Content -->
</div>
<!-- Right Slide Panel -->
<div id="rightPanel" class="modal" data-type="slide-right" data-width="500">
<!-- Content -->
</div><!-- Image Modal -->
<div id="imageModal" class="modal" data-type="image" data-img="path/to/image.jpg" data-alt="Image Alt Text">
</div>
<!-- Video Modal -->
<div id="videoModal" class="modal" data-type="video" data-video="https://www.youtube.com/watch?v=VIDEO_ID">
</div>$('.modal').TailwindModal({
// Appearance
background: '#ffffff', // Modal background color
textColor: '#374151', // Text color
overlayColor: 'rgba(0, 0, 0, 0.75)', // Backdrop color
borderRadius: '0.5rem', // Border radius
// Behavior
animation: true, // Enable/disable animations
closeButton: true, // Show close button
closeOnBackdrop: true, // Close on backdrop click
closeOnEscape: true, // Close on ESC key
// Media Options
videoAutoplay: true, // Autoplay videos
imageZoom: true, // Enable image zoom
// Callbacks
onOpen: function() { // Before modal opens
console.log('Opening...');
},
onShow: function() { // After modal is shown
console.log('Modal visible!');
},
onClose: function() { // Before modal closes
console.log('Closing...');
},
onHide: function() { // After modal is hidden
console.log('Modal hidden!');
}
});// Show modal
$('#myModal').TailwindModal('show');
// Hide modal
$('#myModal').TailwindModal('hide');
// Toggle modal
$('#myModal').TailwindModal('toggle');
// Destroy modal instance
$('#myModal').TailwindModal('destroy');
// Update options
$('#myModal').TailwindModal('option', 'closeOnBackdrop', false);| Attribute | Description | Values |
|---|---|---|
data-size |
Modal size | small, medium, large |
data-type |
Modal type | slide-left, slide-right, image, video |
data-width |
Custom width for slide panels | Any valid CSS width |
data-img |
Image path for image modals | File path or URL |
data-alt |
Alt text for images | Any string |
data-video |
Video URL for video modals | YouTube URL |
data-modal-target |
Target modal selector | CSS selector |
data-modal-close |
Close modal trigger | No value needed |
The plugin uses Tailwind CSS classes for styling. Key classes include:
.modal- Base modal class.modal-overlay- Backdrop overlay.modal-container- Modal container.modal-content- Modal content wrapper
You can override default styles by modifying the CSS file or adding your own styles:
.modal-content {
/* Custom modal content styling */
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
.modal-overlay {
/* Custom overlay styling */
backdrop-filter: blur(4px);
}The plugin works seamlessly with Tailwind's utility classes:
<div id="darkModal" class="modal bg-gray-800 text-white" data-size="medium">
<h3 class="text-xl font-bold text-yellow-400 mb-4">Dark Theme Modal</h3>
<p class="text-gray-300 mb-6">This modal uses a dark theme.</p>
<button data-modal-close class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded">
Close
</button>
</div>- Chrome 60+
- Firefox 60+
- Safari 12+
- Edge 79+
Check out the included index.html file for comprehensive examples of all modal types and features.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with β€οΈ using jQuery and Tailwind CSS
- Inspired by modern modal design patterns
- Thanks to the open-source community for feedback and contributions
If you encounter any issues or have questions:
- Check the documentation above
- Look through existing issues
- Create a new issue with detailed information
- Demo - Live demo
- Issues - Bug reports and feature requests
- Author - Amit P. Kumar
- Company - PS TECH GLOBAL
Made with β€οΈ by Amit P. Kumar