What I love the most about Josh is that he is smart and he assumes that we are smart… At the same time he is learning and he assumes that we are learning too… from that we have his iconic balanced approach where he is never assuming that we know everything and he is never going to treat us like if we know nothing at all… he is outlining the elements that we need to be aware of if we are new to the topic and then he is introducing the core of the topic… I love that approach it’s perfect for me I love that style of teaching we have the felling that we are on the same level and growing up together… This is why I always repeat myself and say that Josh is such a good communicator 😊😊😊😊
You e managed to summarise exactly what I couldn’t quite put my finger on haha. His ability to show he’s still human (make mistakes/learn etc) whilst being aware of the core fundementals on a topic. Thanks for the comment, helped further my own understanding and give some words to this style of teaching for me.
Bro, thank you. Very simple yet detailed at the same time. You covered so many important concepts. This might not work well for a beginner, but as someone who's been on the TS journey, it's perfect.
Are there any performance improvements that back up this approach? Or is it just for Developer Experience? Since it may reduce Code Redundancy, we are also installing extra libraries in exchange of it
@@AlexSilva-ye2lpthis is a terrible approach you can’t unit test css classes. Only make utility classes in css, for example background-card or header-prominent. If you want to make an actual card turn it into a component.
Why to use that tailwind classes inside cva when you can directly use inside button Or simply you can create some global css classes and use that classname
Awesome! Just one question: when you create forwardRef you add both but doesn't ButtonProps already contain everything from HTMLButtomElement from the interface you created above it? Why is it necessary to pass HTMLButtonElements again there?
The forwardRef generic type parameter list (ie, the bit between the angle brackets ) takes in two values to replace two generics. The first is the type of the thing you're providing the ref to. The second is the props that the component takes. So in this case, HTMLButtonElement refers to the tag which the ref is referencing. If it was a div element instead, then it would be HTMLDivElement. Then the ButtonProps bit is just saying which props the element could take. There's some repetition, but it because you could not bother with sending props to the tag in case you want to restrict what the consumer of your component can do. Lots of flexibility even though in most cases it'll be bad practice to not just pass the props down.
Perfect video, perfect speed, i love it! I usally speed up all videos x2 just to get to the point, I like the libs he is using, I didn't know about them before, and I usually have variants and size in many components, im going to use these lib in my project. LIKE AND SUBSCRIBED!
Clean and Straight Forward and Thanks for also mentioning the keyboard shortcut i always have defficulty to find the vs code keyboard shortcut because I thinks its a time waste to learn keyboard shortcut i learn in process not explecitely
Interesting tooling. Is there a reason you did not use ComponentProps instead of the interface route? I have found through research that we should default to using types as opposed to interfaces. Also I believe using FC is also no longer best practice but I could be tripping Great video though. Don't think I am criticizing just because I asked some questions
Great video! What about dark mode? Is there a way to create dark mode modifiers for each variant and add darkMode prop to the component, or is it necessary to create independent dark mode variants?
Does anyone know which react snippet extension Josh is using. He created a typescript react component only using "rc" snippet. I am already using ES7+ React/Redux/React-Native snippets but I don't it provides this snippet.
Disabled is not a variant, it's an attribute. Just style it using the attribute pretty much like .myClass[disabled] in CSS. You can either define it for all of them, individually or both. Tailwind uses "disabled:" prefix for it :)
Material UI doing for us this thing in advance , why we struggle too much ,MUI give us option of Theme in which we can do custom theme , Create reusable design
Hello👋. In my project I have primary and secondary buttons with global .btn class which I use on a and button tags, but I want to use Button component, because lots of project examples use that option. If not difficult, can you give examples why to use Button component, what are the benefits?
Great Content Josh! as always. I have a question about the video. Please could you tell me the reason that you put 'clsx' in the cn function. I think it doesn't matter if we don't have that. 🙄
I would love to see a series where you a have project to build and showing how to write an app that would be easy to scale and have a lot of reusable components :D
Im not marking any comments as anything. It's not a secret that I learn from open-source code too. I share what I learn on this channel, and always credit the creator if I do so. If you had read the readme, you'd know that, even though shadcn specifically states no attribution is required whatsoever
@@joshtriedcoding sorry josh for my hard talk, but it would have been nice , if you have mentioned about it , it not about atrribution , but mentioning shadn to that people, so that they could benefit more from his complete work. Thanks.
@@joshtriedcoding you jump too much and too fast, it's a good pace for intermediate developers but not good for beginners. What you explain is aimed at beginners, an intermediate dev knows this stuff. So since you're viewers are most likely going to be beginners, you need to adapt your pace to them. Can't just jump around setting types they never even heard of, importing packages without thoroughly explaining them, using typescript code in a "create Reusable React components" titled video etc. Your average viewer doesn't even know what a ref is, you just threw it in their face. This kind of videos are better suited for a series rather than a one time explainer. In a series you go step by step and get them to your pace (+ more content, more watchtime etc which benefits you as well. You can make people binge a series, that does wonders for the algo) Just be smarter :) if you really spend a couple minutes thinking about it or if you just rewatched the video before uploading it you would probably have came to the same conclusions. Good luck buddy, looking forward to see your future content as you get used to YT
What I love the most about Josh is that he is smart and he assumes that we are smart… At the same time he is learning and he assumes that we are learning too… from that we have his iconic balanced approach where he is never assuming that we know everything and he is never going to treat us like if we know nothing at all… he is outlining the elements that we need to be aware of if we are new to the topic and then he is introducing the core of the topic… I love that approach it’s perfect for me I love that style of teaching we have the felling that we are on the same level and growing up together… This is why I always repeat myself and say that Josh is such a good communicator 😊😊😊😊
You e managed to summarise exactly what I couldn’t quite put my finger on haha. His ability to show he’s still human (make mistakes/learn etc) whilst being aware of the core fundementals on a topic.
Thanks for the comment, helped further my own understanding and give some words to this style of teaching for me.
Minimum requirement for programmer: should be able to dig deep.
Good! Instead of ButtonHTMLAtrrs you can also use ComponentProps (as well as 'div', 'input' etc) to make code look cleaner :)
Thanks so much for this
copied (agreed)👌
The name should be changed from "Josh tried coding" to "Josh is coding". Love what you're doing man, thanks.
Brilliant content! I am watching you for a few weeks now. One on the few channels in dev that actually worth watching! ❤
That was something that really fired me up months ago ❤🎉
Really handy to reuse components once you figure out how and take the time to make them reusable
I did not understood why to use this approach when we can use the globals.css to create default styles and variant styles too.
Bro, thank you. Very simple yet detailed at the same time. You covered so many important concepts.
This might not work well for a beginner, but as someone who's been on the TS journey, it's perfect.
what is the typescript snippet you used to make that btn component so quick?
What is the name of extension using which you initiated React function component "fc"
What's the name of that vscode extension which you're using by typing fc for typescript react functional component?
What do you mean?
React Snippet extension will help you do that
Are there any performance improvements that back up this approach? Or is it just for Developer Experience? Since it may reduce Code Redundancy, we are also installing extra libraries in exchange of it
I like to use only the lib called classnames. I don't see the necessity of class-variancy-authority.
@@botelhoh4535 me too, I think its much easier to just create the default styles at the globals.css file and then create the variant classes their.
@@AlexSilva-ye2lpthis is a terrible approach you can’t unit test css classes. Only make utility classes in css, for example background-card or header-prominent. If you want to make an actual card turn it into a component.
What a goat!
tysm, i really need this for future planning when i work on react again
Really impressed with the content man, really like this kind of content ♥
Cheers man
Why to use that tailwind classes inside cva when you can directly use inside button Or simply you can create some global css classes and use that classname
Ya same question
Awesome!
Just one question:
when you create forwardRef you add both but doesn't ButtonProps already contain everything from HTMLButtomElement from the interface you created above it? Why is it necessary to pass HTMLButtonElements again there?
The HTMLButtonElement here is the return type of the component.
The forwardRef generic type parameter list (ie, the bit between the angle brackets ) takes in two values to replace two generics. The first is the type of the thing you're providing the ref to. The second is the props that the component takes.
So in this case, HTMLButtonElement refers to the tag which the ref is referencing. If it was a div element instead, then it would be HTMLDivElement. Then the ButtonProps bit is just saying which props the element could take. There's some repetition, but it because you could not bother with sending props to the tag in case you want to restrict what the consumer of your component can do. Lots of flexibility even though in most cases it'll be bad practice to not just pass the props down.
Perfect video, perfect speed, i love it! I usally speed up all videos x2 just to get to the point, I like the libs he is using, I didn't know about them before, and I usually have variants and size in many components, im going to use these lib in my project. LIKE AND SUBSCRIBED!
i dont know why , but i was keep counting how many "Really really" was there xD xD thanks for this fruitful videos!
Insanely valuable - thank you for taking the time!
Great tutorial! Just one question. Do the tailwind classes we write in those cva things affected by prettier with tailwind's extension?
Not sure, good question. Haven’t tried that out yet
Clean and Straight Forward and Thanks for also mentioning the keyboard shortcut i always have defficulty to find the vs code keyboard shortcut because I thinks its a time waste to learn keyboard shortcut i learn in process not explecitely
can you please share the extension you made the basic component only typing 'fc'?
Interesting tooling. Is there a reason you did not use ComponentProps instead of the interface route?
I have found through research that we should default to using types as opposed to interfaces. Also I believe using FC is also no longer best practice but I could be tripping
Great video though. Don't think I am criticizing just because I asked some questions
Bravo! Can you make the same
Idea but with an input and react hook form?
did you define typescript react code snippet like "fc" by yourself? or are you using extension?
The extension is called ES7+ React/Redux/React-Native snippets
Great video! What about dark mode? Is there a way to create dark mode modifiers for each variant and add darkMode prop to the component, or is it necessary to create independent dark mode variants?
Question about component FILE NAMES. Which compoennt file name should be PascalCase and which should be just regular lowercase ?
Does anyone know which react snippet extension Josh is using. He created a typescript react component only using "rc" snippet. I am already using ES7+ React/Redux/React-Native snippets but I don't it provides this snippet.
could you explain how to build the styled function of MUI? I see it has some features like inheritance style's-component and namespace classes
This is great content Bro. I enjoyed every bit of it
Amazing! Please create more similar typescript videos.
Amazing pattern. Thank you for sharing it with us!
Why is there no intellisense when you're typing tailwind class names? Is there any easy way to fix this?
All thats left now is auto complete for the ButtonVariant object and this would be perfect.
What I don’t understand is… this button wouldn’t only be a … but what if you wanted to have the button component as a or
no , he giving us option to create reusable button
nice! Anyway, CVA re-exported `clsx` package they called it cx, so it's unnecessary to install `classnames`
CVA does not surface the types such as 'ClassValue[]' though
how can i pass not only input but also label to Reac.ComponentProps??
Hey Josh, great video, thanks! Just wondering how we can make a disabled variant?
Disabled is not a variant, it's an attribute. Just style it using the attribute pretty much like .myClass[disabled] in CSS.
You can either define it for all of them, individually or both. Tailwind uses "disabled:" prefix for it :)
for example if I have a component that has a wrapper and button then how can I utilize cva to use conditional classes in both?
Just curious, do u use VSC in real work projects with all these manual lib imports, or u doing it for us?
Incredible work and clarity. Keep going! 🫡
How do you add children without passing props in button ?
Material UI doing for us this thing in advance , why we struggle too much ,MUI give us option of Theme in which we can do custom theme , Create reusable design
Same thoughts
Nice! Now the shadcn ui components make sense!
Nice man... Make an video about ui components library and how build and re-use on an application. Thanks!
Cheers dude. I think a key part of a UI lib is to be very reusable by default. Personally I think shadcn has done a great job at this with his library
Would be great to make a video about your navigation in vscode, looks interesting
Hey Josh, Its amezing to have your videos, i just want to know how do you create tsx file with just fc snipes? Please let me know
Awesome stuff, I really wanna make a project with React + TypeScript. Have only made with Javascript.
Hello👋. In my project I have primary and secondary buttons with global .btn class which I use on a and button tags, but I want to use Button component, because lots of project examples use that option. If not difficult, can you give examples why to use Button component, what are the benefits?
Great Content Josh! as always. I have a question about the video. Please could you tell me the reason that you put 'clsx' in the cn function. I think it doesn't matter if we don't have that. 🙄
True, I think it's not needed anymore. As far as I know, tailwind-merge uses clsx under the hood anyways
Thanks so much Josh
Display -> Spaces: 4
Editor -> Spaces: 2
How is styling not the point sir? How?
Why not write plain old CSS?
please, create video about NextJS roadmap. Thank you.
You offer Contractor work 💼?
The concept of defining styles inside of your Button component then using those in other random non-Button components is pretty absurd to me.
You could have used namespaced components too
Didn't understand use of forward ref
Svelte Skeleton UI has already solved this issue...
instead of forwarding ref why don't you give it just another name and pass it normally? instead of ref - btnRef
Amazing content
emmm, it's a button from shadcn/ui
Exactly 😂 I just searched from shadcn component that what is cva and got this vdo
this amazing thank you
I would love to see a series where you a have project to build and showing how to write an app that would be easy to scale and have a lot of reusable components :D
Any certain project you’d like to see?
@@joshtriedcodingany type of e-commerce website 😌
@@joshtriedcoding Thx for another banger! I agree with @bubuq3, my 2 cents maybe a chat app or ecommerce app?
@@joshtriedcoding maybe create a CMS like Wordpress, but using NextJS? with plugin, theme, WP hooks system, etc.
@@joshtriedcoding E commence project that merge multiple store into one UI
great video man \m/
josh bester mann 🎉
Muy bueno, gracias
Clsx is kinda useless now tailwind merge and tailwind join exists. Import {twMerge, twJoin} from 'tailwind-merge';
Nice !
ctrl + spacebar !!
shadcn is built upon this haha
nice!
Wieso nicht deutsch?
too much abstraction will eventually kill you
common man why are you afraid of the truth , copying open source code doesn't mean you have done it yourself, marking my comments as spam won't work
Im not marking any comments as anything. It's not a secret that I learn from open-source code too. I share what I learn on this channel, and always credit the creator if I do so. If you had read the readme, you'd know that, even though shadcn specifically states no attribution is required whatsoever
@@joshtriedcoding sorry josh for my hard talk, but it would have been nice , if you have mentioned about it , it not about atrribution , but mentioning shadn to that people, so that they could benefit more from his complete work. Thanks.
@@tangle5069 I made a whole video about his work because I was so impressed with it: ua-cam.com/video/DeLHGl936Fo/v-deo.html
@@joshtriedcoding Aplogies from my side, i hadn't watched that video, anyways keep doing the good stuff.
nextjs is bloddy shit its too much complicated for a simple button
wha
shadcn
Just write an object literal and use it as a map smh.
This is really not that useful. No offense, but thx for the info
No offence taken, what would make this more useful in your opinion?
@@joshtriedcoding Boss response!
@@joshtriedcoding you jump too much and too fast, it's a good pace for intermediate developers but not good for beginners. What you explain is aimed at beginners, an intermediate dev knows this stuff. So since you're viewers are most likely going to be beginners, you need to adapt your pace to them. Can't just jump around setting types they never even heard of, importing packages without thoroughly explaining them, using typescript code in a "create Reusable React components" titled video etc.
Your average viewer doesn't even know what a ref is, you just threw it in their face. This kind of videos are better suited for a series rather than a one time explainer. In a series you go step by step and get them to your pace (+ more content, more watchtime etc which benefits you as well. You can make people binge a series, that does wonders for the algo)
Just be smarter :) if you really spend a couple minutes thinking about it or if you just rewatched the video before uploading it you would probably have came to the same conclusions. Good luck buddy, looking forward to see your future content as you get used to YT
@@eminvesting Thanks very much for the detailed critique! That was possibly the most valuable feedback I've gotten.
@@eminvesting agree with your comment.
xD
bro plz go slow
inline css 🤮
you can't reuse this "reusable" component on the projects which are not using tailwind
why wouldn't you just use tailwind in everything? i mean if it's part of your stack, you'd use it wherever you can
You need to talk slowly,and some more explanation about every thing you code would be nice...
appreciate your feedback
u can slow down the vid, mate
@@hashira_d Its about explanation to...
Man i just love u🫶🏼