-
Notifications
You must be signed in to change notification settings - Fork 28
Creating a theme
Themes in Skeleton Sass 3 enable you to extend and/or override the default behavior of Skeleton Sass without touching Skeleton Sass core code. Skeleton Sass 3 offers endpoints that truly allow you to have Skeleton Sass as a TPL (third-party library) in your project! Below we'll outline how to create a theme in Skeleton Sass 3.
Looking for theme setup in Skeleton Sass 2?
For the purposes of this tutorial, we'll assume you have Skeleton Sass integrated into your project already. Don't have Skeleton Sass setup yet? Learn how!
We'll assume the following app structure:
-
app/
-
source/
images/
js/
-
sass/
skeleton.scss
-
skeleton/
_config.scss
_loader.scss
-
themes/
-
my_theme/
_vars.scss
_mixins.scss
-
-
Creating a new theme that extends and/or overrides Skeleton Sass core themes is easier than before. Simply navigate to app/source/sass/skeleton/themes
and create a new directory with the name of your theme. Add two new files:
-
_vars.scss
which will contain all of your custom, theme-scoped variables -
_mixins.scss
which will contain all of your custom, theme-scoped mixins
Skeleton Sass ships with two themes:
Additional documentation:
In your own themes, you can override global variables on a per-theme basis as seen in the fresh theme _vars.scss
. Some general guidelines to follow when using variables with Skeleton Sass themes:
- Any variables that do not differ between themes should be placed in
_config.scss
- Any new variables to be used across all themes (e.g. Font Awesome font path variable) should be placed in
_config.scss
- Any new variables that differ from theme-to-theme should be place in the theme's respective
_vars.scss
file - Any global or theme-scoped overrides that differ between themes should be place in the theme's respective
_vars.scss
file
Referring to the four rules, ensure you want to create global mixins and/or functions.
Although this is not explicitly addressed in the structure above, we should create some additional files in the skeleton
directory:
_mixins.scss
_functions.scss
Once these files are created we need to add them to our _loader.scss
// 1. core config and core config overrides
@import "config";
// Adding new global mixins/functions
@import "mixins";
@import "functions";
// ...
Remember that _mixins.scss
partial we created in app/source/sass/skeleton/themes/my_theme
? Add your theme-scoped mixins here!
This can be done two ways:
-
Create a
_base.scss
file inapp/source/sass/skeleton/themes/my_theme
and import the core theme's_base.scss
partial. Be sure to update your_loader.scss
to reference your_base.scss
partial!app/source/sass/skeleton/themes/my_theme/_base.scss
@import "../../../../../../bower_components/skeleton-sass/skeleton/themes/fresh/base"; // '../' galore 👎
app/source/sass/skeleton/_loader.scss
// ... // 4. import default theme styles @import "themes/my_theme/base"; @import "../../../bower_components/skeleton-sass/skeleton/themes/fresh/skeleton";
Base styles are the dressings of a website. The base styles defined in each theme are the set of styles that dress components like navigation bars, body text, preformatted text, etc. Often, we'll want to grid capability of Skeleton Sass, but wish to use our own base styles. This can be done several ways. Let's look at some use cases:
-
I want to make slight modifications to a core theme's colors
This can often be done by changing the theme variables. We recommend looking at the core variables and override the ones you need.
-
I want to make some/many modifications to a core theme's base styles
Depending on the magnitude of the changes this can be done two ways:
- Override the styles you want to in
skeleton.scss
- Good for trivial changes that can't otherwise be accomplished by editing variable values
- Copy and paste the core theme's
_base.scss
partial intoapp/source/sass/skeleton/themes/my_theme/_base.scss
and be sure to update the reference to_base.scss
in_loader.scss
!- Good for big changes
- Override the styles you want to in