home - posts - about - twitter - rss - search

Style Markdown with Tailwind CSS

tailwind
  1. Install @tailwindcss/typography from the project directory
npm install @tailwindcss/typography
  1. Add the plugin to the Tailwind config
// tailwind.config.js
module.exports = {
  content: [
    // ...   
  ],
  theme: {
    // ...
  },
  plugins: [
    require('@tailwindcss/typography'),
    // ...
  ],
}
  1. Wrap the HTML content generated by markdown using the prose class
<div class="prose">
	// HTML generated by markdown
</div>
  1. To further configure the styling, use the extend option in the Tailwind config file
module.exports: {
  theme: {
    extend: {
      typography: {
        excerpt: {
          css: {
            p: {
              fontFamily: `${theme('fontFamily.display')}`,
              fontSize: theme('fontSize.2xl'),
              lineHeight: theme('lineHeight.8'),
            }
          }
        },
      },
    },
  },
}