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: README.md
+13-58
Original file line number
Diff line number
Diff line change
@@ -33,73 +33,28 @@ import {
33
33
34
34
### Styling
35
35
36
-
This project uses [emotion] to generate static CSS for most component styles, but still relies on [Primer CSS] for some classname-based styles that haven't yet been ported over.
36
+
This project uses [emotion] to generate static CSS for most component styles, but still relies on [Primer CSS] for some classname-based styles that haven't yet been ported over. Components that haven't yet been ported over rely on [a subset of Primer CSS](https://github.com/primer/components/blob/master/src/primer-components.scss) that's globally injected at import time.
37
37
38
-
To ensure proper styling of all Primer components, you'll need to include some static CSS that's distributed with the `@primer/components` npm package in `dist/primer-components.css`.
38
+
#### Base styles
39
39
40
-
#### JavaScript bundlers
41
-
If you're using a JavaScript bundler that supports CSS imports, you can import it in your bundles directly:
42
-
43
-
```js
44
-
import'@primer/components/dist/css/build.css'
45
-
```
46
-
47
-
If you're using webpack, you will need to install [style-loader](https://github.com/webpack-contrib/style-loader) and configure webpack to use it for imports ending in '.css', e.g.
48
-
49
-
```js
50
-
{
51
-
module: {
52
-
rules: [
53
-
{
54
-
test:/\.css$/,
55
-
use:'style-loader'
56
-
}
57
-
]
58
-
}
59
-
}
60
-
```
61
-
62
-
#### Server inlining
63
-
If you run a Node server, you can read the file from disk at startup:
40
+
You can establish base Primer styles for your app by wrapping all of your Primer components in `<BaseStyles>`:
For fully static or statically generated (Jekyll, Hugo, etc.) apps, you may need to manually copy `node_modules/@primer/components/dist/css/build.css` (after `npm install --save @primer/components`) to one of your site's public directories, i.e. `/assets`:
This will set the `color`, `font-family`, and `line-height` CSS properties to the same ones used in [primer-base](https://github.com/primer/primer/blob/master/modules/primer-base/lib/base.scss#L15).
101
56
102
-
Some Primer components rendered client-side may produce a [flash of unstyled content]. You can avoid most jarring flashes by ensuring that `primer-components.css` is either inlined or linked in the `<head>` of your document with one of the techniques described above.
57
+
#### Static CSS rendering
103
58
104
59
If you're rendering React components both server-side _and_ client-side, we suggest following [Emotion's server-side rendering instructions](https://emotion.sh/docs/ssr) to avoid the flash of unstyled content for server-rendered components. This repo's [documentation template component](https://github.com/primer/components/blob/master/pages/_document.js) demonstrates how to do this in [Next.js].
0 commit comments