Skip to content

Commit ffcf1dd

Browse files
committed
section about class name generator
1 parent 4d815aa commit ffcf1dd

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

docs/react-jss.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Benefits compared to using the core JSS package directly:
2323
- [Accessing the theme inside the styled component](#accessing-the-theme-inside-the-styled-component)
2424
- [Accessing the theme without styles](#accessing-the-theme-without-styles)
2525
- [Using custom Theming Context](#using-custom-theming-context)
26+
- [Class name generator options](#class-name-generator-options)
2627
- [Server-side rendering](#server-side-rendering)
2728
- [React tree traversing](#react-tree-traversing)
2829
- [Custom setup](#custom-setup)
@@ -320,6 +321,29 @@ const App = () => (
320321
)
321322
```
322323

324+
## Class name generator options
325+
326+
Make sure using the same setup on the server and on the client. Id generator is used for class names and for keyframes.
327+
328+
1. You can change the class name generation algorithm by passing your custom [generator function](./jss-api.md#generate-your-class-names) prop.
329+
330+
```javascript
331+
const generateId = (rule, sheet) => 'some-id'
332+
<JssProvider generateId={generateId}>
333+
<MyApp />
334+
</JssProvider>
335+
```
336+
337+
1. You can add an additional prefix to each class, [see here](#multi-tree-setup).
338+
339+
1. You can minify class names by passing id options, so that prefixes will not be used even if defined, [see also](./jss-api.md#minify-selectors).
340+
341+
```javascript
342+
<JssProvider id={{minify: true}}>
343+
<MyApp />
344+
</JssProvider>
345+
```
346+
323347
## Server-side rendering
324348

325349
After the application is mounted, you should remove the style tag used by critical CSS rendered server-side.

0 commit comments

Comments
 (0)