-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
PassThough new merging strategy with tailwind-merge to smartly merge classes #4707
Comments
This was implemented in PrimeReact using this PR: primefaces/primereact#5755 It allows for using TailWind Merge properly |
Hi, I modified the mergeProps options to customize the returned pt props using globalPTProps, selfPTProps etc.
Exp;
Best Regards, |
@mertsincan Sorry for poking you but this new custom merge is not working for me:
I added the debugger and console for debugging. Neither is hit, meaning the function wasn't called. Any hints? |
Hi @damms005, thanks a lot for your report! Could you please create a new issue ticket with a sample stackblitz link for this? Thank you! |
@damms005 I know this is closed, but I wanted to help, idk why, but if you merge props first, then classes it works: const customMergeProps = (
globalPTProps: Record<string, any> = {},
selfPTProps: Record<string, any> = {},
datasets: any,
) => {
const merged = mergeProps(globalPTProps, selfPTProps, datasets);
merged.class = twMerge(merged.class as ClassNameValue);
return merged;
};
const primeVueSettings: PrimeVueConfiguration = {
ripple: false,
unstyled: true,
pt,
ptOptions: {
mergeProps: customMergeProps,
},
}; |
Hi @EdvinasBa, thanks a lot for your update! I gave an example based on the link below. |
@mertsincan https://stackblitz.com/edit/ygjjym?file=src%2FApp.vue customMergeProps appears to do nothing in the reproduction, log not happening edit: tested in 4.0.5, now it seems to work! |
@melloware it seems ptOptions overrides the defaults of its descendants: primefaces/primevue-tailwind#320 |
Describe the feature you would like to see added
Use tailwind-merge to smartly merge tailwind classes.
Is your feature request related to a problem?
Currently, if we want to customize the default Tailwind preset with a Custom Preset, we have two options:
usePassThought
, the classes will be concatenated togethermergeProps
The first option will result in duplicated classes and will require us to use
!important
utility by adding a ! character to the beginning of a class if we want to override one class.The second option will result in rewriting all of the classes.
Describe the solution you'd like
Use a third merging strategy "smarter" with
tailwind-merge
that could be the default.We could use the awesome library defu combined with tailwind-merge to smartly merge tailwind classes.
It would look pretty similar to how it's handled in
NuxtUI
, here is the how they currently handle it: https://github.com/nuxt/ui/blob/dev/src/runtime/utils/index.tsHere is an example explained in the
NuxtUI
documentation that uses the equivalent ofpt
withui
: https://ui.nuxt.com/getting-started/theming#ui-propDescribe alternatives you have considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: