Top Related Projects
Sass makes CSS fun!
Modern CSS framework based on Flexbox
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.
A utility-first CSS framework for rapid UI development.
A modern alternative to CSS resets
Quick Overview
Bourbon is a lightweight Sass tool set, providing a collection of mixins and functions designed to make web development easier and more efficient. It's a simple and straightforward library that helps developers write cleaner, more maintainable CSS without imposing design decisions or bloated code.
Pros
- Lightweight and modular, allowing developers to use only what they need
- Extensive documentation and active community support
- Seamless integration with existing Sass projects
- Regularly updated to maintain compatibility with the latest Sass versions
Cons
- Limited pre-built components compared to full CSS frameworks
- Requires knowledge of Sass to fully utilize its features
- Some mixins may become obsolete as CSS evolves and adds new features
- Learning curve for developers new to Sass or Bourbon's specific syntax
Code Examples
- Using the
position
mixin:
.element {
@include position(absolute, 0 null null 10px);
}
This creates an absolutely positioned element, 10px from the left and flush with the top of its container.
- Applying the
font-face
mixin:
@include font-face(
"source-sans-pro",
"fonts/source-sans-pro-regular",
("woff2", "woff")
);
This generates the necessary @font-face
declaration for including custom fonts.
- Using the
shade
function for color manipulation:
.button {
background-color: #3498db;
&:hover {
background-color: shade(#3498db, 20%);
}
}
This creates a darker shade of the original color for the button's hover state.
Getting Started
To use Bourbon in your project:
-
Install Bourbon via npm:
npm install bourbon
-
Import Bourbon in your Sass file:
@import "bourbon";
-
Start using Bourbon's mixins and functions in your Sass:
.element { @include padding(2rem null); color: shade($base-color, 10%); }
Now you can leverage Bourbon's features to streamline your CSS development process.
Competitor Comparisons
Sass makes CSS fun!
Pros of Sass
- More comprehensive and feature-rich, offering a wider range of functionalities
- Official implementation of the Sass language, ensuring better compatibility and support
- Larger community and ecosystem, with more resources and third-party tools available
Cons of Sass
- Steeper learning curve due to its extensive feature set
- Requires compilation, which can add complexity to the development workflow
- Larger file size and potentially slower compilation times for complex projects
Code Comparison
Sass:
@mixin button-styles($color) {
background-color: $color;
color: darken($color, 20%);
&:hover {
background-color: lighten($color, 10%);
}
}
Bourbon:
@import "bourbon";
.button {
@include button($color: $blue);
@include transition(all 0.2s ease-in-out);
}
Sass provides more low-level control and flexibility in defining mixins, while Bourbon offers pre-built mixins for common patterns, resulting in more concise code. Sass requires more manual implementation but allows for greater customization, whereas Bourbon provides a quicker setup with less flexibility.
Modern CSS framework based on Flexbox
Pros of Bulma
- Comprehensive CSS framework with pre-built components
- Flexbox-based grid system for modern layouts
- Mobile-first approach with responsive design out of the box
Cons of Bulma
- Larger file size due to more features and components
- Less flexibility for custom designs compared to Bourbon's lightweight approach
- Steeper learning curve for developers new to the framework
Code Comparison
Bulma (class-based approach):
<div class="columns">
<div class="column is-half">
<p class="has-text-centered">Centered text</p>
</div>
</div>
Bourbon (Sass mixin approach):
.container {
@include grid-column(6);
p {
@include text-align(center);
}
}
Bulma provides a more declarative, class-based approach to styling, while Bourbon offers a programmatic, mixin-based method. Bulma's approach may lead to more verbose HTML but can be easier for rapid prototyping. Bourbon's approach keeps HTML cleaner but requires more custom Sass code.
Both frameworks have their strengths, with Bulma excelling in quick development of feature-rich interfaces and Bourbon offering more flexibility for custom designs. The choice between them depends on project requirements and developer preferences.
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
Pros of Bootstrap
- Comprehensive UI framework with pre-built components
- Extensive documentation and large community support
- Responsive grid system for easy layout creation
Cons of Bootstrap
- Larger file size, potentially impacting page load times
- More opinionated design, which can lead to "Bootstrap-looking" websites
- Steeper learning curve for customization
Code Comparison
Bootstrap (CSS):
.btn-primary {
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
Bourbon (Sass):
@import "bourbon";
.btn-primary {
@include button($color: #fff, $background: #007bff);
}
Key Differences
- Bootstrap provides ready-to-use components, while Bourbon offers mixins and functions for custom styling
- Bourbon is more lightweight and flexible, allowing for easier customization
- Bootstrap includes a grid system and JavaScript components, whereas Bourbon focuses on Sass utilities
Use Cases
- Bootstrap: Rapid prototyping, projects requiring a full UI framework
- Bourbon: Custom designs, projects needing lightweight Sass tools
Community and Maintenance
- Bootstrap: Larger community, frequent updates, extensive third-party resources
- Bourbon: Smaller but active community, regular maintenance, focused on Sass functionality
The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.
Pros of Foundation
- More comprehensive framework with built-in UI components and JavaScript plugins
- Extensive documentation and community support
- Responsive grid system with flexible layout options
Cons of Foundation
- Larger file size and potential performance impact
- Steeper learning curve due to more features and complexity
- Less customizable without overriding default styles
Code Comparison
Foundation:
.button {
@include button;
@include button-style($primary-color);
}
Bourbon:
.button {
@include button($primary-color);
}
Foundation provides more built-in mixins and components, while Bourbon offers a lightweight approach with more flexibility for custom designs. Foundation's code often includes more pre-defined styles and options, whereas Bourbon encourages developers to build their own styles using its utility mixins.
Foundation is better suited for rapid prototyping and projects requiring a full-featured framework. Bourbon is ideal for developers who prefer a minimalist approach and want more control over their stylesheets.
Both projects have active communities and regular updates, but Foundation has a larger ecosystem with additional resources and extensions.
A utility-first CSS framework for rapid UI development.
Pros of Tailwind CSS
- Utility-first approach allows for rapid development and easy customization
- Extensive documentation and large community support
- Built-in responsive design and dark mode support
Cons of Tailwind CSS
- Steeper learning curve for developers used to traditional CSS frameworks
- Can lead to verbose HTML with many utility classes
- Requires additional build step and configuration
Code Comparison
Tailwind CSS:
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Button
</button>
Bourbon:
@import "bourbon";
.button {
@include button($background: blue);
}
Summary
Tailwind CSS offers a utility-first approach with extensive features and community support, while Bourbon provides a more traditional Sass mixin library. Tailwind CSS excels in rapid development and customization but may result in more verbose HTML. Bourbon offers a cleaner HTML structure but requires more custom CSS writing. The choice between the two depends on project requirements and team preferences.
A modern alternative to CSS resets
Pros of normalize.css
- Lightweight and focused solely on normalizing browser styles
- Widely adopted and well-maintained, with frequent updates
- Easy to integrate into any project without additional dependencies
Cons of normalize.css
- Limited in scope, only addressing browser inconsistencies
- Requires additional CSS for more advanced styling and layout
- Less flexibility compared to full-featured Sass mixins and functions
Code Comparison
normalize.css:
html {
line-height: 1.15;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
Bourbon:
@import "bourbon";
body {
@include margin(0);
@include padding(20px);
font-family: $font-stack-system;
}
Summary
normalize.css is a lightweight CSS reset that focuses on normalizing browser styles, making it easy to integrate into any project. It's widely adopted and well-maintained but limited in scope.
Bourbon, on the other hand, is a comprehensive Sass mixin library that provides a wide range of tools for styling and layout. While it offers more flexibility and features, it requires Sass compilation and may have a steeper learning curve.
The choice between the two depends on project requirements, with normalize.css being ideal for simple normalization and Bourbon offering more advanced styling capabilities.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Deprecated as of September 13, 2024
This project is no longer maintained. We encourage people to leverage the modern native CSS features in lieu of this library. You can refer to our blog post on how to go about replacing or rethinking each helper.
A Lightweight Sass Tool Set
Bourbon is a library of Sass mixins and functions that are designed to make you a more efficient style sheet author.
It isâ¦
-
Dependency-free: Bourbon is pure Sass.
-
Human-readable: We aim for clarity over brevity.
-
Lightweight: Zero output post-install and has no visual opinion.
Helpful Links
Table of Contents
Requirements
Installation
-
Install the Bourbon gem using the RubyGems package manager:
gem install bourbon
-
Install the Bourbon library into the current directory:
bourbon install
Pro Tip: You can target installation into a specific directory using the
path
flag:bourbon install --path my/custom/path/
-
Import Bourbon at the beginning of your stylesheet:
@import "bourbon/bourbon";
Itâs not recommended that you modify Bourbonâs files directly as it will make updating to future versions difficult, by overwriting your custom changes or causing merge conflicts.
Installation for Ruby on Rails 4.2+
-
Add Bourbon to your Gemfile:
gem "bourbon"
-
Then run:
bundle install
-
Restart your server and rename
application.css
toapplication.scss
:mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss
-
Delete all Sprockets directives in
application.scss
(require
,require_tree
andrequire_self
) and use Sassâs native@import
instead (why?). -
Import Bourbon at the beginning of
application.scss
. Any project styles that utilize Bourbonâs features must be imported after Bourbon.@import "bourbon"; @import "home"; @import "users";
Installing with npm and using a Node-based asset pipeline
-
Add Bourbon as a dependency:
npm install --save bourbon
-
If youâre using eyeglass, skip to Step 3. Otherwise, youâll need to add Bourbon to your node-sass
includePaths
option.require("bourbon").includePaths
is an array of directories that you should pass to node-sass. How you do this depends on how node-sass is integrated into your project. -
Import Bourbon into your Sass files:
@import "bourbon";
Installing older versions of Bourbon
-
Uninstall any Bourbon gem versions you already have:
gem uninstall bourbon
-
Reinstall the Bourbon gem, using the
-v
flag to specify the version you need:gem install bourbon -v 4.2.7
-
Follow the instructions above to install Bourbon into your project.
Command Line Interface
bourbon [options]
Options
Option | Description |
---|---|
-h , --help | Show help |
-v , --version | Show the version number |
--path | Specify a custom path |
--force | Force install (overwrite) |
Commands
Command | Description |
---|---|
bourbon install | Install Bourbon into the current directory |
bourbon update | Overwrite and update Bourbon in the current directory |
bourbon help | Show help |
Browser Support
Bourbon supports Internet Explorer 11+ and the latest versions of Chrome, Firefox, Safari, and Edge.
Contributing
See the contributing document. Thank you, contributors!
License
Bourbon is copyright © 2011 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the license.
About thoughtbot
This repo is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.
We love open source software! See our other projects. We are available for hire.
Top Related Projects
Sass makes CSS fun!
Modern CSS framework based on Flexbox
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.
A utility-first CSS framework for rapid UI development.
A modern alternative to CSS resets
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot