@@ -113,29 +113,6 @@ export default function RootLayout({
113
113
If you're not using the new ` app/ ` directory, there's no need to add
114
114
the` 'use client'; ` directive add the top of your file.
115
115
116
- ### Chakra UI with Next.js Link
117
-
118
- If you're using Next.js 13, we've provided a ` @chakra-ui/next-js ` package that
119
- gives you a smoother experience when using Chakra UI Link component with
120
- ` next/link ` .
121
-
122
- This package provides the ** Link** which combines the functionality of the
123
- Next.js Link and Chakra UI Link components.
124
-
125
- ``` jsx live=false
126
- // app/page.tsx
127
- ' use client'
128
- import { Link } from ' @chakra-ui/next-js'
129
-
130
- export default function Page () {
131
- return (
132
- < Link href= ' /about' color= ' blue.400' _hover= {{ color: ' blue.500' }}>
133
- About
134
- < / Link>
135
- )
136
- }
137
- ```
138
-
139
116
### Customizing theme
140
117
141
118
If you intend to customise the default theme object to match your design
@@ -223,3 +200,67 @@ TypeScript version of `4.1.0` is required.
223
200
| theme | ` Theme ` | ` @chakra-ui/theme ` | optional custom theme |
224
201
| colorModeManager | ` StorageManager ` | ` localStorageManager ` | manager to persist a users color mode preference in |
225
202
| portalZIndex | ` number ` | ` undefined ` | common z-index to use for ` Portal ` |
203
+
204
+ ### Chakra UI with Next.js Link
205
+
206
+ If you're using Next.js 13, we've provided a ` @chakra-ui/next-js ` package that
207
+ gives you a smoother experience when using Chakra UI Link component with
208
+ ` next/link ` .
209
+
210
+ This package provides the ** Link** which combines the functionality of the
211
+ Next.js Link and Chakra UI Link components.
212
+
213
+ ``` jsx live=false
214
+ // app/page.tsx
215
+ ' use client'
216
+ import { Link } from ' @chakra-ui/next-js'
217
+
218
+ export default function Page () {
219
+ return (
220
+ < Link href= ' /about' color= ' blue.400' _hover= {{ color: ' blue.500' }}>
221
+ About
222
+ < / Link>
223
+ )
224
+ }
225
+ ```
226
+
227
+ ### Chakra UI with next/font
228
+
229
+ With Next.js 13, you can optimize your fonts (including custom fonts) and remove external network requests for improved privacy and performance.
230
+
231
+ To use the new ` next/font ` with Chakra UI globally;
232
+
233
+ ``` jsx live=false
234
+ /* pages/_app.tsx */
235
+ import { Rubik } from ' next/font/google' ;
236
+
237
+ const rubik = Rubik ({ subsets: [' latin' ] });
238
+
239
+ const App = ({ Component, pageProps }: AppProps ) => {
240
+ <>
241
+ < style jsx global >
242
+ {`
243
+ :root {
244
+ --font-rubik: ${ rubik .style .fontFamily } ;
245
+ }
246
+ ` }
247
+ < / style>
248
+ < ChakraProvider theme= {theme}>
249
+ < Component {... pageProps} / >
250
+ < / ChakraProvider>
251
+ < / >
252
+ };
253
+ ```
254
+ Now you can use the optimized font with your custom theme file across the app.
255
+
256
+ ``` jsx live=false
257
+ /* theme.ts */
258
+ export const theme = extendTheme ({
259
+ ...
260
+ fonts: {
261
+ heading: ' var(--font-rubik)' ,
262
+ body: ' var(--font-rubik)' ,
263
+ }
264
+ ...
265
+ });
266
+ ```
0 commit comments