0

I am working with nextsjs based project, here in other pages if I load css like this then it works

import css from './cssname.css';

<div className={css.myclass}></div>

but now I am dealing with a lightbox component I need to import css for this, so I this

import "react-popupbox/dist/react-popupbox.css"

css dosen't work in my code. here is my full code which I copy paste from docs first example.

import React ,{Component} from 'react';
import { PopupboxManager, PopupboxContainer } from 'react-popupbox';
import "react-popupbox/dist/react-popupbox.css"

class lightbox extends Component{

    constructor(props){
        super(props)

        this.openPopupbox = this.openPopupbox.bind(this);
    }

    openPopupbox(){
        const content = (
            <div>
              <p>Work like you don't need the money.</p>
              <p>Dance like no one is watching.</p>
              <p>And love like you've never been hurt.</p>
              <span>― Mark Twain</span>
            </div>
          )
          PopupboxManager.open({ content })
    }

    render(){
        return(
            <div> 
                <button onClick={this.openPopupbox}>Click me!</button>
                <PopupboxContainer/>
            </div>
        )
    }
}

export default lightbox
2
  • Change import to import './cssname.css'; and <div className="myclass"></div> Commented Sep 20, 2020 at 15:35
  • @Nithish I follow Docs (github.com/fraina/react-popupbox) but css is not working and doing the same way which you suggest. Commented Sep 20, 2020 at 16:03

1 Answer 1

1

nextJS doesn't allow you to import CSS file expect on pages/_app.js. Create a pages/_app.js file if not already present. Then, import the CSS file. for more check the doc: Built-In CSS Support

Sign up to request clarification or add additional context in comments.

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.