CSS in ReactJS Components
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988989/pasted-from-clipboard.png)
Css in React Componets
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988474/Screen_Shot_2017-07-15_at_3.26.32_AM.png)
Css puede ser sorpresivamente difícil
- Compiled Css
- Inline Styles
- Css Modules
- Css in JS
Compiled CSS
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988438/Screen_Shot_2017-07-15_at_2.00.24_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988439/Screen_Shot_2017-07-15_at_2.01.42_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988441/Screen_Shot_2017-07-15_at_2.02.10_AM.png)
Borrar estilos puede generar problemas
Las hojas de estilos crecen y crecen
Solución a Global Css
Naming: BEM, OOCSS, SMACSS
Solución a Global Css
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988446/Screen_Shot_2017-07-15_at_2.13.08_AM.png)
https://www.sitepoint.com/front-end-tooling-trends-2017/
Solución a Global Css
BEM
Block __ Element -- Modifier
Form__Button--Error
Inline Styles
BEM
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988448/Screen_Shot_2017-07-15_at_2.24.21_AM.png)
Inline Styles
Facil de codificar
Encapsulado
Explicito
Dinamico
no Pseudo classes
no Media Queries
no Animations
no ....
Inline vs Compiled
Considera el uso de ambos en base al contexto
Best Practices:
Encapsulate
Be Small and specifict
Css Modules
Es un CSS file que todas sus clases son encapsuladas localmente por defecto
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988449/Screen_Shot_2017-07-15_at_2.37.40_AM.png)
Css Modules
1. Write plain Css
2. Import style from file.css
3. Use style as Js Object
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988454/Screen_Shot_2017-07-15_at_2.48.22_AM.png)
Css Modules
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988455/Screen_Shot_2017-07-15_at_2.50.13_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988456/Screen_Shot_2017-07-15_at_2.50.49_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988457/Screen_Shot_2017-07-15_at_2.55.09_AM.png)
Css Modules
Automatic BEM
Sass, less
Compose
Encapsulado
No Conflictos
Small Css selectors
Compilado en Build Time
Css Modules
Que tiene de malo ?
Toda hoja de estilo es importado como objectos, no hay globales
Theming es un poco mas complejo
Css In JS
JS over Sass, Less , PostCSS ?
~50 cssInJs libraries
Css In JS
Es mas Javascript
Variables, F(), Loops
En ReactJs ya usamos JS en "Templates"
Css In JS
Amarrado a la Libreria
Falta de Css features
Puede ser confuso cuando se mezcla con plain Css
Css In JS
Radium
Jsxstyles
Styled Components
Glamour
...
Css In JS
?
~50 cssInJs libraries
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988463/Screen_Shot_2017-07-15_at_3.22.54_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988514/Screen_Shot_2017-07-15_at_4.25.04_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988515/Screen_Shot_2017-07-15_at_4.25.43_AM.png)
Styled Components
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988481/Screen_Shot_2017-07-15_at_3.42.54_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988482/Screen_Shot_2017-07-15_at_3.43.23_AM.png)
Styled Components
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988485/Screen_Shot_2017-07-15_at_3.45.13_AM.png)
Styled Components
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988488/Screen_Shot_2017-07-15_at_3.49.48_AM.png)
Styled Components
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988489/Screen_Shot_2017-07-15_at_3.52.04_AM.png)
Styled Components
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988490/Screen_Shot_2017-07-15_at_3.55.07_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988493/Screen_Shot_2017-07-15_at_3.58.22_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988507/Screen_Shot_2017-07-15_at_4.15.55_AM.png)
Styled Components
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988496/Screen_Shot_2017-07-15_at_4.04.51_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988497/Screen_Shot_2017-07-15_at_4.04.56_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988517/Screen_Shot_2017-07-15_at_4.28.53_AM.png)
Cual debería usar ?
Cual debería usar ?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/151816/images/3988503/Screen_Shot_2017-07-15_at_4.10.11_AM.png)
Gracias!
Preguntas ?
Styling ReactJs
By Isaac Luis Mori Guerra
Styling ReactJs
- 218