Skip to content

How to import NextJS font and use it for all stories #24456

Closed Answered by valentinpalkovic
alamenai asked this question in Help
Discussion options

You must be logged in to vote

Are you familiar with the concept of having a preview.js file?
In combination with decorators, you can achieve the same like what you are actually doing in your Next.js app.

Something like below should do the trick:

// .storybook/preview.tsx

import React from 'react';

import { Preview } from '@storybook/react';
import { Inter } from "next/font/google"

const inter = Inter({ subsets: ["latin"], weight: ["500", "600", "700", "800", "900"] })

const preview: Preview = {
  decorators: [
    (Story) => (
      <div className={inter.className}>
        <Story />
      </div>
    ),
  ],
};

export default preview;

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alamenai
Comment options

Answer selected by alamenai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants