Avoid This Tailwind Mistake (Dynamic Classes)

  Рет қаралды 23,760

ByteGrad

ByteGrad

Күн бұрын

Пікірлер: 59
@ByteGrad
@ByteGrad 8 ай бұрын
My Professional React & Next.js course is OUT NOW now! Find it here: bytegrad.com/courses/professional-react-nextjs -- this is the #1 resource to master the latest React & Next.js, my absolute best work.
@webdev_telugu
@webdev_telugu Жыл бұрын
He is the best in addressing all the issues that we run into while using React and Next
@MrAbbo11
@MrAbbo11 7 ай бұрын
I literally lost my mind over this yesterday. Thank you for this!!!!!!!! I tried to chatgpt my way out of this and literally spent 2 hours on it. That was the end of my coding session yesterday, I was raging so hard I just couldn't continue.
@alexandrmeyer
@alexandrmeyer 2 ай бұрын
The best explanation I have ever seen. I know about the issue for a while, but just now I understood why
@agustintorres2904
@agustintorres2904 7 ай бұрын
THANKS YOU SO MUCH IT WAS THE SAFELIST I HAD THIS ERROR FOR 3 HOURS THANKS YOU SO MUCH
@bilalch898
@bilalch898 Жыл бұрын
That's the only thing I hate about tw.
@rakagunarto1261
@rakagunarto1261 Жыл бұрын
the alternative is sending the entirety of tailwind CSS on page load, which is terrible.
@bilalch898
@bilalch898 Жыл бұрын
@@rakagunarto1261 na you can use tailwind CDN. It can handle dynamic classes.
@rakagunarto1261
@rakagunarto1261 Жыл бұрын
@@bilalch898 yeah that's sending the entirety of tailwind CSS, all 2000kb of it, which is terrible.
@bilalch898
@bilalch898 Жыл бұрын
@@rakagunarto1261 nope, CDN doesn't ship code to your build.
@alexm9104
@alexm9104 Жыл бұрын
@@bilalch898 it does. You can optimize your build with command "npx tailwindcss -o build.css --minify". But I think this option is not available if you use TW CDN.
@samwise8731
@samwise8731 6 ай бұрын
another option is using the syle attribute. Get hex code of corresponding tailwind class, and use it in style like
@crasite
@crasite Жыл бұрын
Some best practice is to use class-variance-authority with twMerge. That's basically how shadcn style their component.
@ayanonlinee
@ayanonlinee 25 күн бұрын
ohh finally I got the issue 😅 Thanks man
@maxzakh
@maxzakh 4 ай бұрын
Great explanation, was giving me a headache
@anj000
@anj000 Жыл бұрын
Ok... 2:24 WTF
@ByteGrad
@ByteGrad Жыл бұрын
Its crazy
@piush787
@piush787 9 ай бұрын
Can't believe this.. An eye opener.
@abbashali01
@abbashali01 Жыл бұрын
I was searching something for the exact problem where I had some color coming from an api and wanted the background of some cards to change according to the color. But it just wasn't happening and I was incredibly frustrated because of it and left the project midway. Thanks for the video. Now I can work on that project again
@TadjhBrooks
@TadjhBrooks Жыл бұрын
For that use case try setting the hex color directly in the html style param
@Furki4_4
@Furki4_4 Жыл бұрын
Thank you very much for your cristal clear explanation
@jawyor-k3t
@jawyor-k3t Жыл бұрын
damn this channel is a gold mine. thanks
@samirneupane7563
@samirneupane7563 5 ай бұрын
you save my day
@anonymous_dev9472
@anonymous_dev9472 10 ай бұрын
Amazing content 🤩
@aymenbachiri-yh2hd
@aymenbachiri-yh2hd 4 ай бұрын
THanks so much for the video, it was so helpful
@prateekpradhan80
@prateekpradhan80 7 ай бұрын
i am trying to resolve this use from two days... thank you
@cyb3ristic
@cyb3ristic Жыл бұрын
I remember having to set left margins dynamically, so I made a script which generates ml-[1px] to ml-[10000px] just so that I can reference any of them dynamically.. no idea if it was the best way to handle it but it worked.
@suzanne_atkinson
@suzanne_atkinson Жыл бұрын
good to hear, I'm thinking of a similar solution..3600 classes to represent every minute of the day...
@PROJECTJMUSIC
@PROJECTJMUSIC Жыл бұрын
Super helpful!
@sarojregmi200
@sarojregmi200 Жыл бұрын
great video, thanks.
@will_zzy
@will_zzy Жыл бұрын
So, is there a less verbose workaround for the breakpoint situation other than creating class name variables in advance? Can’t believe no one has created a simple solution to this common situation.
@TravisHi_YT
@TravisHi_YT Жыл бұрын
They have, it's called CSS
@rockNbrain
@rockNbrain Жыл бұрын
Tks bro, I've just face this in a couple days ago LOL😂
@daniwalasy6654
@daniwalasy6654 9 ай бұрын
thanks it was usefull
@abhinasregmi9742
@abhinasregmi9742 8 ай бұрын
wow 😮 Had troubles because of this now i now how to solve em
@blueflaregamerz4375
@blueflaregamerz4375 4 ай бұрын
thanks that was helpfull
@rakib17874
@rakib17874 3 ай бұрын
what kind of voodo magic is this ?
@allenwang3464
@allenwang3464 Жыл бұрын
Hi, Im curious about how to implement the 'md' function writing multiple times the same prefix so annoying, thx
@yaldakarimi-l7y
@yaldakarimi-l7y Жыл бұрын
Thanks for the great content but what if we have sth like a color picker in our app and based on the color that user chooses we wanna store that hex value and then use it in another component as the background color, we would need sth like this: bg-${[color]} but this doesn't work either. that's an issue that I have,
@abulazaiemabas5070
@abulazaiemabas5070 Жыл бұрын
This y i stopped using tw, u cant conditionally render classnames
@amanrubey
@amanrubey 9 ай бұрын
isn't it problematic that any of the text present in p , h1 tag etc can change the css?!
@revadoniaprilio7709
@revadoniaprilio7709 Жыл бұрын
I have a dumb classes like this, its dynamically because depth is the depth of recursive function for access an object. Do you have any idea?
@yourDecisi0n
@yourDecisi0n 9 ай бұрын
You could set a CSS variable for your padding and use the variable inside your tailwind class
@imjusthereforlolz
@imjusthereforlolz Жыл бұрын
@4:50, how do you make sure the TW classes in those objects are in the proper order when passed into TW?
@Maximiliano-u4l
@Maximiliano-u4l Жыл бұрын
That's the Neat Part, You Don't
@yohendryy
@yohendryy 6 ай бұрын
Interpolación sucks in general, i use maps for that
@ashishboora3049
@ashishboora3049 11 ай бұрын
Is this a good example of "it's not a bug, it's a feature"?
@clololown
@clololown 12 күн бұрын
I hate this about tailwind, makes creating dynamic pattern generation utils impossible. For example, if you have a common string of tailwind utilities, you have to create a static map of it and add it to the content array to be able to use it from an object so you don't have to retype the same patterns all the time (i.e. flex-box classes, responsive spacing, etc) So now, instead of automating mapping patterns using utility functions you have to manually create an object with a string or string array value. If you don't, tailwind ignores your generated strings. How annoying is that? Purging should be more configurable. I want to generate reusable tailwind utilities mapped to a pattern object using utility function. The only option seems to be a custom plugin with your own utilities to create reusable style patterns (basically mixins). Problem is, it's bad practice to use the shorthand tailwind utility classes, you have to write out the actual css using jss . Might as well create stylesheets with layers but then you can't integrate that as well into ts/js components as with cva or tv (I guess css/scss modules would be the way to go but god damn, that's annoying) Do I really have to create a static output of the generated objects and then pull them into tailwind config synchronously for this to work properly? Surprised tailwind doesn't have a way to modify the content purge config
@javascriptes
@javascriptes 8 ай бұрын
Wow
@MushfiqurRahmanCD
@MushfiqurRahmanCD Жыл бұрын
We faced a similar issue where we needed to get the classes from a CMS system. We basically dynamically generated the tailwind config with whitelisted class names.
@suzanne_atkinson
@suzanne_atkinson Жыл бұрын
clever
@bozzhik
@bozzhik 3 ай бұрын
can i see example of your implementation? i have right now same task to do, also to get colors from CMS to have them as tailwind classes
@khalidsaifullahfuad
@khalidsaifullahfuad 16 күн бұрын
Wow I didn't know tailwind parsing engine is this dumb...
@ahjiba
@ahjiba 6 ай бұрын
wow this is so unintuitive
@mrdee734
@mrdee734 Жыл бұрын
This is why tailwind is not good.
@succatash
@succatash Жыл бұрын
And animations are annoying
@lets_see_777
@lets_see_777 10 ай бұрын
this is working for me: bg-${error?"red": "blue"}-600 even when these tokens are not included anywhere
10 Tailwind Classes I Wish I Knew Earlier
13:31
Web Dev Simplified
Рет қаралды 192 М.
Colorful Pasta Painting for Fun Times! 🍝 🎨
00:29
La La Learn
Рет қаралды 308 МЛН
Человек паук уже не тот
00:32
Miracle
Рет қаралды 3,5 МЛН
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 35 МЛН
I tricked MrBeast into giving me his channel
00:58
Jesser
Рет қаралды 28 МЛН
TypeScript Generics are EASY once you know this
22:21
ByteGrad
Рет қаралды 141 М.
I WISH I Knew These Tailwind Tips Earlier
9:15
Theo - t3․gg
Рет қаралды 194 М.
Why use Type and not Interface in TypeScript
14:12
ByteGrad
Рет қаралды 212 М.
Why I Pick ShadCN and Tailwind for all my projects
18:53
developedbyed
Рет қаралды 73 М.
18: You Need Tinker Time with Adam Wathan
1:31:07
Mostly Technical
Рет қаралды 1,7 М.
Tailwind-Merge Is Incredibly Useful - And Here's Why!
12:58
simonswiss
Рет қаралды 37 М.
Advanced TailwindCSS Techniques You Have To Know?! [8 concepts]
20:31
My opinion on Angular 18 & React 19
9:47
Maximilian Schwarzmüller
Рет қаралды 62 М.
Colorful Pasta Painting for Fun Times! 🍝 🎨
00:29
La La Learn
Рет қаралды 308 МЛН