-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dark Mode #69
Comments
I followed @stefanzweifel's article https://stefanzweifel.io/posts/2020/07/20/add-dark-mode-support-to-at-tailwindcsstypography/. Instead of adding a |
Hi, @pspeter3 do you think you could share your dark variant config of your |
@dkast Author of that blog post here. Here's an example Light settings go to module.exports = {
theme: {
typography: (theme) => ({
default: {
css: {
color: theme('colors.gray.900'),
a: {
color: theme('colors.blue.500'),
'&:hover': {
color: theme('colors.blue.700'),
},
},
},
},
dark: {
css: {
color: theme('colors.gray.100'),
a: {
color: theme('colors.blue.100'),
'&:hover': {
color: theme('colors.blue.100'),
},
},
},
},
}),
},
plugins: [
require('@tailwindcss/typography')({
modifiers: [],
}),
]
} |
@stefanzweifel awesome, thank you! |
I think as an extension, if you want to use the experimental {
// ...rest of config
variants: {
typography: ["responsive", "dark"]
}
} |
I am curious though what the Tailwind team thinks the right colors for text should be in dark mode. I suspect it will depend on the new color palette as well. |
const defaultTheme = require('tailwindcss/defaultTheme');
module.exports = {
experimental: {
darkModeVariant: true,
},
dark: 'class',
future: {
defaultLineHeights: true,
standardFontWeights: true,
removeDeprecatedGapUtilities: true,
purgeLayersByDefault: true,
},
theme: {
extend: {
colors: {
twitter: '#1DA1F2',
linkedIn: '#2867B2',
github: '#333333',
...defaultTheme.colors,
},
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
},
},
typography: (theme) => ({
dark: {
css: {
color: theme('colors.gray.100'),
a: {
color: theme('colors.blue.100'),
'&:hover': {
color: theme('colors.blue.100'),
},
},
},
},
}),
},
plugins: [
require('@tailwindcss/ui'),
require('@tailwindcss/custom-forms'),
require('@tailwindcss/typography')({
modifiers: [],
}),
],
}; <article
class="prose dark:prose-dark dark:text-gray-100"
>
...
</article> Unfortunately, this doesn't seem to work! I'm using color-mode nuxt module ( https://color-mode.nuxtjs.org/#tailwind-v18 ) |
Same problem here.
is changing colors in light mode nicely (if I change above value), but under Same setup with nuxt and color-mode module. |
okay valid but this is a feature request and a workaround would be
|
Since the dark mode is now GA in 2.0 typography with prose should have a module apart that is configurable and documented on the usage of dark mode with it. |
@vinayakkulkarni @jhull You forgot to enable the variant: variants: {
extend: {
typography: ['dark']
}
}, |
agree that there should be documentation on the subject. I found a good config for 2.0 at the bottom of this closed issue: #94 |
@benji014628 seems like extending typography works when you do DEFAULT uppercase. |
@benji014628 well with TailwindCSS 2.0 you need to do that |
Also came here wondering if tailwind2.0 dark mode support was officially supported with this plugin ? |
Haven't added it by default but it's 100% possible to add with all of the existing options in Tailwind + the plugin. Here's a quick 5 minute version: https://play.tailwindcss.com/xTOjz3kR3m?file=config The steps to do this were:
|
@adamwathan Thank you for providing clear instructions about how it should be done. Based on that, I’ve just opened #122 to address this issue for everyone. |
I have a feeling it wasn't working for me because i didn't have the following imports in CSS @tailwind base;
@tailwind components;
@tailwind utilities; I was hoping to use this only importing the css classes required for typography. |
I got it to work. |
Thank you for all you do. I nearly quit my job and moved into the forest after trying to figure this out. 😅 |
Thank you for the step by step instructions. I feel these steps should be mentioned in README instead of being tucked away in a comment inside this issue. Tailwind lists "dark mode" as core concept and thus the typography plugin should make that core concept easy to adapt. |
Add it to the README so people do not need to find tailwindlabs#69
I added a quick PR for the documentation in case that's helpful @adamwathan |
Just wanted to let everyone know that you can also use Nightwind to easily manage the dark mode in Typography. You can define every single color, or just let it automatically generate a dark mode for you (which should be fine in most cases). |
I've been using the solution proposed by Adam above and it seems to work very well, but today I opened the website in Facebook's embedded browser and the colours were quite wrong. It looks good in every other browser I've tried |
Use Tailwind 2.0's ability to use class-based dark mode. The dark-mode switch comes from: - https://github.com/donavon/use-dark-mode - https://github.com/wKovacs64/gatsby-plugin-use-dark-mode - https://github.com/JoseRFelix/react-toggle-dark-mode To extend tailwind-typography, use the CSS @adamwathan shared in [this comment](tailwindlabs/tailwindcss-typography#69 (comment)).
Use Tailwind 2.0's ability to use class-based dark mode. The dark-mode switch comes from: - https://github.com/donavon/use-dark-mode - https://github.com/wKovacs64/gatsby-plugin-use-dark-mode - https://github.com/JoseRFelix/react-toggle-dark-mode To extend tailwind-typography, use the CSS @adamwathan shared in [this comment](tailwindlabs/tailwindcss-typography#69 (comment)).
How would this work in terms of the new Tailwind 3.0? |
Per #216, I think you use |
Wow, completely missed that. That cut my className length by at least 200 characters 😄, thanks a ton! |
Gonna close this I guess 😅 Enjoy! |
Thanks @adamwathan and the rest of the team! 🎉 There's even a video on how to use it! |
I don't think the |
+1 on that.
|
I've made a separate bug report for the standalone issue: |
Given that the typography sets colors for elements, how should those colors change with the new experimental dark mode?
The text was updated successfully, but these errors were encountered: