Тёмный

Theming Tailwind with CSS Variables 

Tailwind Labs
Подписаться 93 тыс.
Просмотров 121 тыс.
50% 1

In this video, you'll learn how to build designs that support multiple themes in Tailwind CSS, leveraging the power of CSS variables. We also look at a common "gotcha" you might run into when trying to use color opacity utilities alongside colors defined as variables.
Source code: play.tailwindcss.com/YelhilBeHb

Наука

Опубликовано:

 

16 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 175   
@rfmiotto
@rfmiotto 3 года назад
I was running into this just a couple days ago! What a perfect timing for this tutorial. Thank you Tailwind Labs for these videos. Please, keep coming up with high-quality materials like this.
@jslbrt
@jslbrt 3 года назад
I'm going nuts with Tailwind, I love it.
@TheRafark
@TheRafark 3 года назад
Yeah me two, it’s great
@Allformyequine
@Allformyequine 2 года назад
Ditto!!
@Andrey-il8rh
@Andrey-il8rh 3 года назад
I really like how flexible it is to style not only the full root document but each component individually. I already see how those variables can even be scoped inside the component itself to provide completely different styling rules for each individual component and not only colors, it basically allows for turning Tailwind into an ultimate utility-meta framework where classes become meta-information for a possible look. Requires a bit of a mental stretch in the beginning but gives ultimate powers!
@yashkhd1100
@yashkhd1100 2 года назад
I think your method is best one for implementing dynamic theming with tailwind CSS. I have seen bunch of other approaches but by far this one is cleanest one.
@friemae
@friemae 3 года назад
These videos are really excellent, awesome developer experience!
@user-hn5ie9hx6q
@user-hn5ie9hx6q Год назад
Exploring tailwind and had thoughts few days ago: "How can I use css variables for themes" And today video appeared. Magic! Thanks RU-vid and you guys! Awesome!
@protocode_227
@protocode_227 Год назад
it's spooky sometimes, right 😄
@ulvidamirli2758
@ulvidamirli2758 3 года назад
Perfect tutorial and that’s what I was looking for. Out of topic, but it would be perfect to see web design tutorials from you
@QueeeeenZ
@QueeeeenZ 2 года назад
Perfect, this is exactly what I was looking for! I thought it was not possible to do themes with Tailwind.
@benthomson2406
@benthomson2406 2 года назад
your guys make tailwind CSS custom feature amazing!
@_CazaBobos
@_CazaBobos 2 года назад
I've been looking for this for very long. Thanks! It works amazingly with Next.js SSG Just a little trick: instead of asking if opacityValue is undefined, you can use a nullish coalescence operator to assign a default value when it's null or undefinded. Example... ${ opacityvalue ?? 1 }
@weblearningd2294
@weblearningd2294 Год назад
I can not stop watching your videos, really great!! Thanks a lot!
@addd3231
@addd3231 6 месяцев назад
Very helpful tutorial, few days ago I tried to build my app with custom theme colors, but this is more useful 🤯
@akamfoad
@akamfoad 2 года назад
Will use this video as inspiration to theme my website soon, thanks for the great explanation and approach as always
@faraonch
@faraonch 10 месяцев назад
Fantastic demo! You could consider setting the default transparency value to 1 in function arg where you deconstruct the opacity value to avoid the if statement in the withOpacity.
@SusanthCom
@SusanthCom 3 года назад
Thank you so much ❤️ for this wonderful tutorial. Would love to see more possibilities of theming. Hope we can control more looks like, border radius, background image, polygon shapes, different svg based on theme. It will bring great change in looks apart from colour alone. 👍👍 Keep rocking.
@paawfrance
@paawfrance 2 года назад
Thank you from France, your video is a game changer for me :)
@elie1400
@elie1400 3 года назад
A list of your vscode extensions would be appreciated
@DaniloMarquesdeRezende
@DaniloMarquesdeRezende 3 года назад
Agreed
@eYinka
@eYinka 3 года назад
Honestly +1
@corey5974
@corey5974 3 года назад
I believe the one that highlights the css colors is a plugin called Color Hight (naumovs.color-highlight) by Sergii Naumov
@DanielDrummond2k6
@DanielDrummond2k6 2 года назад
Any one know how extension to convert color Hex to RGBA and vise versa?
@elie1400
@elie1400 2 года назад
@@DanielDrummond2k6 hex-to-rgba by dakshmiglani
@lightningspeed6466
@lightningspeed6466 2 года назад
Thanks it was really helpfull Was trying to figure it out for a long time
@jimmyj.6792
@jimmyj.6792 3 года назад
So awesome 😍😍😍 simple as well with a great quality and some magic final tricks 😁👌🎉🎉
@raymondmichael4987
@raymondmichael4987 2 года назад
This looks heavy and good to be done
@renu3463
@renu3463 3 года назад
Really like this series
@divdax4286
@divdax4286 3 года назад
Love your videos and tailwindcss!
@Andrey-il8rh
@Andrey-il8rh 3 года назад
I've heard this punch from many people who hate (don't know how to use) Tailwind - that it can't be used on a "themeable project", thanks for myth-busting this argument!
@thomassaw
@thomassaw 5 месяцев назад
Thank you so much for this video. Learned a lot!
@Allformyequine
@Allformyequine 2 года назад
... and that is it!! LOL Fantastic and you sometimes make me laugh a little which is a giant bonus; Tailwind really has a gem with you and the way you do these videos! How long did they look to find a coder that is ALSO great in front of a camera lol! Rock on!
@adrian1358
@adrian1358 День назад
Great stuff, a lot of useful info, thank you 😊
@VuNguyen-yj5wi
@VuNguyen-yj5wi 2 года назад
Thank you so much! It's so useful ❤️
@mkroven
@mkroven 3 года назад
Thank u. Wonderful explanation.
@oliverp8006
@oliverp8006 3 года назад
Great one, would be nice to have a follow up part about the best way to add/implement dark mode to the theming
@hoagy_ytfc
@hoagy_ytfc 3 года назад
Yes!
@electrotsmishar
@electrotsmishar 2 года назад
Thank you. Great tutorial
@jnetto
@jnetto 3 года назад
Best teacher ever! Thanks for this tutorial!
@ShinjaeKang
@ShinjaeKang 3 года назад
Good tutorials, Thank you very much :)
@MikeStratton
@MikeStratton 2 года назад
You make it look insanely easy. wait, maybe it is that easy!
@chethannp5981
@chethannp5981 Год назад
The best tutorial ❤
@FauzulChowdhury
@FauzulChowdhury 3 года назад
Superb content. 👏👏👏
@aleksandervitalevich1299
@aleksandervitalevich1299 Месяц назад
«Лёгким движением руки брюки превращаются… брюки превращаются… превращаются брюки… в элегантные шорты!» 👍👍👍
@markconger8049
@markconger8049 3 года назад
Should my brain hurt after watching this? LOL It does. I’m sure I’ll have to watch this series a couple of times through since my CSS skills are so-so. But, that said, I’m very impressed so far with Tailwind’s approach. It seems now we finally have CSS that is a programming language than whatever it was previously.
@justine_chang39
@justine_chang39 2 года назад
this video was awesome
@evanfuture
@evanfuture 3 года назад
Amazing, I love it.
@andreich1980
@andreich1980 3 года назад
Nice video, thank you.
@agnemedia624
@agnemedia624 3 года назад
Thanks for tips, tricks and technics Wow
@dealloc
@dealloc 2 года назад
I would just specify colors for specific states in the theme without the hassle of support bg-opacity, etc. It may seem odd, but if the idea is to give control to the theme of defining colors, then it makes more sense that it also controls the opacity. There are cases where you want to use a different opacity based on the contrast, as color is perceived differently based on the background and foreground contrast and the opacity will look lighter/darker depending on this. This is also why dark themes aren't simply just inverting the colors; contrast matters.
@sinyayadynya
@sinyayadynya 3 года назад
What a masterpiece!
@adamtak3128
@adamtak3128 3 года назад
Is this the theming strategy you suggest we use with the new JIT compiler in tailwindcss?
@TobiasSailer
@TobiasSailer 3 года назад
Curious: is this vscode preview plugin public? Can't find it!
@vesper8
@vesper8 3 года назад
Amazing video! It would really helpful if you could share a gist or repo with the code too... also would love it if you could name a few of the plugins you're using on vscode.. notably the css preview when you hover a class and the one that highlights colors with their actual color. Many thanks!!
@xithalius
@xithalius 3 года назад
Great video!
@AriBahtiar
@AriBahtiar 3 года назад
thiank u.. i am happy with this video.
@amrishpatidar2579
@amrishpatidar2579 2 года назад
great explanation
@Andrey-il8rh
@Andrey-il8rh 3 года назад
Just a small suggestion to make check inside withOpacity more succinct, you can just check for undefined like so opacityValue ?? 1 that way if it will be undefined it will default to 1, note that I'm using nullish coalescing operator here to support 0 values. It's natively supported in Node since v.14
@tamrat_assefa
@tamrat_assefa 3 года назад
This is super cool.
@techie607
@techie607 3 года назад
I am trying to implement tailwind css struggling a lot but feeling confident as well
@jasarwadlow9406
@jasarwadlow9406 3 года назад
Neat! Great video, it's well-explained and very easy to understand. Thanks! I have a question: can we use any existing tailwind colors (ie, text/bg-red-500)? Using the approach in the video, it looks like the same color may be redefined multiple times. aka, is it possible to create something like an Alias Token? Or is the only way to do this via the tailwind config (where we have access to the colors)?
@jasarwadlow9406
@jasarwadlow9406 3 года назад
nvm, I think I found how: --color-fill: theme('colors.red.700');
@neelabhdutta6691
@neelabhdutta6691 2 года назад
I am thinking of using it to implement light/dark theme on user selection, so, do I have to change the wrapper class conditionally or dark:my-wrapper would work just like usual html with dark class ???
@valtism
@valtism 3 года назад
The microphone is so big 🤣 Thanks for the content as always!
@siewierap
@siewierap 3 года назад
I always more appreciate good voice quality than a cam!
@VincentCordel
@VincentCordel 8 месяцев назад
Great tutorial thank you! Quick question: is it possible to use the default tailwind colour palette in the css variables instead of the hex/rgb hardcoded values? In other words, something like: -colour-primary: Colors.red.700 Instead of -colour-primary: rgb(255,179,255)
@myxsys
@myxsys 2 года назад
The opacity function doesn't work in Tailwind CSS v3.0.24. However, returning `var(${variableName})` works without wrapping `rgb` or `rgba`
@dibbyo456
@dibbyo456 3 года назад
This is GOLD
@dorshiff
@dorshiff Год назад
When it came to typography, there are some needed changes in different screen sizes, how do you define them in this method?
@wolfphantom
@wolfphantom 2 года назад
The return value could be streamlined as an implicit return, but I would at least set the default @ 22:00 with ({ opacityValue = 1 }) rather than setting a guard check
@LorenzoLeonardini
@LorenzoLeonardini 2 года назад
I have the feeling (but I could be totally wrong) that opacityValue is not the value itself but the name of the CSS variable for the opacity (--tw-bg-opacity)
@yakovlev_io
@yakovlev_io 2 года назад
@@LorenzoLeonardini you are right, it’s an object destruction syntax { … }
@devhamdani
@devhamdani 10 месяцев назад
Can you tell me that which fonts you're using for your editor. I really love it.
@Martin-4D
@Martin-4D 3 года назад
Wow! That is the business!
@markokraljevic1590
@markokraljevic1590 2 года назад
but what if i want to reuse colors from the palette like --accent-medium: theme('colors.pink.700'); and not hardcoding rgb values? theme('colors.pink.700') is hex value and I need to convert to rgb somewhere
@magnusandersson2495
@magnusandersson2495 3 года назад
Why split and convert the hex code to rgb values in your with opacity function instead of using the vscode plug-in? Javascript has parseint-function that can do this.
@zeroows
@zeroows 2 года назад
Great work, Thank you. 27:05 where did the fly came from :)
@palyanytsia
@palyanytsia 3 года назад
What's the plugin you are to preview colors in css?
@tilakmadichettitheappdeveloper
@tilakmadichettitheappdeveloper 3 года назад
good question ! its in the internet.
@harrygreen1465
@harrygreen1465 Год назад
Great video, thanks! It's a little outdated I think, as you can now define hex colours inside the tailwind config `theme`, and opacity variants will work without needing to add the logic yourself.
@JustinByrne1337
@JustinByrne1337 3 года назад
Does anyone know how to get that preview panel in VSCode I can't find one that looks that good
@chaes1161
@chaes1161 3 года назад
Great! Is there any way to enable color preview using this approach?
@huannguyen6559
@huannguyen6559 2 года назад
You can still use rgb(0,0,0,1) in your css file for color preview but need to remove "rgb" and "alpha" in the "withOpacity" function
@Diamonddrake
@Diamonddrake 3 года назад
Tailwind is love, tailwind is life.
@kohelet910
@kohelet910 2 года назад
Using JS functions into CSS.. so cool
@brianzitzow4411
@brianzitzow4411 3 года назад
Any reason you are using CSS Custom Properties rather than plugins that add the utilities and use theme properties with the values defined directly in the theme?
@codementor3974
@codementor3974 Год назад
i have a problem ,if we set opacity-x for bg-theme-x not only bg opaicty changed even text opacity turn chnaged , what to do in this situation please guide
@visheshpandey2001
@visheshpandey2001 4 месяца назад
14:40 thats amazing!!!!!!!!!!
@iamdavidwparker
@iamdavidwparker 3 года назад
I implemented multiple themes on a site of mine last year. 12 themes light + dark mode. It was super simple, though I _think_ this may be even easier. Can't wait to try it out! Note: not sure why my last comment was deleted? Due to link?
@TailwindLabs
@TailwindLabs 3 года назад
Not sure either, I did see the notification email though originally! We didn’t delete it, must be a RU-vid thing probably link related like you said 🤔
@iamdavidwparker
@iamdavidwparker 3 года назад
@@TailwindLabs probably. Not worried about it. Thanks for the video, the timing is perfect.
@SusanthCom
@SusanthCom 3 года назад
Could you please share your implementation. Would like to learn more about theming ❤️ Thanks 👍in advance
@SusanthCom
@SusanthCom 3 года назад
@david Parker ❤️❤️
@SamAbaasi
@SamAbaasi 2 года назад
Thanks a lot
@helloiamjoshie
@helloiamjoshie 2 года назад
How would one go about setting up border colors this way?
@lcapocer
@lcapocer 2 года назад
When I use Vue-Cli and run a build only the :root theme is inside the generated css file, why is that?
@JimOHalloran
@JimOHalloran 3 года назад
Kinda feels like with naming colours you're getting back into some of the "naming is hard" territory that utilities were meant to solve for us. But I don't see any other way around it. I'm working on my first Tailwind application at the moment which will eventually be forked off and used as the basis for many other apps. How the follow on apps get re-coloured without a massive search and replace to change a whole bunch of utilities was on my mind, so this is well timed.
@hcsftw
@hcsftw 3 года назад
Thank you! Could you provide the code somewhere?
@jameelahamedmca
@jameelahamedmca 2 года назад
Usefull Thanks
@lenartpapez2512
@lenartpapez2512 3 года назад
This looks amazing, but I can't seem to get it to work in a new Angular project (v11.2). Neither with CSS or SCSS. Any news on that?
@g-luu
@g-luu 2 года назад
did you manage to get it working? seems to work on development but not in production
@JohnSmith-zl8rz
@JohnSmith-zl8rz 2 года назад
You only use textColor and backgroundColor, so I need go to each tailwind config and add those again, like "divideColor", "caretColor" etc. ???
@WalterKimaro
@WalterKimaro 3 года назад
So good
@MasudRana-nx4rf
@MasudRana-nx4rf 3 года назад
Awesome.
@MrTrickydisco
@MrTrickydisco 3 года назад
Any chance you could share the code on play.tailwind?
@ray-lee
@ray-lee 3 года назад
how about dark theme? is it just dark:theme-name?
@diego5g
@diego5g 3 года назад
What is your VSCode theme?
@ulrichmbouna4091
@ulrichmbouna4091 3 года назад
About new tailwindcss/jit , i have problemes with postcss 8 in vue 3 project , how can i do please?
@macbruker
@macbruker 3 года назад
Try searching for a similar issue in the tailwindcss/jit github repo. If you don't find an existing issue, you can add one of your own. It could be that you are missing the NODE_ENV=development variable. Instructions for this is in the readme file in the repo.
@joeregan.
@joeregan. 3 года назад
Why doesn't tailwind include classes like primary by default like other popular frameworks like bootstrap and uikit?
@ahmedosama7632
@ahmedosama7632 3 года назад
Make a video on RTL with tailwind
@sushardianto8039
@sushardianto8039 3 года назад
Thank you. Please, share the code link
@QWERTY-mh2hb
@QWERTY-mh2hb 8 месяцев назад
It's possible to do this with React Native?
@JohnSmith-zl8rz
@JohnSmith-zl8rz 2 года назад
text-skin-base is confusing, sounds very close to text-base (size), what about text-skin-content ?
@matthewblott
@matthewblott 3 года назад
Genius :-)
@stctheproducer
@stctheproducer 3 года назад
First comment! 🥳 Thanks for this video 🙏🏾
@Levyndra
@Levyndra Год назад
With new TS config it's problematically to implement such function like ({opacity}) => `blabla` to "colors" section
@nmastroianni
@nmastroianni 8 месяцев назад
I am getting TypeScript errors for the withOpacity function that make me nuts. I had to use a return type of "any" which makes me squirm a little.
@Svish_
@Svish_ 3 года назад
Any reason one you couldn't/shouldn't just define the theme colors as `rgba` and use the text-opacity thing directly? So instead of `--color-fill: 185, 28, 28;` and that `withOpacity` function, just do `--color-fill: rgba(185, 28, 28, var(--tw-text-opacity));`? Not sure I understand what the `opacityValue` and helper function you made does "more", and feel like I'm missing something here. 🤔
@TailwindLabs
@TailwindLabs 3 года назад
Then if you used it for a background color it would adopt the text opacity instead of the background opacity. The variable name changes depending on how the color is used, for example: That uses two different opacity variables, so if you bake it right into the color one of the won't work.
@Svish_
@Svish_ 3 года назад
@@TailwindLabs Aaaah! Knew there had to be something I was missing. Thank you for quick reply! Started using Tailwind for the first time last week on a new side-project of mine and I'm LOVING IT 💙
@bryanltobing
@bryanltobing 2 года назад
what font that you use for your vs code font ?
@josephocampo4968
@josephocampo4968 Год назад
looks like dank mono
@benjaminmaywald660
@benjaminmaywald660 3 месяца назад
Thanks for the whole Playlist ...your microphone is getting bigger with every video ;-)
Далее
I WISH I Knew These Tailwind Tips Earlier
9:15
Просмотров 174 тыс.
10 Tailwind Tricks You NEED To Know!
10:45
Просмотров 277 тыс.
Почему Катар богатый? #shorts
0:45
mood всех бабушек
0:11
Просмотров 396 тыс.
Translating a Custom Design System to Tailwind CSS
10:10
Floating Labels with Tailwind CSS
10:19
Просмотров 99 тыс.
cn() - Every Tailwind Coder Needs It (clsx + twMerge)
7:46
10 Tailwind Classes I Wish I Knew Earlier
13:31
Просмотров 170 тыс.
Custom themes with TailwindCSS in under 9 minutes
8:40
How to Create Themes with Tailwind CSS
19:57
Просмотров 8 тыс.
Styling Forms with Tailwind CSS
17:25
Просмотров 139 тыс.
Acer Predator Тараканьи Бега!
1:00
Просмотров 487 тыс.