You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/css-in-js.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -20,4 +20,4 @@ _Note that this functionality is not a part of React or Gatsby, and requires usi
20
20
21
21
This section contains guides for styling your site with some of the most popular CSS-in-JS libraries, including how to set up global styles using each library.
Copy file name to clipboardExpand all lines: docs/docs/css-libraries-and-frameworks.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -7,4 +7,4 @@ There are many other CSS libraries and frameworks that you can use in your Gatsb
7
7
8
8
These are not full-on approaches to styling, and generally work no matter which styling approach you've chosen for your website. They require installing third-party libraries, often with the help of Gatsby community plugins.
Copy file name to clipboardExpand all lines: docs/docs/post-css.md
+10-8
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@ title: PostCSS
4
4
5
5
PostCSS transforms extended syntaxes and features into modern, browser-friendly CSS. This guide will show you how to get started with Gatsby and PostCSS.
6
6
7
-
### Installation and Configuration
7
+
##Installing and Configuring PostCSS
8
8
9
9
This guide assumes that you have a Gatsby project set up. If you need to set up a project, head to the [**Quick Start guide**](/docs), then come back.
10
10
11
-
1. Install the Gatsby plugin [**gatsby-plugin-postcss**](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-postcss).
11
+
1. Install the Gatsby plugin [**gatsby-plugin-postcss**](/packages/gatsby-plugin-postcss/).
12
12
13
13
`npm install --save gatsby-plugin-postcss`
14
14
@@ -18,13 +18,11 @@ This guide assumes that you have a Gatsby project set up. If you need to set up
18
18
plugins: [`gatsby-plugin-postcss`],
19
19
```
20
20
21
-
3. Write your stylesheets using PostCSS (.css files) and require or import them as normal.
22
-
23
-
If you need to pass options to PostCSS use the plugins options; see [postcss-loader](https://github.com/postcss/postcss-loader) for all available options.
21
+
> **Note**: If you need to pass options to PostCSS use the plugins options; see [postcss-loader](https://github.com/postcss/postcss-loader) for all available options.
24
22
25
-
#### Syntax example
23
+
3. Write your stylesheets using PostCSS (.css files) and require or import them as normal.
26
24
27
-
```css
25
+
```css:styles.css
28
26
@custom-media --med (width <= 50rem);
29
27
30
28
@media (--med) {
@@ -36,6 +34,10 @@ If you need to pass options to PostCSS use the plugins options; see [postcss-loa
36
34
}
37
35
```
38
36
37
+
```javascript
38
+
import"./styles.css"
39
+
```
40
+
39
41
### With CSS Modules
40
42
41
43
Using CSS modules requires no additional configuration. Simply prepend `.module` to the extension. For example: `App.css -> App.module.css`. Any file with the module extension will use CSS modules.
@@ -69,6 +71,6 @@ module.exports = () => ({
69
71
})
70
72
```
71
73
72
-
###Other resources
74
+
## Other resources
73
75
74
76
-[Introduction to postcss](https://www.smashingmagazine.com/2015/12/introduction-to-postcss/)
[Sass](https://sass-lang.com) is an extension of CSS, adding nested rules, variables, mixins, selector inheritance, and more. In Gatsby, Sass code can be translated to well-formatted, standard CSS using a plugin.
6
+
7
+
Sass will compile `.sass` and `.scss` files to `.css` files for you, so you can write your stylesheets with more advanced features.
8
+
9
+
> **Note**: the difference between using a `.sass` or `.scss` file is the syntax that you write your styles in. All valid CSS is valid SCSS as well so it is the easiest to use and most popular. You can read more about the differences in the [Sass documentation](https://sass-lang.com/documentation/syntax).
10
+
11
+
## Installing and Configuring Sass
12
+
13
+
This guide assumes that you have a Gatsby project set up. If you need to set up a project, head to the [**Quick Start guide**](/docs), then come back.
14
+
15
+
1. Install the Gatsby plugin [**gatsby-plugin-sass**](/packages/gatsby-plugin-sass/).
16
+
17
+
`npm install --save gatsby-plugin-sass`
18
+
19
+
2. Include the plugin in your `gatsby-config.js` file.
20
+
21
+
```javascript:title=gatsby-config.js
22
+
plugins: [`gatsby-plugin-sass`],
23
+
```
24
+
25
+
> **Note**: You can configure [additional plugin options](/packages/gatsby-plugin-sass/#other-options) like paths to include and options for `css-loader`.
26
+
27
+
3. Write your stylesheets as `.sass` or `.scss` files and require or import them as normal.
28
+
29
+
```css:styles.scss
30
+
$font-stack: Helvetica, sans-serif;
31
+
$primary-color: #333;
32
+
33
+
body {
34
+
font: 100%$font-stack;
35
+
color: $primary-color;
36
+
}
37
+
```
38
+
39
+
```css:styles.sass
40
+
$font-stack: Helvetica, sans-serif
41
+
$primary-color: #333
42
+
43
+
body
44
+
font: 100% $font-stack
45
+
color: $primary-color
46
+
```
47
+
48
+
```javascript
49
+
import"./styles.scss"
50
+
import"./styles.sass"
51
+
```
52
+
53
+
## Other resources
54
+
55
+
-[Introduction to Sass](https://designmodo.com/introduction-sass/)
Copy file name to clipboardExpand all lines: docs/docs/tailwind-css.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,7 @@ title: Tailwind CSS
4
4
5
5
Tailwind is a utility-first CSS framework for rapidly building custom user interfaces. This guide will show you how to get started with Gatsby and [Tailwind CSS](https://tailwindcss.com/).
6
6
7
-
This guide assumes that you have a Gatsby project set up. If you need to set up a project, head to the [**Quick Start guide**](/docs/quick-start), then come back.
8
-
9
-
### Overview
7
+
## Overview
10
8
11
9
There are two ways you can use Tailwind with Gatsby:
12
10
@@ -17,6 +15,8 @@ You have to install and configure Tailwind for both of these methods, so this gu
17
15
18
16
## Installing and Configuring Tailwind
19
17
18
+
This guide assumes that you have a Gatsby project set up. If you need to set up a project, head to the [**Quick Start guide**](/docs/quick-start), then come back.
19
+
20
20
1. Install Tailwind
21
21
22
22
```shell
@@ -31,7 +31,7 @@ To configure Tailwind, we'll need to add a Tailwind configuration file. Luckily,
31
31
./node_modules/.bin/tailwind init
32
32
```
33
33
34
-
## Option #1: PostCSS
34
+
###Option #1: PostCSS
35
35
36
36
1. Install the Gatsby PostCSS plugin [**gatsby-plugin-postcss**](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-postcss).
37
37
@@ -61,7 +61,7 @@ You can now use the `@tailwind` directives to add Tailwind's utilites, preflight
61
61
62
62
To learn more about how to use Tailwind in your CSS, visit the [Tailwind Documentation](https://tailwindcss.com/docs/installation#3-use-tailwind-in-your-css)
63
63
64
-
## Option #2: CSS-in-JS
64
+
###Option #2: CSS-in-JS
65
65
66
66
These steps assume you have a CSS-in-JS library already installed, and the examples are based on Styled Components.
67
67
@@ -82,7 +82,7 @@ const Button = styled.button`
82
82
`
83
83
```
84
84
85
-
###Other resources
85
+
## Other resources
86
86
87
87
-[Introduction to PostCSS](https://www.smashingmagazine.com/2015/12/introduction-to-postcss/)
Copy file name to clipboardExpand all lines: packages/gatsby-plugin-sass/README.md
+49-32
Original file line number
Diff line number
Diff line change
@@ -9,31 +9,28 @@ Provides drop-in support for SASS/SCSS stylesheets
9
9
## How to use
10
10
11
11
1. Include the plugin in your `gatsby-config.js` file.
12
-
2. Write your stylesheets in SASS/SCSS and require or import them as normal.
13
12
14
-
```javascript
15
-
// in gatsby-config.js
13
+
```javascript:title="gatsby-config.js"
16
14
plugins: [`gatsby-plugin-sass`]
17
15
```
18
16
19
-
By Default `node-sass` is used. To use `dart-sass`.
17
+
2. Write your stylesheets in Sass/SCSS and require or import them as normal.
20
18
21
-
```bash
22
-
npm i -D sass
19
+
```css:title="src/index.sass"
20
+
html {
21
+
background-color: rebeccapurple;
22
+
p {
23
+
color: white;
24
+
}
25
+
}
23
26
```
24
27
25
28
```javascript
26
-
// in gatsby-config.js
27
-
plugins: [
28
-
{
29
-
resolve:`gatsby-plugin-sass`,
30
-
options: {
31
-
implementation:require("sass"),
32
-
},
33
-
},
34
-
]
29
+
import("./src/index.sass")
35
30
```
36
31
32
+
## Other options
33
+
37
34
If you need to pass options to Sass use the plugins options, see [node-sass](https://github.com/sass/node-sass)/[dart-sass](https://github.com/sass/dart-sass) docs
38
35
for all available options.
39
36
@@ -66,27 +63,27 @@ plugins: [
66
63
]
67
64
```
68
65
69
-
### With CSS Modules
66
+
### Alternative Sass Implementations
70
67
71
-
Using CSS Modules requires no additional configuration. Simply prepend `.module` to the extension. For example: `App.scss` -> `App.module.scss`.
72
-
Any file with the `module` extension will use CSS Modules.
68
+
By default the node implementation of Sass (`node-sass`) is used. To use the implementation written in Dart (`dart-sass`), you can install `sass` instead of `node-sass` and pass it into the options as the implementation:
73
69
74
-
### PostCSS plugins
75
-
76
-
PostCSS is also included to handle some default optimizations like autoprefixing
77
-
and common cross-browser flexbox bugs. Normally you don't need to think about it, but if
78
-
you'd prefer to add additional postprocessing to your SASS output you can specify plugins
79
-
in the plugin options
80
-
81
-
## Relative paths & url()
82
-
83
-
This plugin resolves `url()` paths relative to the entry SCSS/SASS file not – as might be expected – the location relative to the declaration. Under the hood, it makes use of [sass-loader](https://github.com/webpack-contrib/sass-loader/blob/master/README.md#problems-with-url) and this is documented in the [readme](https://github.com/webpack-contrib/sass-loader/blob/master/README.md#problems-with-url).
84
-
85
-
Using [resolve-url-loader](https://github.com/bholloway/resolve-url-loader) may provide a workaround, but at present this is not in the build and implementation would demand customisation.
70
+
```bash
71
+
npm install --save-dev sass
72
+
```
86
73
87
-
TODO link to a plugin that adds resolve-url-loader
74
+
```javascript
75
+
// in gatsby-config.js
76
+
plugins: [
77
+
{
78
+
resolve:`gatsby-plugin-sass`,
79
+
options: {
80
+
implementation:require("sass"),
81
+
},
82
+
},
83
+
]
84
+
```
88
85
89
-
##Other options
86
+
### SASS Precision
90
87
91
88
SASS defaults to [5 digits of precision](https://github.com/sass/sass/issues/1122). If this is too low for you (e.g. [if you use Bootstrap](https://github.com/twbs/bootstrap-sass/blob/master/README.md#sass-number-precision)), you may configure it as follows:
92
89
@@ -103,6 +100,26 @@ plugins: [
103
100
]
104
101
```
105
102
103
+
### With CSS Modules
104
+
105
+
Using CSS Modules requires no additional configuration. Simply prepend `.module` to the extension. For example: `App.scss` -> `App.module.scss`.
106
+
Any file with the `module` extension will use CSS Modules.
107
+
108
+
### PostCSS plugins
109
+
110
+
PostCSS is also included to handle some default optimizations like autoprefixing
111
+
and common cross-browser flexbox bugs. Normally you don't need to think about it, but if
112
+
you'd prefer to add additional postprocessing to your Sass output you can specify plugins
113
+
in the plugin options.
114
+
115
+
## Relative paths & url()
116
+
117
+
This plugin resolves `url()` paths relative to the entry SCSS/Sass file not – as might be expected – the location relative to the declaration. Under the hood, it makes use of [sass-loader](https://github.com/webpack-contrib/sass-loader/blob/master/README.md#problems-with-url) and this is documented in the [readme](https://github.com/webpack-contrib/sass-loader/blob/master/README.md#problems-with-url).
118
+
119
+
Using [resolve-url-loader](https://github.com/bholloway/resolve-url-loader) may provide a workaround, but at present this is not in the build and implementation would demand customization.
120
+
121
+
<!-- TODO link to a plugin that adds resolve-url-loader -->
122
+
106
123
## Breaking changes history
107
124
108
125
<!-- Please keep the breaking changes list ordered with the newest change at the top -->
0 commit comments