Skip to content

How can I efficiently customize Tailwind CSS’s typography utilities to support both light and dark modes without repeating too much configuration? #18747

Answered by wongjn
PatrickMeirelles asked this question in Help
Discussion options

You must be logged in to vote

The .dark would only work if you have dark class set as the dark mode selector. Furthermore, the theme() function with dot syntax is deprecated in v4. Also, the :root and .dark rules here would never actually apply since they would be overridden by the .prose class rule itself later on anyway.

You don't actually need the .dark rule if you utilize the --tw-prose-invert CSS variables. As per the docs:

/** @type {import('tailwindcss').Config} */
module.exports = {
  theme: {
    extend: {
      typography: ({ theme }) => ({
        DEFAULT: {
          css: {
            --tw-prose-body: theme(colors.slate.700);
            --tw-prose-headings: theme(colors.slate.900);
            --tw-prose-l…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wongjn
Comment options

wongjn Aug 17, 2025
Collaborator

Answer selected by PatrickMeirelles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants