@css-bit/tailwind-smart-config
v0.11.0
Published
Smart tailwind configuration modifier
Maintainers
Readme
@css-bit/tailwind-smart-config
Smart tailwind configuration modifier.
Installation
npm install @css-bit/tailwind-smart-config --save-devUsage
Tailwind v3:
import { tailwindSmartConfig } from '@css-bit/tailwind-smart-config';
export default {
plugins: [tailwindSmartConfig()]
};Tailwind v4: tailwindSmartConfig takes nested options, which v4's @plugin
directive cannot express (it only accepts a flat list of declarations), so load
it through the @config directive with a v3-style config file instead.
// tailwind.config.js
import { tailwindSmartConfig } from '@css-bit/tailwind-smart-config';
export default {
plugins: [
tailwindSmartConfig({
spacing: { sm: 10, md: 20 },
unit: 'rpx'
})
]
};/* app.css */
@import 'tailwindcss';
@config '../tailwind.config.js';featureFixing takes no options, so it can go straight into @plugin:
@import 'tailwindcss';
@plugin '@css-bit/tailwind-smart-config/fixing.mjs';Tailwind v4 limitations
These come from v4 itself, not from this plugin:
- Custom
background-sizevalues containing/are not available, e.g.bg-y-2/3andbg-x-1/10. v4 does not extendbackground-sizethrough the theme, and it rejects escaped/inaddUtilitiesselectors. Use v4's own arbitrary values (bg-[length:auto_66.67%]) or switch thedashoption to avoid slashes. Values without a slash (bg-cover,bg-half) work as usual. - Some utilities render differently under v4:
- Negative margins are emitted as
calc(160rpx * -1)instead of-160rpx. Same computed value. border-*also setsborder-style, and the directional utilities (border-land friends) additionally setborder-width: 1px. In v3border-0 border-lleavesborder-width: 0; in v4 theborder-lwins and the result is1px.@applyemits utilities in v4's cascade order rather than in the order they were written, so declarations that override each other can resolve differently.rounded-b-0 rounded-r-lggives a bottom-right radius of10pxin v3 but0in v4.- v4 keeps every declaration while v3's optimiser drops the ones that end up overridden. The computed result is unaffected.
- Negative margins are emitted as
