@@ -62,30 +62,51 @@ That means pages never load unnecessary code!
...
@@ -62,30 +62,51 @@ That means pages never load unnecessary code!
### CSS
### CSS
We use [glamor](https://github.com/threepointone/glamor) to provide a great built-in solution for CSS isolation and modularization without trading off any CSS features.
#### Built-in CSS support
Glamor's [HowTo](https://github.com/threepointone/glamor/blob/master/docs/howto.md) shows converting various CSS use cases to Glamor. See Glamor's [API docs](https://github.com/threepointone/glamor/blob/master/docs/api.md) for more details.
We bundle [styled-jsx](https://github.com/zeit/styled-jsx) to provide support for isolated scoped CSS. The aim is to support "shadow CSS" resembling of Web Components, which unfortunately [do not support server-rendering and are JS-only](https://github.com/w3c/webcomponents/issues/71).
```jsx
```jsx
importcssfrom'next/css'
exportdefault()=>(
exportdefault()=>(
<divclassName={style}>
<div>
Hello world
Hello world
<p>scoped!</p>
<stylejsx>{`
p {
color: blue;
}
div {
background: red;
}
@media (max-width: 600px) {
div {
background: blue;
}
}
`}</style>
</div>
</div>
)
)
```
conststyle=css({
#### CSS-in-JS
background:'red',
':hover':{
It's possible to use any existing CSS-in-JS solution. The simplest one is inline styles:
background:'gray'
},
```
'@media (max-width: 600px)':{
export default () => (
background:'blue'
<p style={{ color: red }}>hi there</p>
}
)
})
```
```
To use more sophisticated CSS-in-JS solutions, you typically have to implement style flushing for server-side rendering. We enable this by allowing you to define your own [custom `<Document>`](#custom-document) component that wraps each page
The following wiki pages provide examples for some popular styling solutions:
-`glamor` (formerly `next/css`)
-`styled-components`
-`styletron`
-`fela`
### Images and other static files
### Images and other static files
Create a folder called `static` in your project root directory. From your code you can then reference those files with `/static/` URLs, e.g.: `<img src="/static/file-name.jpg" />`.
Create a folder called `static` in your project root directory. From your code you can then reference those files with `/static/` URLs, e.g.: `<img src="/static/file-name.jpg" />`.