Bootstrap snippet and html example. colored modals

Bootstrap 3.3.4 snippet "colored modals" with HTML, CSS, and JS. Copy, paste, and customize this responsive UI component for your project.
Tags: modal,alert

HTML code

Clean, semantic HTML that powers this Bootstrap 3.3.4 snippet. Copy and paste it into your page (with Bootstrap loaded) to reproduce the exact layout shown in the preview.

<div class="container bootstrap snippets bootdey">
    <div class="btn-demo" id="btn-color-targets">
        <a href="#modalColor" data-target-color="blue" data-toggle="modal" class="btn btn-default ">Blue</a>
        <a href="#modalColor" data-target-color="lightblue" data-toggle="modal" class="btn btn-default ">Light Blue</a>
        <a href="#modalColor" data-target-color="cyan" data-toggle="modal" class="btn btn-default ">Cyan</a>
        <a href="#modalColor" data-target-color="green" data-toggle="modal" class="btn btn-default ">Green</a>
        <a href="#modalColor" data-target-color="lightgreen" data-toggle="modal" class="btn btn-default ">Light Green</a>
        <a href="#modalColor" data-target-color="red" data-toggle="modal" class="btn btn-default ">Red</a>
        <a href="#modalColor" data-target-color="amber" data-toggle="modal" class="btn btn-default ">Amber</a>
        <a href="#modalColor" data-target-color="orange" data-toggle="modal" class="btn btn-default ">Orange</a>
        <a href="#modalColor" data-target-color="teal" data-toggle="modal" class="btn btn-default ">Teal</a>
        <a href="#modalColor" data-target-color="bluegray" data-toggle="modal" class="btn btn-default ">Blue Gray</a>
    </div>
</div>

<div class="modal fade" data-modal-color="" id="modalColor" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Modal title</h4>
            </div>
            <div class="modal-body">
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sodales orci ante, sed ornare eros vestibulum ut. Ut accumsan vitae eros sit amet tristique. Nullam scelerisque nunc enim, non dignissim nibh faucibus ullamcorper. Fusce pulvinar libero vel ligula iaculis ullamcorper. Integer dapibus, mi ac tempor varius, purus nibh mattis erat, vitae porta nunc nisi non tellus. Vivamus mollis ante non massa egestas fringilla. Vestibulum egestas consectetur nunc at ultricies. Morbi quis consectetur nunc.</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-link">Save changes</button>
                <button type="button" class="btn btn-link" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

CSS code

Scoped CSS that styles the component. Paste it after Bootstrap 3.3.4 to keep the design, spacing, and responsiveness consistent.

body{margin-top:20px;}

.modal[data-modal-color] {
  color: #fff;
}

.modal .modal-header {
  padding: 23px 26px;
  border-bottom: 1px solid transparent;
}

.modal .modal-content {
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.31);
  border-radius: 3px;
  border: 0;
}

.modal-footer {
  padding: 15px;
  text-align: right;
  border-top: 1px solid transparent;
}

.modal[data-modal-color] .modal-footer {
  background: rgba(0, 0, 0, 0.1);
}

.modal[data-modal-color] .modal-footer .btn-link {
  font-weight: 400;
}

.modal[data-modal-color] .modal-title, .modal[data-modal-color] .modal-footer .btn-link {
  color: #fff;
}

.modal .modal-footer .btn-link {
  font-size: 14px;
  color: #000;
  font-weight: 500;
}

.btn-link {
  color: #797979;
  text-decoration: none;
  border-radius: 2px;
}

.modal[data-modal-color] .modal-footer .btn-link:hover {
  background-color: rgba(0, 0, 0, 0.1);
  text-decoration:none;
}

.modal[data-modal-color] .modal-footer .btn-link {
  font-weight: 400;
}

/* ========== MODAL COLORS ===============================*/
.modal[data-modal-color="blue"] .modal-content {
  background: #2196f3;
}

.modal[data-modal-color="lightblue"] .modal-content {
  background: #03a9f4;
}

.modal[data-modal-color="cyan"] .modal-content {
  background: #00bcd4;
}

.modal[data-modal-color="green"] .modal-content {
  background: #4caf50;
}

.modal[data-modal-color="lightgreen"] .modal-content {
  background: #8bc34a;
}

.modal[data-modal-color="red"] .modal-content {
  background: #f44336;
}

.modal[data-modal-color="amber"] .modal-content {
  background: #ffc107;
}

.modal[data-modal-color="orange"] .modal-content {
  background: #ff9800;
}

.modal[data-modal-color="teal"] .modal-content {
  background: #009688;
}

.modal[data-modal-color="bluegray"] .modal-content {
  background: #607d8b;
}

Javascript/Jquery code

Lightweight JS to power any interactions this snippet needs. Drop it under your scripts (after Bootstrap 3.3.4) to mirror the live demo.

$(document).ready(function(){
    $('body').on('click', '#btn-color-targets > .btn', function(){
        var color = $(this).data('target-color');
        $('#modalColor').attr('data-modal-color', color);
    });
}); 

Similar snippets

Bootstrap example and template. Rounded and Shadowed Alerts

Rounded and Shadowed Alerts

Bootstrap example and template. notifications panel

notifications panel

Bootstrap example and template. Bootstrap colored Nav with nice alerts

Bootstrap colored Nav with nice alerts

Bootstrap example and template. unify light notifications

unify light notifications

Bootstrap example and template. Vertical Timeline with lines

Vertical Timeline with lines

Bootstrap example and template. events card widget

events card widget

Bootstrap example and template. invoice page

invoice page

Bootstrap example and template. Blog user profile

Blog user profile

FAQ

How do I use this snippet?

Include Bootstrap 3.3.4, paste the HTML, add the CSS block, and include the JS (if any) to mirror the live preview.

Can I use it in commercial projects?

Yes. It’s free for personal and commercial work; check the snippets license for details.

Is it responsive?

Yes. It inherits the responsive grid and components from Bootstrap 3.3.4.

Bootstrap example and template. colored modals

About this bootstrap example/template

Optimized for copy‑paste: clean HTML, scoped CSS, and minimal JS so you can ship production‑ready UI faster and keep designs consistent.

Mobile‑first and responsive by default. Tested across modern browsers to reduce polish time on your project.

Already trusted in 26.1K+ views. Reuse this snippet to speed up landing pages, dashboards, or onboarding flows.

Bootstrap 3.3.4

<link rel='stylesheet' href='https://netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css'>

<script src='https://netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js'></script>

This code example is based on bootstrap 3.3.4 and the grid system of this framework

Responsive

Based on bootstrap framework makes all the layouts perfectly responsive for all devices

Crossbrowser compatibility

Tested on all major browsers, it works smoothly on all of them

Jquery plugins

Great built-in plugins with jquery framework, you can easy to change all declarations

semantic html 5

Built on html / css3 the code quality is really amazing

Simple Integration

This code example can be simply integrated on existing sites and new ones too, all you need to do is copy the code and start working