vercel / geist-font

https://vercel.com/font
SIL Open Font License 1.1
2.13k stars 54 forks source link

Next 13: Error After Import Geist Font -> SyntaxError: Cannot use import statement outside a module #27

Closed iamdevmarcos closed 8 months ago

iamdevmarcos commented 8 months ago

Font Name (Geist Sans/Geist Mono):

Description of the Issue: A compilation error occurred after installing and importing the Geist font.

Steps to Reproduce:

  1. Install Geist font, using npm i geist
  2. Import GeistSans or GeistMono in the top level at _app.tsx
  3. Use GeistSans.className at <main className="GeistSans.className" />

Screenshots:

Error:

image

My _app.tsx file.

image

Environment (please complete the following information):

Additional Information

Ethaan commented 8 months ago

FYI i noticed the same, but to get this font working i used the localFont like

const geist = localFont({
  src: [
    { path: "../public/fonts/Geist/Geist-Regular.otf", weight: "500" },
    { path: "../public/fonts/Geist/Geist-Medium.otf", weight: "600" },
    { path: "../public/fonts/Geist/Geist-SemiBold.otf", weight: "700" },
    { path: "../public/fonts/Geist/Geist-Bold.otf", weight: "800" },
    { path: "../public/fonts/Geist/Geist-Black.otf", weight: "900" },
  ],
  display: "swap",
  variable: "--font-geist-sans",
  fallback: ["inter"],
});

For those using TailwindCSS

Extend the theme

extend: {
 fontFamily: {
   sans: ['var(--font-geist-sans)'],
 },
}

Then use it

<div className={cn(geist.variable, "font-sans")}>

JohnPhamous commented 8 months ago

Thank for you trying out the font and reporting this. Closing this issue as this is a dupe of #13. We will fix this!