1

I am building a site with Next.js and Tailwind and wanted to know if there is any way you can use Tailwind CSS classes along with Next.js classes. For example:

<img src={user.picture} className="rounded"{styles.pfp}></img>

or perhaps something like

<img src={user.picture} className=`rounded{styles.pfp}`></img>

Is there any way to do that? Do let me know if there is.

1 Answer 1

2

Yes, the way to do it would be like this:

<img src={user.picture} className={`rounded ${styles.pfp}`}></img>

with rounded being the Tailwind class and styles.pfp being your class.

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

1 Comment

Unless the styles.pfp variables are defined before tailwind builds its classes, it won't work. For that kind of scenario, safelisting should be used.

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.