Home > Enterprise >  Next.js module css multiple class name
Next.js module css multiple class name

Time:10-10

I am using Next.js and module.css in a project. But I have a problem. I have a "button" component inside a component. I want to give both normal className and Style.myClass to that button component. is there a way to do this?

Sorry the question might be a bit complicated, you can understand better with the example below

<Button className={(Style.MyModuleCssClass, "my-global-class")}
        size={"large"}
        type="primary"> GET MORE
</Button>

can I write a code like this? ie one global class name and one module.css class name

CodePudding user response:

Multiple classname is not a problem, but normally you need to put the classname together like a string operation.

  <Button className={`${Style.MyModuleCssClass} my-global-class`} />

Unless you have a library to help you, https://github.com/JedWatson/classnames#readme

  • Related