sass-boilerplate
A boilerplate for Sass projects using the 7-1 architecture pattern from Sass Guidelines.
Top Related Projects
Modern CSS framework based on Flexbox
Official Sass port of Bootstrap 2 and 3.
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 Lightweight Sass Tool Set
Materialize, a CSS Framework based on Material Design
Sass makes CSS fun!
Quick Overview
Sass-boilerplate is a lightweight and opinionated Sass architecture for structuring scalable CSS projects. It provides a well-organized folder structure and a set of base files to kickstart Sass projects, following best practices and conventions for maintainable and modular CSS development.
Pros
- Well-organized folder structure for easy navigation and scalability
- Follows the 7-1 pattern for Sass architecture, promoting modularity
- Includes a comprehensive
.gitignore
file for Sass projects - Provides a solid foundation for consistent and maintainable CSS code
Cons
- May be too opinionated for some developers who prefer different architectures
- Requires familiarity with Sass and its conventions
- Limited documentation on customization and extension
- May need additional setup for integration with specific build tools or frameworks
Code Examples
- Example of importing partials in the main.scss file:
@import 'abstracts/variables';
@import 'abstracts/functions';
@import 'abstracts/mixins';
@import 'base/reset';
@import 'base/typography';
@import 'components/buttons';
@import 'components/carousel';
- Using a mixin from the boilerplate:
@import 'abstracts/mixins';
.element {
@include on-event {
// Styles for hover, active, focus
background-color: #f0f0f0;
}
}
- Defining variables in the variables partial:
// Colors
$primary-color: #3498db;
$secondary-color: #2ecc71;
// Typography
$base-font-size: 16px;
$heading-font-family: 'Helvetica Neue', sans-serif;
Getting Started
-
Clone the repository:
git clone https://github.com/KittyGiraudel/sass-boilerplate.git
-
Copy the
stylesheets
folder to your project. -
Rename
main.scss
to match your project's name if desired. -
Start writing your Sass code in the appropriate partials within the folder structure.
-
Compile your Sass files using your preferred build tool or Sass compiler.
Competitor Comparisons
Modern CSS framework based on Flexbox
Pros of Bulma
- Comprehensive CSS framework with pre-built components
- Extensive documentation and community support
- Responsive design out of the box
Cons of Bulma
- Larger file size due to extensive features
- Less flexibility for custom designs
- Steeper learning curve for beginners
Code Comparison
Bulma (CSS):
.button {
background-color: #00d1b2;
border-color: transparent;
color: #fff;
}
sass-boilerplate (SCSS):
.button {
@include button-variant($primary-color);
@include transition(background-color 0.2s ease-in-out);
}
Bulma provides ready-to-use CSS classes, while sass-boilerplate offers a more customizable SCSS structure. Bulma's approach is simpler for quick prototyping, but sass-boilerplate allows for more granular control over styles.
sass-boilerplate is a lightweight Sass architecture boilerplate, focusing on providing a solid foundation for custom styling. It's ideal for developers who want full control over their CSS and prefer writing custom styles.
Bulma, on the other hand, is a complete CSS framework with pre-built components and utilities. It's better suited for rapid development and projects that don't require extensive customization.
Choose sass-boilerplate for flexibility and custom designs, or Bulma for quick development with pre-built components and responsive layouts.
Official Sass port of Bootstrap 2 and 3.
Pros of bootstrap-sass
- Comprehensive framework with a wide range of pre-built components
- Extensive documentation and large community support
- Responsive grid system for easy layout creation
Cons of bootstrap-sass
- Larger file size and potential performance impact
- Less flexibility for custom designs due to opinionated styles
- Steeper learning curve for customization
Code Comparison
bootstrap-sass:
@import "bootstrap";
.custom-component {
@extend .btn;
@include button-variant($primary, $primary);
}
sass-boilerplate:
@import "abstracts/variables";
@import "components/button";
.custom-component {
@include button;
background-color: $primary-color;
}
The bootstrap-sass example shows how to extend existing components and use mixins, while sass-boilerplate demonstrates a more modular approach with custom variables and mixins.
bootstrap-sass is better suited for rapid prototyping and projects that align with its design philosophy, while sass-boilerplate offers more flexibility for custom designs and smaller file sizes. The choice between them depends on project requirements and personal preferences.
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
- Comprehensive framework with a wide range of UI components and features
- Extensive documentation and community support
- Responsive grid system for easy layout creation
Cons of Foundation
- Larger file size and potential performance impact
- Steeper learning curve due to its extensive feature set
- Less flexibility for custom designs without overriding styles
Code Comparison
sass-boilerplate:
@import 'abstracts/variables';
@import 'abstracts/functions';
@import 'abstracts/mixins';
@import 'base/reset';
@import 'base/typography';
Foundation:
@import 'foundation';
@include foundation-global-styles;
@include foundation-grid;
@include foundation-typography;
@include foundation-button;
@include foundation-forms;
sass-boilerplate focuses on a minimal, modular structure for custom Sass projects, while Foundation provides a full-featured framework with pre-built components. sass-boilerplate offers more flexibility and a lighter footprint, making it suitable for custom designs. Foundation, on the other hand, provides a robust set of tools and components, making it ideal for rapid prototyping and projects that require a comprehensive UI framework out of the box.
A Lightweight Sass Tool Set
Pros of Bourbon
- More comprehensive set of mixins and functions
- Actively maintained with regular updates
- Extensive documentation and community support
Cons of Bourbon
- Larger file size and potential performance impact
- Steeper learning curve due to more features
- May include unnecessary features for smaller projects
Code Comparison
sass-boilerplate:
@mixin on-event($self: false) {
@if $self {
&,
&:hover,
&:active,
&:focus {
@content;
}
} @else {
&:hover,
&:active,
&:focus {
@content;
}
}
}
Bourbon:
@mixin position($position: relative, $coordinates: null) {
@if type-of($position) == list {
$coordinates: $position;
$position: relative;
}
$coordinates: unpack($coordinates);
$offsets: (
top: nth($coordinates, 1),
right: nth($coordinates, 2),
bottom: nth($coordinates, 3),
left: nth($coordinates, 4)
);
position: $position;
@each $offset, $value in $offsets {
@if is-length($value) {
#{$offset}: $value;
}
}
}
The code comparison shows that Bourbon provides more complex and feature-rich mixins, while sass-boilerplate offers simpler, more focused utilities. Bourbon's approach may be beneficial for larger projects, while sass-boilerplate's simplicity could be preferable for smaller, more streamlined codebases.
Materialize, a CSS Framework based on Material Design
Pros of Materialize
- Comprehensive UI framework with pre-built components
- Responsive grid system for easy layout creation
- Active community and regular updates
Cons of Materialize
- Larger file size and potential performance impact
- Less flexibility for custom designs
- Steeper learning curve for beginners
Code Comparison
Materialize (CSS):
.btn {
text-decoration: none;
color: #fff;
background-color: #26a69a;
text-align: center;
letter-spacing: .5px;
transition: background-color .2s ease-out;
cursor: pointer;
}
sass-boilerplate (SCSS):
%button {
display: inline-block;
padding: 0.5em 1em;
border: 0;
border-radius: 0.25em;
background-color: $primary-color;
color: white;
font-size: 1em;
line-height: 1;
text-decoration: none;
}
Materialize provides a more opinionated and feature-rich approach with pre-styled components, while sass-boilerplate offers a minimal starting point for custom SCSS development. Materialize is better suited for rapid prototyping and projects that align with its design language, whereas sass-boilerplate is ideal for developers who prefer full control over their styling and architecture.
Sass makes CSS fun!
Pros of sass
- Official Sass implementation, ensuring up-to-date features and compatibility
- Extensive documentation and community support
- Robust codebase with comprehensive test coverage
Cons of sass
- Larger codebase, potentially more complex for beginners
- Focused on core Sass functionality, lacking pre-built architecture
- May require additional setup for project-specific organization
Code Comparison
sass-boilerplate:
@import 'abstracts/variables';
@import 'abstracts/functions';
@import 'abstracts/mixins';
@import 'base/reset';
@import 'base/typography';
sass:
@use 'sass:math';
@use 'sass:color';
$base-color: #c6538c;
$border-dark: rgba($base-color, 0.88);
sass-boilerplate provides a structured architecture for organizing Sass files, while sass focuses on core Sass functionality. sass-boilerplate offers a ready-to-use folder structure and import system, making it easier to start a new project. On the other hand, sass provides the foundation for building custom Sass implementations and offers more flexibility for advanced users.
sass-boilerplate is ideal for developers looking for a quick start with a predefined structure, while sass is better suited for those who need full control over their Sass setup or are building tools and libraries that utilize Sass functionality.
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
Sass Boilerplate
This is a sample project using the 7-1 architecture pattern and sticking to Sass Guidelines writing conventions.
Each folder of this project has its own README.md
file to explain the purpose and add extra information. Be sure to browse the repository to see how it works.
Using the indented syntax
Sass conversion
This boilerplate does not provide a .sass
version as it would be painful to maintain both versions without an appropriate build process. However, it is very easy to convert this boilerplate to Sass indented syntax.
Clone it, head into the project and then run:
sass-convert -F scss -T sass -i -R ./ && find . -iname â*.scssâ -exec bash -c 'mv "$0" â${0%\.scss}.sass"' {} \;
Use with Sass
When using sass
- in order to build that boilerplate, one needs to:
- install
sass
if not yet installed:
npm install -g sass
- run build command from command line:
sass stylesheets/main.scss dist/main.css
Top Related Projects
Modern CSS framework based on Flexbox
Official Sass port of Bootstrap 2 and 3.
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 Lightweight Sass Tool Set
Materialize, a CSS Framework based on Material Design
Sass makes CSS fun!
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