Disable Tailwind on a div or component

Viewed 5748

Is there a way to disable Tailwind's Preflight on a specific div or component? For example a WYSIWYG editor, or wanting to migrate gradually to Tailwind.

4 Answers

As far as i know it will always load the ui if can find similar classes. Some solution can be

  • Reducing its priority from other css, by putting it earlier from other css files in initial load.
  • you can config tailwind.config.js file in a way so that it only generates css that needed
  • wrapping css with extra identifier so that it can't collide with tailwind classes.

I believe the optimal method, if you're using it for basic markdown is to use the the @tailwind/typography package which will allow tags such as <h6> <b> etc...

  1. run npm i @tailwindcss/typography
  2. add require("@tailwindcss/typography") to your plugins in tailwind.config.js
  3. add the className prose prose-lg
<div className="prose prose-lg" dangerouslySetInnerHTML={{ __html: markdownDesc }} />

Found this method in a article here: https://tjaddison.com/blog/2020/08/updating-to-tailwind-typography-to-style-markdown-posts/

Related