Build a UI Library with React, Typescript, TailwindCSS and Storybook

  Рет қаралды 24,453

Code With Gionatha

Code With Gionatha

Күн бұрын

🌱 Source Code: www.codewithgionatha.com/repo...
💬 Discord: / discord
In this video, we are going to build a basic React UI Library by using React, TailwindCSS, Typescript, and Storybook.
Timestamps
00:00 Intro
01:07 Project setup
06:17 Tailwind setup
08:18 Storybook setup
11:34 Creating our first story
15:39 Explaining how styling works
18:23 The cn function
19:37 Adding Button styling
28:03 Adding the `ref` prop
29:55 Implement Text component
33:10 Adding the `as` prop
40:57 Implement Input component
45:00 Implement Box and Stack components
51:10 Building a Login form screen
56:34 Library final build
01:02:35 Outro
#react #typescript #tailwindcss #storybook #tutorial #programming #ui

Пікірлер: 57
@kettenbach
@kettenbach 6 ай бұрын
Awesome video. I love all of those libraries. I like seeing all the different generics and props type examples. Very cool. Thanks
@tegasteve8195
@tegasteve8195 6 ай бұрын
This looks like a really nice project to have in a portfolio
@mr.daniish
@mr.daniish 6 ай бұрын
This content is a breath of fresh air
@christoherright6430
@christoherright6430 6 ай бұрын
This helps me a lot. Thanks.
@harshitshakya2513
@harshitshakya2513 Ай бұрын
You save my couple of days, Thanks for sharing this information. Love from INDIA❤
@michaelariesmalaca8557
@michaelariesmalaca8557 24 күн бұрын
Thanks for sharing this stuff.
@vinayakhegde4216
@vinayakhegde4216 6 ай бұрын
This video is excellent. Making some challenging projects with any well-known tech stack would help you grow your channel and educate and enlighten a greater number of people, in my opinion.
@user-yt9dy4br5g
@user-yt9dy4br5g 6 ай бұрын
woaaaaa, thx gio⚡️
@trentcox9239
@trentcox9239 Ай бұрын
should have a look into tailwind-variants. takes the best of tw-merge, cva and clsx and adds even more features like slots to break down styling within the component. perfect for separating the 'noise' of the style classes into a separate file and keeping your components business-only.
@gionatha
@gionatha Ай бұрын
Thanks for sharing, didn’t know about that library. Looks very promising 🙌
@user-dc4qs5vs5z
@user-dc4qs5vs5z 2 ай бұрын
Nice video. But can you please create a video on how we can publish it and use it in another project ?
@ignaciofigueroa7815
@ignaciofigueroa7815 6 ай бұрын
Love it! I have a question. Is this library compatible with Next.js?
@gionatha
@gionatha 6 ай бұрын
Sure, you can import this library in a Nextjs Project.
@anshulsoni653
@anshulsoni653 4 ай бұрын
amazing tutorial, can you help on how I can import this library to my project, also can we deploy his storybook site
@davebenjamin4388
@davebenjamin4388 2 ай бұрын
Thanks for this tutorial. Very helpful to understand some of the inner workings. I have a quick question. I'm using shadcn to build my component lib (bundled with vite). When I publish and then consume button component, i get type warning on button "variant" prop. This seems to be solved by installing class-variance-authority in the consuming app. is this correct? if so should I install cva as a peer dep in my lib (i'm using a nx monorepo. so initially it was intalled in the root package of my packages monorepo.
@davebenjamin4388
@davebenjamin4388 2 ай бұрын
I would have thought that because is not listed as a rollup external, that cva would have been bundled into the package?
@gionatha
@gionatha 2 ай бұрын
@@davebenjamin4388 Hey dave. Yes, I think you need to install those dependencies since I think they are not shipped with the library. This is something that could be improved about this project indeed 😄
@xxXAsuraXxx
@xxXAsuraXxx 6 ай бұрын
is it being treeshaked properly? Last time I remember vite library mode doesnt support treeshake on the output
@gionatha
@gionatha 6 ай бұрын
Hey Kevin, I did some research and it seems it is still an Open Issue ( github.com/vitejs/vite/issues/5174 ). Anyway, it depends on the bundler I guess, seems that when using Webpack you might need to do additional work. I should do some double check on the final output to know if it has been tree-shaken properly.
@xxXAsuraXxx
@xxXAsuraXxx 6 ай бұрын
@@gionatha yep, I encounter this problem when building a library. I switched to a tool called Modern Module, its so good and treeshaked!
@Aman_yadav1419
@Aman_yadav1419 22 күн бұрын
Hey I got an error in storybook with node ..I don't why this is happening please help me
@rahulthakur4017
@rahulthakur4017 5 ай бұрын
Hey, nice but is there a way to not include react related license file(s) inside our build files?? All I need is just our own logic inside the build files
@gionatha
@gionatha 5 ай бұрын
You have two ways of doing that: 1. Inside the vite.config.ts, in the "rollupOptions" specify the deps to externalize, we actually did it in the tutorial (58:44) More info on how to externalize deps can be found here: rollupjs.org/configuration-options/#external 2. Install a vite plugin to externalize external dependencies like: github.com/davidmyersdev/vite-plugin-externalize-deps
@godfreyowino1525
@godfreyowino1525 6 ай бұрын
I have a question. How can we make our library be able to be initialized to our application or installed through npm
@gionatha
@gionatha 6 ай бұрын
You can use ' npm link ' if you want to test it locally. Go inside your library and run `npm link` then go to another project where you want to use it and run `npm link ` then you should be able to start importing the components of your library. The other method is publishing the library on a package registry (such as npm) by running the command `npm publish`. Once done you can install your library wherever you want as you were installing a normal package by running `npm install `. I suggest starting with the first approach.
@kelvinmusselli7066
@kelvinmusselli7066 2 ай бұрын
How to implements this lib in another project?
@mfurkankaya
@mfurkankaya Ай бұрын
First of all; thanks for the great video. I have a question. I would be so happy if you can answer. I named my library as "simple-ui-test-for-pkg" and when I want to use it in a project I have to add './node_modules/simple-ui-test-for-pkg/dist/simple-ui.js' path to tailwind config. Is there another way?
@gionatha
@gionatha Ай бұрын
Thanks. We discussed about this on Discord. You can find the conversation in the #ui-library channel.
@mfurkankaya
@mfurkankaya Ай бұрын
@@gionatha thanks!
@rykageee
@rykageee 3 ай бұрын
I followed your storybook setup and there is an error in both tsconfig.json and tsconfig.node.json "Cannot find type definition file for 'body-parser'. The file is in the program because: Entry point for implicit type library 'body-parser'" how to resolve this error?
@gionatha
@gionatha 3 ай бұрын
stackoverflow.com/questions/71673835/cannot-find-type-definition-file-for-body-parser-in-tsconfig-json
@syimiridris5185
@syimiridris5185 Ай бұрын
Hi can i know if the same setup can be use on react native? ignore the tailwindcss
@gionatha
@gionatha Ай бұрын
I think it should be feasible. But tailwind is not yet supported on react-native out-of-the-box. The only solution is using nativewind: nativewind.dev
@ShubhamVyavhare
@ShubhamVyavhare 3 ай бұрын
I didn't get it, why we are using forwardRef in every component? I search about it little, it says it helps if use want to manipulate DOM element, ref helps. Is it the only reason or there is another reason behind it?
@gionatha
@gionatha 3 ай бұрын
Cause we're building a UI library. If you need to access the ref of one of the components that we built on this project, the only way to properly access it is by forwarding the reference with forwardRef.
@ShubhamVyavhare
@ShubhamVyavhare 3 ай бұрын
@@gionatha Oh okay. Thank you so much for clearing. BTW nice tutorial. Helped me alot...!
@tareqdevdiary
@tareqdevdiary 5 ай бұрын
can it be used using npm, yarn and pnpm?
@gionatha
@gionatha 5 ай бұрын
Technically yes, although I used yarn, you should be able to install the dependencies and run scripts (i.e. storybook) even with npm or pnpm
@tareqdevdiary
@tareqdevdiary 5 ай бұрын
did you published this as a npm package?@@gionatha
@minas4356
@minas4356 2 ай бұрын
You just added the index.css file in the storybook files And there are no css files in the final output of the library how can I fix?
@gionatha
@gionatha 2 ай бұрын
If you’re trying to use this custom library in a separate project, I think you would need to install tailwind in that project as well in order to work.
@atejap
@atejap Ай бұрын
@@gionatha but if i have some custom css into index.css, i need to import the css file for each component i have created, rigth?
@atejap
@atejap Ай бұрын
I included "./node_modules/**/*.{js,ts,jsx,tsx}", into "content" in tailwind.config.cjs file in the separete project and then its woked
@MaxViews24
@MaxViews24 28 күн бұрын
How to build storybook static files for storybook deployment?
@gionatha
@gionatha 27 күн бұрын
you can run the script: "yarn build-storybook"
@MaxViews24
@MaxViews24 27 күн бұрын
Gotcha! My problem is to publish both library and storybook to two different environments.
@adilboudida3412
@adilboudida3412 Ай бұрын
how to deply this Library?
@user-dc4qs5vs5z
@user-dc4qs5vs5z 2 ай бұрын
And when I built it I am not getting styles in my other project. Can anyone help me here ?
@gionatha
@gionatha 2 ай бұрын
Discord
@scorpion32
@scorpion32 5 ай бұрын
I heard that it's is against tailwind terms and conditions to create and profit from their components to build themes
@ujjawalrachhoya8972
@ujjawalrachhoya8972 3 ай бұрын
who cares
@egaiosowor
@egaiosowor 3 ай бұрын
😂😂​@@ujjawalrachhoya8972
@moises-native4829
@moises-native4829 Ай бұрын
Why did you use yarn build and not yarn build-storybook ?
@gionatha
@gionatha Ай бұрын
yarn build is meant for shipping the library and stripping out storybook since is a development library (aka it should not be shipped with the library final bundle) yarn build-storybook instead is meant for shipping the storybook web application if you want to showcase your library to other people.
@Guccifer808
@Guccifer808 6 ай бұрын
Hey! How are you doing? I recall we chatted on IG
@6qat
@6qat 3 ай бұрын
The file simple-ui.d.ts is empty! Any hint for me to solve this?
@gionatha
@gionatha 3 ай бұрын
That's kinda weird 🤔Did you run yarn build? Did you set up the vite.config.ts correctly?
How to make your own NPM package (Step-by-Step) 📦
16:46
Under Ctrl
Рет қаралды 20 М.
Как быстро замутить ЭлектроСамокат
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 14 МЛН
Balloon Stepping Challenge: Barry Policeman Vs  Herobrine and His Friends
00:28
The day of the sea 🌊 🤣❤️ #demariki
00:22
Demariki
Рет қаралды 49 МЛН
Homemade Professional Spy Trick To Unlock A Phone 🔍
00:55
Crafty Champions
Рет қаралды 43 МЛН
This UI component library is mind-blowing
8:23
Beyond Fireship
Рет қаралды 590 М.
UI Libraries Are Dying, Here's Why
13:28
Theo - t3․gg
Рет қаралды 268 М.
Начало работы со StoryBook
23:42
Михаил Непомнящий
Рет қаралды 47 М.
Iphone or nokia
0:15
rishton vines😇
Рет қаралды 1,8 МЛН
wireless switch without wires part 6
0:49
DailyTech
Рет қаралды 4,4 МЛН
Мечта Каждого Геймера
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,5 МЛН
Купил этот ваш VR.
37:21
Ремонтяш
Рет қаралды 254 М.