Skip to content

Use next/font in chakra ui? #7235

Answered by ikoif
fuma-nama asked this question in Q&A
Jan 13, 2023 · 3 comments · 7 replies
Discussion options

You must be logged in to vote

@SonMooSans you can do something like this:
pages/_app.tsx

import { Montserrat } from '@next/font/google'
import type { AppProps } from 'next/app'
import { ChakraProvider, Text } from '@chakra-ui/react'
import { extendTheme } from '@chakra-ui/react'

const montserrat = Montserrat({ subsets: [ 'cyrillic' ] })
const theme = extendTheme({
  fonts: {
    montserrat: montserrat.style.fontFamily,
  },
})

function MyApp({ Component, pageProps }: AppProps) {
  return (
    <ChakraProvider theme={theme}>
      <Text fontFamily='montserrat'>I am Montserrat</Text>
      <Component {...pageProps} />
    </ChakraProvider>
  )
}

export default MyApp

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@KubaZachacz
Comment options

@Adamec19
Comment options

Answer selected by fuma-nama
Comment options

You must be logged in to vote
5 replies
@Adamec19
Comment options

@riceboyler
Comment options

@pepijnvandenhoven
Comment options

@riceboyler
Comment options

@Naoto-Ida
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
9 participants