File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
docs/data/material/experimental-api/classname-generator Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -124,16 +124,36 @@ Always create an initializer file to hoist the `ClassNameGenerator` call to the
124
124
125
125
``` js
126
126
// create a new file called `MuiClassNameSetup.js` at the root or src folder.
127
+ ' use client' ; // remove this line if you are not using React Server Components
127
128
import { unstable_ClassNameGenerator as ClassNameGenerator } from ' @mui/material/className' ;
128
129
129
130
ClassNameGenerator .configure (
130
131
// Do something with the componentName
131
132
(componentName ) => componentName,
132
133
);
134
+
135
+ export default null ;
133
136
```
134
137
135
138
Then import the file in the main JavaScript source based on the framework.
136
139
140
+ ### Next.js App Router
141
+
142
+ Add the ` 'use client' ` directive and import the initializer in ` /app/page.js ` .
143
+
144
+ ``` diff
145
+ + 'use client';
146
+ + import './MuiClassNameSetup';
147
+ import * as React from 'react';
148
+ import Button from '@mui/material/Button';
149
+
150
+ export default function Page() {
151
+ return (
152
+ <Button>Text</Button>
153
+ );
154
+ }
155
+ ```
156
+
137
157
### Next.js Pages Router
138
158
139
159
Import the initializer in ` /pages/_app.js ` .
You can’t perform that action at this time.
0 commit comments