Created
September 5, 2023 12:29
-
-
Save brainhell/8e3861b7412ec9dcc16f218f9654b194 to your computer and use it in GitHub Desktop.
Adding localfont on NextJS-TwinMacro website
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use client' | |
import { createGlobalStyle } from 'styled-components' | |
import tw, { theme, css, GlobalStyles as BaseStyles } from 'twin.macro' | |
const CustomStyles = createGlobalStyle` | |
@font-face { | |
font-family: 'Lobster'; | |
src: url('fonts/Lobster.woff2') format('woff2'); | |
/* https://styled-components.com/docs/faqs#how-do-i-fix-flickering-text-after-server-side-rendering */ | |
font-display: fallback; | |
} | |
@font-face { | |
font-family: 'Raleway'; | |
src: url('fonts/Raleway.woff2') format('woff2'); | |
/* https://styled-components.com/docs/faqs#how-do-i-fix-flickering-text-after-server-side-rendering */ | |
font-display: fallback; | |
} | |
@font-face { | |
font-family: 'Bricolage'; | |
src: url('fonts/Bricolage.woff2') format('woff2'); | |
/* https://styled-components.com/docs/faqs#how-do-i-fix-flickering-text-after-server-side-rendering */ | |
font-display: fallback; | |
} | |
.lobster{ | |
font-family:"Lobster" | |
text-3xl | |
text-blue-500 | |
} | |
#custom-font{ | |
font-family: 'Raleway' | |
} | |
h1{ | |
font-family: 'Lobster' | |
} | |
h2{ | |
font-family: 'Bricolage' | |
} | |
` | |
const GlobalStyles = () => ( | |
<> | |
<BaseStyles /> | |
<CustomStyles /> | |
</> | |
) | |
export default GlobalStyles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment