I have clean nuxt.js project with Nuxt/Tailwind as styling.
With the configuration below i should be able to use these classes on a div or in postcss with @apply text-testred
and text-testred-dark
.
However, only text-testred-dark
works and not the default value with text-testred
.
Also text-testred-DEFAULT
works, so it's interpreting it wrong, since according to the docs it "DEFAULT" will be ignored and will be used as the default suffix of class.
nuxt.config.js
tailwindcss: {
configPath: '~/tailwind.config.js',
cssPath: '~/assets/css/tailwind.css'
}
tailwind.config.js
module.exports = {
theme: {
fontFamily:{
sans: ["'GT Walsheim Pro'"],
serif: ["'GT Walsheim Pro'"],
mono: ["'GT Walsheim Pro'"],
display: ["'GT Walsheim Pro'"],
body: ["'GT Walsheim Pro'"]
},
colors: {
// Configure your color palette here
transparent: 'transparent',
current: 'currentColor',
testred: {
lightest: '#efdfa4',
lighter: '#f1cb8a',
light: '#f5b575',
DEFAULT: '#f89f68',
dark: '#fb8762',
darker: '#f86e61',
darkest: '#f15764'
},
}
}
tailwind.css
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
body{
@apply text-testred; //doesn't work
@apply text-testred-DEFAULT; //works
}
}
EDIT
With latest version (4.0.2) of @nuxtjs/tailwindcss this works as expected.
Approach: We can set a full-page background color by simply changing the screen height of an HTML body. In Tailwind CSS, we use an alternative of CSS background-color property which is represented as background-color-opacity ( eg: bg-blue-200 ) and it is used to specify the background color of an element.
“Tailwind is only maintainable if you're using components.” I see this a lot and it confuses me — if you're building a site and you have no way to reuse a chunk of HTML without copying and pasting it then it sounds you have much bigger problems to solve?
Using modifiers with custom CSS. Any custom styles you add to Tailwind with @layer will automatically support Tailwind's modifier syntax for handling things like hover states, responsive breakpoints, dark mode, and more. Learn more about how these modifiers work in the Hover, Focus, and Other States documentation.
I had the same issue, and the problem was the tailwindcss version. In fact the Nuxt plugin still uses v1.9.6.
You can try it out here in the tailwind playground.
If you switch to v1.9.6 the DEFAULT doesn't work, and go back to v2.0.2 and it works again.
So the solution would be to upgrade your version like it is suggested on the official docs :
yarn add --dev tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With