-
Notifications
You must be signed in to change notification settings - Fork 286
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
docs: update for Tailwind 4 #372
Comments
This is what I used in src/app/globals.css
WARNING It is possible this can work using @import may work instead of @plugin but I have not tried yet. See tw docs |
@gene-git thank you for that. It also works with
Using |
It may also be helpful to include some details on customizing since the docs talk all about using the JS config file instead of theme. For example, what's the best way to set the colors to Slate or Zinc? |
There's zero information I can find for plugin developers about how to support v4. It feels like they were in such a hurry to release it, that pretty simple questions never got answered. |
Also wondering why there is no mention of typography and other plugsins here or in the upgrade guide. |
I always renamed it to |
Hopefully they'll offer a CSS stylesheet with the correct utility class definitions. You can also generate a style sheet via postcss manually - but it won't have the utility class settings via A bit like @victorelgersma has done here... https://github.com/victorelgersma/tailwind-typography-stylesheet (although |
I can also see some mention of typography but I'm not sure if this is how we configure the styles in tailwind typography: |
@nickjj I think for the postcss you need to add that configuration to the postcss config file.. {
"plugins": {
"@tailwindcss/postcss": {}
}
} see: https://tailwindcss.com/docs/installation/framework-guides/angular, this is where I got the reference form. |
I recently upgraded Tailwind v3 to v4 and use I confirm the use of @plugin "@tailwindcss/typography" ; in your main css file and I looked for a good solution to customize the plugin's theme and finally tried something like this: /* Typography plugin */
@utility prose {
--tw-prose-body: var(--color-primary);
--tw-prose-headings: var(--color-primary);
--tw-prose-bold: var(--color-primary);
--tw-prose-quote-borders: var(--color-slate-300);
--tw-prose-quotes: var(--color-muted-foreground);
--tw-prose-code: var(--color-primary);
code {
&::before,
&::after {
display : none ;
}
text-wrap : nowrap ;
}
blockquote {
font-weight : 400 ;
}
} note, all my custom |
In my current tailwind v3 setup I disable some the typography options. Anyone have any ideas how to this in v4 "natively"? const disabledCss = {
'code::before': false,
'code::after': false,
'blockquote p:first-of-type::before': false,
'blockquote p:last-of-type::after': false,
pre: false,
code: false,
'pre code': false,
} |
Not possible, you have to override the utility layer yourself in v4 as of now. |
@Utility prose {} isn't working my me, instead, i had to put it in the theme file: @theme { --aspect-landscape: 36 / 17; --font-sans: 'Sora Variable'; --tw-prose-bullets: var(--colors-limeGreen); |
I am finding this works to disable some of the things i was trying to disable (see my previous question): /*
Typography plugin configuration
*/
@utility prose {
code {
&::before,
&::after {
display: none;
}
}
blockquote {
/* Remove extra quotes */
p {
&:first-of-type::before,
&:last-of-type::after {
display: none;
}
}
}
} |
if you are truly capitalizing "Utility" that could be the issue. |
Yeah, this plugin not having proper support in v4 is what's holding me back from upgrading to v4. |
What about this in TW4?
|
In a tweet from @adamwathan a few moments ago: "[No official update yet] Not yet, it works with v4 as-is but you need to use a JS config if you want to customize it. Hoping to do a CSS-only version in the near-ish future once we’re caught up on bug fixes and stuff." |
I think is is incorrect because the js config doesn't work with typography in v4 |
@KorigamiK Do you mind to clarify/put together a repro what part is not working? I would expect a config file like this loaded via |
Since there was some confusion on how to use the typography plugin together with Tailwind CSS v4 and the JavaScript-based configuration (as opposed to CSS based overwrites that were already discussed in this thread), I went ahead and created a small Vite project to show you how such a setup can look like: https://github.com/philipp-spiess/tw4-typography-plugin-config/blob/main/src/tailwind.config.js The main change is to load the typography plugin via an @import "tailwindcss";
- @plugin "@tailwindcss/typography";
+ @config "./tailwind.config.js"; And then have a /** @type {import('tailwindcss').Config} */
module.exports = {
theme: {
extend: {
typography: (theme) => ({
DEFAULT: {
css: {
color: theme("--color-neutral-700"),
a: {
color: theme("--color-sky-600"),
"&:hover": {
color: theme("--color-sky-800"),
},
},
},
},
}),
},
},
plugins: [require("@tailwindcss/typography")],
}; I'll also go ahead and update the project REAMDE to make this clearer on Monday, sorry for the confusion here for sure! That said if you find any compatibility issues please feel free to reach out here and ask in the meantime. /cc @stijns96 since you asked on how to use this kind of setup above 👍 Edit: I want to add that we certainly want to improve this and allow all extended configurations that currently require the JavaScript API to be accessible via CSS only. We're already evaluating internal prototypes for this so hopefully we can get rid of the JavaScript API for the typography plugin soon. |
@philipp-spiess can you share the docs for @config directives? I couldn't find them |
@KorigamiK It's mentioned in the docs here: https://tailwindcss.com/docs/functions-and-directives#config-directive you can look up the v3 docs for infos on how the JavaScript interface works. |
Ah I see, although since it is legacy it's not the way we should be configuring it right? |
Hey folks! I pushed an update to the project readme to give better example of how to use and configure the extension with Tailwind CSS v4. Hopefully this addresses all your concerns! |
What version of @tailwindcss/typography are you using?
4.0.0
What version of Node.js are you using?
22.11.0
What browser are you using?
Chrome
What operating system are you using?
Linux
Reproduction repository
https://github.com/tailwindlabs/tailwindcss-typography
Describe your issue
The readme here says
Then add the plugin to your tailwind.config.js file
, but runningpnpx @tailwindcss/upgrade@next
as instructed in https://tailwindcss.com/docs/upgrade-guide#using-the-upgrade-tool removed mytailwind.config.js
file. The upgrade guide doesn't make any mention of plugins. The readme here doesn't specify if this plugin works with Tailwind 3 and/or 4The docs for the other plugins such as forms and container queries need to be updated as well
The text was updated successfully, but these errors were encountered: