Is there a plan for resolveConfig
in Tailwind 4?
#14764
Replies: 10 comments 11 replies
-
Most of those use cases are covered now by being able to just reference the CSS variables we create for you! Do you have a specific use case where you can't just reference the CSS variables in your JS? |
Beta Was this translation helpful? Give feedback.
-
Hello, I would ask that the tailwind team please consider leaving Here is one such example: That is a CLI I made to generate flutter code from tailwind and it's awesome because it means the web apps and mobile apps can share the same design system values even though they are written in different languages. I actually have multiple projects in production that rely on this CLI, and I would really not prefer to have to lock them to tailwind v3 in order to have this kind of cross language codegen. Also I'm not saying that I need everything to behave exactly the same. I don't mind refactoring to support v4 as long as I can reproduce similar behavior which is: "Use tailwind to define a centralized design system and then being able to generate code for that design system in ____ languages." I know that my use-case is not the standard, but I hope it at least illustrates some of the value that exposing this sort of functionality provides. By making the internal config / design system accessible in code it allows for extensions in all sorts of places. |
Beta Was this translation helpful? Give feedback.
-
Any news on this. Its is needed if you want to create styleguide, or apps around TW |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
This is a friction point for design systems that relied on tailwind.config.ts being the source of truth. Is this something that the Tailwind team would consider adding in the near future (extracting values from the css config) or should we make our own css config parser/resolver? |
Beta Was this translation helpful? Give feedback.
-
I really need to access the theme screen breakpoints, which decides in my app what components to show here and there... Example: import resolveConfig from 'tailwindcss/resolveConfig'
import tailwindConfig from '/tailwind.config.js'
const fullConfig = resolveConfig(tailwindConfig)
onBeforeRouteLeave((to, from) => {
if (window.innerWidth < parseInt(fullConfig.theme.screens.md)) {
store.main.showMenu = false
}
}) Another use case <div class="flex justify-evenly items-top gap-2 w-full">
<template v-if="windowWidth >= parseInt(fullConfig.theme.screens['2xl'])">
<FilterSearch />
<FilterDeveloper />
<FilterTag />
<FilterFormat />
<FilterPrice />
<FilterLicense />
<FilterRating />
<FilterCollection />
<FilterSort />
<FilterQuantity />
</template>
<template v-else-if="windowWidth >= parseInt(fullConfig.theme.screens.lg)">
<FilterSearch />
<FilterDeveloper />
<FilterTag />
<FilterFormat />
<FilterQuantity />
</template>
<template v-else>
<FilterQuantity canToggleFilter="true" />
</template>
</div> ...I ported my whole app to Tailwind last year, sure hopes this can be resolved somehow! Thanks :) |
Beta Was this translation helpful? Give feedback.
-
In case anyone else got here like I did, I thought I needed resolveConfig in order to just access the tailwind colors. It turns out I can just do this: import colors from 'tailwindcss/colors' |
Beta Was this translation helpful? Give feedback.
-
I did some digging myself... The tailwindcss npm package exposes a bunch of things, and I had to brute-force to find the breakpoints.. $ cat node_modules/tailwindcss/package.json
...
"exports": {
".": {
"types": "./dist/lib.d.mts",
"style": "./index.css",
"require": "./dist/lib.js",
"import": "./dist/lib.mjs"
},
"./plugin": {
"require": "./dist/plugin.js",
"import": "./dist/plugin.mjs"
},
"./plugin.js": {
"require": "./dist/plugin.js",
"import": "./dist/plugin.mjs"
},
"./defaultTheme": {
"require": "./dist/default-theme.js",
"import": "./dist/default-theme.mjs"
},
"./defaultTheme.js": {
"require": "./dist/default-theme.js",
"import": "./dist/default-theme.mjs"
},
"./colors": {
"require": "./dist/colors.js",
"import": "./dist/colors.mjs"
},
"./colors.js": {
"require": "./dist/colors.js",
"import": "./dist/colors.mjs"
},
"./lib/util/flattenColorPalette": {
"require": "./dist/flatten-color-palette.js",
"import": "./dist/flatten-color-palette.mjs"
},
"./lib/util/flattenColorPalette.js": {
"require": "./dist/flatten-color-palette.js",
"import": "./dist/flatten-color-palette.mjs"
},
... Then you can do this import defaultTheme from 'tailwindcss/defaultTheme'
console.log('defaultTheme', defaultTheme)
console.log('defaultTheme.screens', defaultTheme.screens) Which will give you this defaultTheme.screens
Object { sm: "40rem", md: "48rem", lg: "64rem", xl: "80rem", 2xl: "96rem" } Then you can do something like this // util.js
import defaultTheme from 'tailwindcss/defaultTheme'
export const breakpoints = {}
for (const prop in defaultTheme.screens) {
const px = parseInt(defaultTheme.screens[prop].replace('rem', '')) * 16
breakpoints[prop] = px
}
// Usage
import { breakpoints } from '@/util' And you get the breakpoints as they used to be.. https://tailwindcss.com/docs/responsive-design#overview Hopefully this can be helpfull to someone... |
Beta Was this translation helpful? Give feedback.
-
Shame this was removed. I relied on this for integration with Mantine and charting libraries. It was really nice for grabbing color ranges as an array. Would love to see this added back or a library to replace the functionality. I'll have to write one but it probably won't be complete enough to open source. |
Beta Was this translation helpful? Give feedback.
-
Why remove something that is a legit way of doing things? |
Beta Was this translation helpful? Give feedback.
-
With Tailwind 4's CSS-first configuration approach, I would assume that this means the ability to reference values in JavaScript using the built-in
resolveConfig
function will no longer be possible? Has this been confirmed at all? Have any alternative solutions been discussed, or will it simply no longer be possible?Beta Was this translation helpful? Give feedback.
All reactions