3

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

1 Answer 1

8

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

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.