Add a Shadow Effect to Bootstrap Components

In Google’s Material Design Lite, you have the ability to add box shadows to components but in Twitter’s Bootstrap you aren’t able to. In this tutorial, I’m going to show you how-to add the same component shadow effect found in Material Design Lite to Bootstrap.Table Example:

See the Pen Bootstrap Table Material Design Lite Shadow Effect by Brandon Himpfen (@brandonhimpfen) on CodePen.

Button Example:

See the Pen Bootstrap Buttons Material Design Lite Shadow Effect by Brandon Himpfen (@brandonhimpfen) on CodePen.

CSS

Add the following to your theme’s CSS file:

.box-shadow--2dp {
    box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12)
}
.box-shadow--3dp {
    box-shadow: 0 3px 4px 0 rgba(0, 0, 0, .14), 0 3px 3px -2px rgba(0, 0, 0, .2), 0 1px 8px 0 rgba(0, 0, 0, .12)
}
.box-shadow--4dp {
    box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2)
}
.box-shadow--6dp {
    box-shadow: 0 6px 10px 0 rgba(0, 0, 0, .14), 0 1px 18px 0 rgba(0, 0, 0, .12), 0 3px 5px -1px rgba(0, 0, 0, .2)
}
.box-shadow--8dp {
    box-shadow: 0 8px 10px 1px rgba(0, 0, 0, .14), 0 3px 14px 2px rgba(0, 0, 0, .12), 0 5px 5px -3px rgba(0, 0, 0, .2)
}
.box-shadow--16dp {
    box-shadow: 0 16px 24px 2px rgba(0, 0, 0, .14), 0 6px 30px 5px rgba(0, 0, 0, .12), 0 8px 10px -5px rgba(0, 0, 0, .2)
}

HTML

To add the shadow effect to the Bootstrap component, use one of the above CSS classes.