File tree Expand file tree Collapse file tree 3 files changed +71
-0
lines changed
docs/src/pages/css-in-js/advanced Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { makeStyles } from '@material-ui/styles' ;
3
+
4
+ const useStyles = makeStyles ( {
5
+ '@global' : {
6
+ '.cssjss-advanced-global-root' : {
7
+ height : 100 ,
8
+ width : 100 ,
9
+ backgroundColor : 'blue' ,
10
+ } ,
11
+ '.cssjss-advanced-global-child' : {
12
+ height : 8 ,
13
+ backgroundColor : 'red' ,
14
+ } ,
15
+ } ,
16
+ } ) ;
17
+
18
+ function GlobalCss ( ) {
19
+ useStyles ( ) ;
20
+
21
+ return (
22
+ < div className = "cssjss-advanced-global-root" >
23
+ < div className = "cssjss-advanced-global-child" />
24
+ </ div >
25
+ ) ;
26
+ }
27
+
28
+ export default GlobalCss ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import clsx from 'clsx' ;
3
+ import { makeStyles } from '@material-ui/styles' ;
4
+
5
+ const useStyles = makeStyles ( {
6
+ root : {
7
+ '&.root' : {
8
+ height : 100 ,
9
+ width : 100 ,
10
+ backgroundColor : 'blue' ,
11
+ } ,
12
+ '& .child' : {
13
+ height : 8 ,
14
+ backgroundColor : 'red' ,
15
+ } ,
16
+ } ,
17
+ } ) ;
18
+
19
+ function HybridCss ( ) {
20
+ const classes = useStyles ( ) ;
21
+
22
+ return (
23
+ < div className = { clsx ( classes . root , 'root' ) } >
24
+ < div className = "child" />
25
+ </ div >
26
+ ) ;
27
+ }
28
+
29
+ export default HybridCss ;
Original file line number Diff line number Diff line change @@ -253,6 +253,20 @@ JSS relies on the concept of [class name generator](https://cssinjs.org/jss-api/
253
253
254
254
## Global CSS
255
255
256
+ ### ` jss-plugin-global `
257
+
258
+ The [ ` jss-plugin-global ` ] ( #jss-plugins ) plugin is installed in the default preset, you can use it to define global class names.
259
+
260
+ {{"demo": "pages/css-in-js/advanced/GlobalCss.js"}}
261
+
262
+ ### Hybrid
263
+
264
+ You can also combine JSS generated class names with global ones.
265
+
266
+ {{"demo": "pages/css-in-js/advanced/HybridGlobalCss.js"}}
267
+
268
+ ### Deterministic class names
269
+
256
270
We provide an option to make the class names ** deterministic** with the [ ` dangerouslyUseGlobalCSS ` ] ( /css-in-js/api/#creategenerateclassname-options-class-name-generator ) option. When turned on, the class names will look like this:
257
271
258
272
- development: ` .AppBar-root `
You can’t perform that action at this time.
0 commit comments