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
> Note: this feature is available with `[email protected]` and higher.
7
+
8
+
Generally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `<AcceptButton>` and `<RejectButton>` components, we recommend creating a `<Button>` component with its own `.Button` styles, that both `<AcceptButton>` and `<RejectButton>` can render (but [not inherit](https://facebook.github.io/react/docs/composition-vs-inheritance.html)).
9
+
10
+
Following this rule often makes CSS preprocessors less useful, as features like mixins and nesting are replaced by component composition. You can, however, integrate a CSS preprocessor if you find it valuable.
11
+
12
+
To use Sass, first install `node-sass`:
13
+
14
+
```bash
15
+
$ npm install node-sass --save
16
+
$ # or
17
+
$ yarn add node-sass
18
+
```
19
+
20
+
Now you can rename `src/App.css` to `src/App.scss` and update `src/App.js` to import `src/App.scss`.
21
+
This file and any other file will be automatically compiled if imported with the extension `.scss` or `.sass`.
22
+
23
+
To share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import "./shared.scss";` with variable definitions.
24
+
25
+
This will allow you to do imports like
26
+
27
+
```scss
28
+
@import'styles/_colors.scss'; // assuming a styles directory under src/
29
+
@import'~nprogress/nprogress'; // importing a css file from the nprogress node module
30
+
```
31
+
32
+
> **Tip:** You can opt into using this feature with [CSS modules](#adding-a-css-modules-stylesheet) too!
33
+
34
+
> **Note:** You must prefix imports from `node_modules` with `~` as displayed above.
-[Alternatives to Ejecting](#alternatives-to-ejecting)
47
46
48
-
## Adding a Sass Stylesheet
49
-
50
-
> Note: this feature is available with `[email protected]` and higher.
51
-
52
-
Generally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `<AcceptButton>` and `<RejectButton>` components, we recommend creating a `<Button>` component with its own `.Button` styles, that both `<AcceptButton>` and `<RejectButton>` can render (but [not inherit](https://facebook.github.io/react/docs/composition-vs-inheritance.html)).
53
-
54
-
Following this rule often makes CSS preprocessors less useful, as features like mixins and nesting are replaced by component composition. You can, however, integrate a CSS preprocessor if you find it valuable.
55
-
56
-
To use Sass, first install `node-sass`:
57
-
58
-
```bash
59
-
$ npm install node-sass --save
60
-
$ # or
61
-
$ yarn add node-sass
62
-
```
63
-
64
-
Now you can rename `src/App.css` to `src/App.scss` and update `src/App.js` to import `src/App.scss`.
65
-
This file and any other file will be automatically compiled if imported with the extension `.scss` or `.sass`.
66
-
67
-
To share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import "./shared.scss";` with variable definitions.
68
-
69
-
This will allow you to do imports like
70
-
71
-
```scss
72
-
@import'styles/_colors.scss'; // assuming a styles directory under src/
73
-
@import'~nprogress/nprogress'; // importing a css file from the nprogress node module
74
-
```
75
-
76
-
> **Tip:** You can opt into using this feature with [CSS modules](#adding-a-css-modules-stylesheet) too!
77
-
78
-
> **Note:** You must prefix imports from `node_modules` with `~` as displayed above.
79
-
80
47
## Post-Processing CSS
81
48
82
49
This project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it.
0 commit comments