-
|
Suppose I have a plugin that adds utility classes for font sizes: module.exports = plugin.withOptions((opts) => {
return ({ addUtilities }) => {
const sizes = {
"fluid-0": { fontSize: '<somevalue>' },
"fluid-1": { fontSize: '<somevalue>' }
}
addUtilities(sizes)
}
})Now, I can reference them inside my css like: @layer components {
.btn {
@apply fluid-0;
}
}But how can I access them using the module.exports = {
// ... other config
extend: {
typography: (theme) => ({
DEFAULT: {
css: {
fontSize: theme(/* <how should I access them utilties here? */>)
}
}
})
}
}Should I have to change something inside my plugin? Is there a way to add those utilities inside the default |
Beta Was this translation helpful? Give feedback.
Answered by
schardev
May 8, 2023
Replies: 1 comment 3 replies
-
|
You could look at creating "dynamic" utility classes, where the values are pulled from the module.exports = plugin(({ matchUtilities, theme }) => {
matchUtilities(
{ fluid: value => ({ fontSize: value }) },
{ values: theme('fluidFontSizes') },
);
});module.exports = {
theme: {
// Could also go in extend or be in the plugin's
// default values.
fluidFontSizes: {
1: '<somevalue>',
2: '<somevalue>',
},
extend: {
typography: ({ theme }) => ({
DEFAULT: {
css: {
fontSize: theme('fluidFontSizes.1'),
},
},
}),
},
},
// …
}; |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@wongjn I think I misinterpreted your answer. I got it working like I wanted it to be with:
I think the docs doesn't make the behaviour pretty clear but I got it right after tinkering with it.