Bourbon Neat Sass Grid Framework
Bourbon Neat is a lightweight, semantic, and fluid grid framework built with Sass. Currently at stable version 4.0.0, it aims to provide a flexible foundation for responsive layouts while being straightforward to integrate. Its release cadence involves major versions every few years, with more frequent minor and patch updates addressing fixes and enhancements. A key differentiator is its emphasis on semantic markup and a 'fluid first' approach to grid design, offering robust mixins for defining columns, gutters, and media queries without injecting excessive presentational classes into HTML. It is part of the 'Bourbon Family' of Sass tools, which implies good interoperability with other libraries like Bourbon and Bitters.
Common errors
-
Bundler could not find compatible versions for gem "sass"
cause The `sass` gem (Ruby Sass) in your Gemfile or system is outdated and conflicts with Neat's requirements.fixRun `bundle update sass` to upgrade the `sass` gem to a compatible version within your Ruby on Rails project. -
Neat to not be found when using SassC.
cause An issue prevented Neat from being correctly resolved or found by SassC, a LibSass wrapper.fixThis specific issue was fixed in Neat v3.0.1. Upgrade your `bourbon-neat` package to version 3.0.1 or newer. Ensure your `node-sass` `includePaths` are correctly configured if using npm. -
Neat to not be found within Rails apps.
cause A bug in earlier versions of Neat prevented it from being correctly located by Rails' asset pipeline.fixThis issue was fixed in Neat v2.1.0. Upgrade your `neat` gem to version 2.1.0 or newer. Also, ensure your `application.scss` correctly uses `@import "neat";`.
Warnings
- breaking Bower support has been entirely removed starting with Neat v4.0.0. Projects still relying on Bower for Neat will need to migrate to npm or RubyGems for package management.
- breaking The Ruby Sass gem (deprecated) is no longer a runtime dependency as of v4.0.0. While this removes a legacy dependency, ensure your Sass compilation environment is updated to use Dart Sass or LibSass-based compilers like `node-sass`.
- breaking Version 2.0.0 introduced significant changes, including the addition of `grid-shift` and `grid-media` functionality, while `grid-collapse` removed its `float` property. These changes might break layouts relying on previous behaviors or expecting the `float` property within `grid-collapse`.
- deprecated The use of `&&` for boolean 'and' in Sass was deprecated in older versions. Neat fixed this in v1.9.1, but if using an older version or custom mixins, be aware of this Sass warning.
- gotcha When using Neat in Ruby on Rails, `@import` rules in `application.scss` are not compatible with Sprockets directives (e.g., `//= require`). You must choose one or the other for your asset management.
Install
-
npm install bourbon-neat -
yarn add bourbon-neat -
pnpm add bourbon-neat
Imports
- @import 'neat';
@import 'bourbon-neat';
@import 'neat';
- @import 'neat/neat';
@import 'neat';
@import 'neat/neat';
- $grid-columns
$neat-grid-columns: 12;
$grid-columns: 12;
Quickstart
@import 'neat';
// Configure Neat variables (optional, defaults are fine)
$neat-grid-columns: 12;
$neat-gutter: 20px;
// Define a custom grid for media queries (optional)
$custom-grid: (columns: 6, gutter: 15px);
.outer-container {
@include outer-container;
}
.main-content {
@include column(9);
@include media('max-width', 768px) {
@include column(12);
}
@include media('max-width', 480px) using ($custom-grid) {
@include column(6);
}
}
.sidebar {
@include column(3, omega()); // omega() mixin for the last column in a row
@include media('max-width', 768px) {
@include column(12);
}
}