2

I am trying to integrate React Grid Layout in my Next.js application. As part of the installation process, they have said, include the following stylesheet in my application:

/node_modules/react-grid-layout/css/styles.css
/node_modules/react-resizable/css/styles.css

How do I go about doing this?

0

3 Answers 3

4

I haven't used this library myself, but normally to import css you would just import the file at the top of the module where you want to use it, and then you don't have to do anything else with it.

Assuming your App file is directly under src, if I was you I'd try importing those files at the top of App with:

import '../node_modules/react-grid-layout/css/styles.css'
import '../node_modules/react-resizable/css/styles.css'
Sign up to request clarification or add additional context in comments.

Comments

1

Well, actually they are not CSS modules and they are common CSS files, so you can simply import them into your root file (App.js or index.js) with ECMAscript module like this:

import '../node_modules/react-grid-layout/css/styles.css';
import '../node_modules/react-resizable/css/styles.css';

Comments

1

While @SMAKSS's answer is correct, I want to point out that there will be a new update from Next.js to support importing CSS from 3rd party libraries. It is still on the canary branch at the time of this post is submitted.

Example

// components/MySlider.tsx
import { Slider } from "@reach/slider";
import "@reach/slider/styles.css";

function Example() {
  return <Slider min={0} max={200} step={10} />;
}

https://github.com/vercel/next.js/pull/16993

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.