Build a Carousel Component like Instagram purely in ReactJS and TailwindCSS

  Рет қаралды 82,823

Your Code Lab

Your Code Lab

Жыл бұрын

#reactjs #reactjstutorial #carousel #tutorial #tailwindcss #instagramclone
In this video you'll learn how to make a carousel or image slider component very much like instagram in ReactJS and Tailwind CSS from scratch (without any additional libraries) under 10 minutes. It works with images as well as videos and also supports auto sliding feature, previous/next controls and bottom indicators.
Code: gist.github.com/nimone/1fad7a...
Socials:
Instagram: / ycldev
Twitter: / yourcodelab

Пікірлер: 121
@psyferinc.3573
@psyferinc.3573 Жыл бұрын
hmmmm i normally have to go through many many many videos . but this is just beauriful. one of those times where you feel emotional because you expected 4 hours on something but ended up understanding it and applyint it in 20 minutes . thank you my good sir.
@ycldev
@ycldev Жыл бұрын
Very much appreciate the response. I am glad I could save you some time 😄.
@myblog8751
@myblog8751 Жыл бұрын
Your way of teaching and quality content is so amazing. I hope you make more long hour project videos in react You got a new subscriber
@ycldev
@ycldev Жыл бұрын
Thank you, it really means a lot. I definitely have plans for react project videos.
@user-vu9dl3vn7l
@user-vu9dl3vn7l 3 ай бұрын
Thank you so much for this helpful tutorial!
@user-qi2hv3rx6l
@user-qi2hv3rx6l 8 ай бұрын
You're simply the best there is around here. Thank you very much Sir !
@ycldev
@ycldev 8 ай бұрын
I appreciate your kind words thank you 😊
@gui_cabral_99
@gui_cabral_99 Жыл бұрын
That was a big help! Thanks man
@sherifdeenishola3331
@sherifdeenishola3331 Жыл бұрын
Short, precise and understanding
@deewrekk7375
@deewrekk7375 Жыл бұрын
Masterful. Top quality content. Thank you!
@ycldev
@ycldev Жыл бұрын
Really appreciate your kind response and glad you found value 😊
@derolores
@derolores 4 ай бұрын
Amazing video! I was about to install bootstrap whilst using tailwind...This one saved me < 3
@ycldev
@ycldev 4 ай бұрын
Always happy to prevent a bootstrap install😄
@user-wk7zm3od2o
@user-wk7zm3od2o Жыл бұрын
Awesome Video and detailed explanation! Thank you for this great tutorial!!!!
@ycldev
@ycldev Жыл бұрын
Stay tuned for more 😊
@joshuagalit6936
@joshuagalit6936 11 ай бұрын
You earned my subscription brutha
@quelvinmachadodepaula
@quelvinmachadodepaula Жыл бұрын
Way to go man!
@kunalukey5870
@kunalukey5870 Жыл бұрын
Awesome! 🔥
@elhamrajabi3492
@elhamrajabi3492 11 ай бұрын
Thank you for your great article🌹🌹
@arhabersham
@arhabersham Жыл бұрын
New favorite channel ❤
@ycldev
@ycldev Жыл бұрын
Don't know what to say. I am overjoyed.
@destroyerking7668
@destroyerking7668 3 ай бұрын
Amazing man you saved my day!! Appreciate
@ycldev
@ycldev 3 ай бұрын
Have a nice rest of the day 🤟
@rossinifonseca5683
@rossinifonseca5683 3 ай бұрын
keep doing this man!!! awesome
@ycldev
@ycldev 3 ай бұрын
Thanks, I will!
@genibrylian493
@genibrylian493 Жыл бұрын
Thanks, its a Great content. Keep Up the spirit. Subscribed!
@ycldev
@ycldev Жыл бұрын
Glad you liked it. It means a lot!
@slushiiforonda1473
@slushiiforonda1473 7 ай бұрын
New subscriber thank you very much
@balls991
@balls991 Жыл бұрын
Great, thank you.
@min.min0
@min.min0 8 ай бұрын
Wow it is really helpful thank you keep going
@ycldev
@ycldev 8 ай бұрын
Glad you found it helpful 😊
@M00nL1ght6
@M00nL1ght6 Жыл бұрын
good job! you really helped me with my page c:
@ycldev
@ycldev Жыл бұрын
Pleased to know it helped.
@franciscoolivares1474
@franciscoolivares1474 Жыл бұрын
Nice bro!
@KevynGiron-qv9yg
@KevynGiron-qv9yg 11 ай бұрын
Thanks for the video ❤
@ycldev
@ycldev 11 ай бұрын
You are welcome ☺️
@davique0
@davique0 Жыл бұрын
thank you so much for this content, it is very helpful, is there a way to add the 3D effect, like you can see the previous and next slide on the sides with some transparency?
@ycldev
@ycldev Жыл бұрын
Hey Mario, thanks for the appreciation. At the moment I only have few pointers for the result you want: - Scale the active slide with large shadows. - Adjust the height of carousel container. according to the scale and expand the width (~3x) so that it can show the next and previous slides. - Add some spacing between the slides and make the inactive ones 40% transparent (or grayscale).
@alissonperim7425
@alissonperim7425 Жыл бұрын
That was amazing, because you made it simple, and efficient. Thanks for this vídeo.
@ycldev
@ycldev Жыл бұрын
Thank you for watching!
@didaantruong4572
@didaantruong4572 Жыл бұрын
Wow 🎉❤
@watchnow4211
@watchnow4211 5 ай бұрын
Awesome
@Thwaha
@Thwaha 9 ай бұрын
Amazing.. Subscribed.. Like to learn more from you..
@ycldev
@ycldev 9 ай бұрын
Thanks ☺️
@otienodennis9571
@otienodennis9571 Жыл бұрын
I would love to learn more of tailwind from you, you make it easy to understand.
@ycldev
@ycldev Жыл бұрын
Thanks for the kind words. Next video on react + tailwind components coming up this week 😉
@dawn_signal
@dawn_signal Жыл бұрын
excellent
@mohdsahil226
@mohdsahil226 Жыл бұрын
How can we repeat the sllider instead moving back to first image. like clicking on the last image should move left with first one
@ycldev
@ycldev Жыл бұрын
Slides appear in sequence, since you pass them as an array, I don't think what you want is possible with the current implementation. Since CSS translate property is doing the job of sliding them according to their positions.
@alexg7282
@alexg7282 3 ай бұрын
thank you
@ycldev
@ycldev 3 ай бұрын
You are welcome!
@malikahadali2188
@malikahadali2188 10 ай бұрын
very nice and very informative video☺
@ycldev
@ycldev 10 ай бұрын
Glad you liked it
@swopnilmaharjan8630
@swopnilmaharjan8630 Жыл бұрын
can u make it for more than one images ? it was sth like when we clcik next arrow button the image wud slide and in that spot the image wud come like form small to big.
@ycldev
@ycldev Жыл бұрын
You can map the slides in the carousel and then scale the previous and next slide to half. But you would have to replace the overflow-hidden on container to something that can accommodate 3 slides at a time.
@mosdev2091
@mosdev2091 Жыл бұрын
Merci !
@bestteam4805
@bestteam4805 4 ай бұрын
Very helpful and quick video. Is there a version that can be dragged left and right with the mouse?
@ycldev
@ycldev 4 ай бұрын
I think that's not possible with our current implementation. You can look at the shadcn ui carousel component it is feature complete.
@ronaldchiagozie8317
@ronaldchiagozie8317 Ай бұрын
best
@JDUDEadventure
@JDUDEadventure 3 ай бұрын
Hi do you have a video on how to make this slide appear to transition infinitely instead of it reaching the end of the slide and moves back all the way to the beginning?
@ycldev
@ycldev 3 ай бұрын
We currently do not. But we will definitely follow up on this video, and make it better.
@moxterin
@moxterin 7 ай бұрын
Hi! First of all i want to thank you for the excellent material. How could i add text content for each slide? I have tried several things but none of them is working right now.
@ycldev
@ycldev 7 ай бұрын
You can pass any html element as slide to this carousel. Have you tried passing a div with a background image and some content text?
@indiegaming819
@indiegaming819 Күн бұрын
how can i add a different text above each image, and translate each text according to the image ? BTY nice tutorial
@diegocuevas3714
@diegocuevas3714 4 ай бұрын
Ty man, i was looking for this kinda video tutorial, can you tell us the vs theme u are using?
@ycldev
@ycldev 4 ай бұрын
Hey Diego, I am using Monokai pro theme, filter spectrum to be precise.
@nathanielmitchell3344
@nathanielmitchell3344 5 күн бұрын
Can this be changed to have a fade effect? For example opacity changing from 0 to 1 and back between images.
@ycldev
@ycldev 5 күн бұрын
Try this: Instead of translating, set the opacity of all images to 0 and only turn it up for the active slide.
@nathanielmitchell3344
@nathanielmitchell3344 5 күн бұрын
@@ycldev thanks!
@attaullahkhan3931
@attaullahkhan3931 Жыл бұрын
can you suggested for me . which node js version are using nowdays v16, v18 ?
@ycldev
@ycldev Жыл бұрын
I recently installed node 18 lts, using 17 in this video
@emmachuksudeji9477
@emmachuksudeji9477 5 ай бұрын
This is just awesome. I appreciate it. Can you make the slider to continue in the same direction instead of the going backward when it gets to the end.
@ycldev
@ycldev 5 ай бұрын
Thanks for the appreciation. With the current transform transitions it may not be possible. At the moment I can't think of another way for it to work.
@emmachuksudeji9477
@emmachuksudeji9477 5 ай бұрын
Okay. We can achieve that with JavaScript
@mohdsahil226
@mohdsahil226 Жыл бұрын
Hi Can you make it work without style tag? only using tailwind classes? I want different layout with `LTR and RTL classes?
@ycldev
@ycldev Жыл бұрын
Don't know if that's feasible with classes. Your best bet for interpolating the state with styles is custom styling, although you can use external animation libraries to achieve the same.
@pancham_barman
@pancham_barman 3 ай бұрын
on desktop mode it shows half the image and the other half of the next image, is there any way to so that it shows on one image at a time on desktop?
@ycldev
@ycldev 3 ай бұрын
Are you sure you used images of similar dimensions?
@pancham_barman
@pancham_barman 3 ай бұрын
@@ycldev yes they are almost the same, I tried giving separate width, and figured out that after 45~46rem, the next images tries to show up a little bit. So can you try to tweak it a little bit so that it can be used in full screen, on desktop mode. On mobile, since the width is less, it work fine..
@ycldev
@ycldev 3 ай бұрын
Try using a max width on the container. But for full screen with the image may not fit perfectly so try object-fit cover or fill on the images
@jacob_scott
@jacob_scott 8 ай бұрын
I want to build a carousel that goes forward from last slide to first. Every solution I find transitions backwards and glimpses over the slides in between very quickly
@ycldev
@ycldev 8 ай бұрын
If you don't want the backward transition, just reverse the slides array you're passing it?
@codewithskills1470
@codewithskills1470 Ай бұрын
can you tell me ehat kind of theme and font you use it amazing
@ycldev
@ycldev Ай бұрын
Monokai Pro (filter spectrum) and Cascadia Code
@wkmgaming6097
@wkmgaming6097 3 ай бұрын
In instagram if the images are more the dots are still remain this is the main functionality can u create this
@ycldev
@ycldev 3 ай бұрын
A little tricky but you can start by limiting the number of max dots and decreasing the size of the first one if curr+2 > max dots and last one if curr+2 < number of slides
@mrlectus
@mrlectus 11 ай бұрын
Why use style attribute for the transformation and not tailwind?
@ycldev
@ycldev 11 ай бұрын
Our transformation is dynamic and dependent on the state change. It won't work with tailwind since it wouldn't know how may classes for "translate-x-[dynamic%]" it would require (there can be any number of slides) and even if it works, it is a highly discouraged practice.
@harshitpant07
@harshitpant07 16 күн бұрын
How can we add 3 card at one time and move 1 card on each click... Like review cards
@ycldev
@ycldev 8 күн бұрын
You can increase the width of the container so that 3 cards are visible at a time and only translate one card worth of width
@m__link6499
@m__link6499 Жыл бұрын
I mean, how can we make sure that the slider shows only one Image at the time?
@ycldev
@ycldev Жыл бұрын
Make sure you use images of same dimensions.
@m__link6499
@m__link6499 Жыл бұрын
@@ycldev Thank you for your response. unfortunately, all the images have the same size, so the problem should be resolve anywhere else I think...😔
@ultragamersvk1668
@ultragamersvk1668 8 ай бұрын
would you mind teaching us how we can easily make responsive multipage websites easily
@ycldev
@ycldev 8 ай бұрын
Well, I always try to make every project responsive. I am also planing to make multipage Nextjs apps in future. Hope that addresses your comment.
@protamim_32
@protamim_32 5 ай бұрын
How can be make it responsive?
@ycldev
@ycldev 5 ай бұрын
It is already responsive you just have to limit the max width of the container for how wide you want the carousel to be.
@newHorizon985
@newHorizon985 11 ай бұрын
Font name please Looks good
@ycldev
@ycldev 11 ай бұрын
Cascadia code with font ligatures on
@sefii05
@sefii05 Жыл бұрын
for the love of god, use a better font
@kevyyar
@kevyyar Жыл бұрын
Oh I lovw that font ❤
@weboff_official
@weboff_official Жыл бұрын
I have cards with 200 width and 1 just follow your steps then suddenly in just one click my 8 cards gone into hell😅🤣
@ycldev
@ycldev Жыл бұрын
Happens with me too. Carousel is very sensitive to width, just to be safe about the dimensions of the images, manually assign the desired width and height to the tag.
@weboff_official
@weboff_official Жыл бұрын
No brother i have text in object looping it and make a 200×200 card but if we multiply current index to 100 then card disappears
@weboff_official
@weboff_official Жыл бұрын
i want to show 3 cards at a time it's mean 200px it should move now if you have any suggestion or logic please tell me thank you
@ycldev
@ycldev Жыл бұрын
Oh my bad, now I get it. You have to adjust the translateX property. Since you are showing 3 cards at a time, so instead of translating 100% (full width), you should use 33.33% (1/3rd width). It should hopefully slide one by one now.
@weboff_official
@weboff_official Жыл бұрын
thank you 💕 you earned a subscriber 🤗
@8koi245
@8koi245 Жыл бұрын
no way, a fellow user of the useState snippet then just remove the e for import ~
@ycldev
@ycldev Жыл бұрын
Hey, thanks for watching. Didn't get the last part. I am not very good with custom vscode snippets.
@8koi245
@8koi245 Жыл бұрын
@@ycldev it's not custom, it's just the shortcut for writing useState the if you remove the last e and write it again, the option for 2 auto import appears, way faster than importing it by hand
@ycldev
@ycldev Жыл бұрын
Oh, I got it. I normally remove the autosuggestions when I am recording the video so it does't clutter the screen. And bring them up with ctrl+space when I need them.
@AriRaouf-kq4le
@AriRaouf-kq4le 7 ай бұрын
Why you give the autoSlide prop a default value=false while you give it true when you set the autoSlide attrib in the parent 2.why you set children:slides.? Is not children destruction prop is enough .? Is it like default value or what? The react will auto know it’s children
@ycldev
@ycldev 7 ай бұрын
Autosliding behaviour should be off by default in most usecases unless you need it everywhere. Children: slides is like setting slides = children, I thought I will be a more appropriate name.
@Metovski
@Metovski Жыл бұрын
children:slides what a weird usage
@ycldev
@ycldev Жыл бұрын
Got carried away calling them slides 😅
@Metovski
@Metovski Жыл бұрын
@@ycldev i see first time. i usually use children not children:slides
@imheretosleep
@imheretosleep 9 ай бұрын
So no one's gonna talk about the fonts that he used in his code editor 😨
@ycldev
@ycldev 9 ай бұрын
It is cascadia code 🤫
@user-id2fu3ex8l
@user-id2fu3ex8l Жыл бұрын
Hi teacher ! I want to apply object-fit : cover to slide images, where should I put that property ?
@ycldev
@ycldev Жыл бұрын
You should directly appy it to the images (where you are passing them) and wrap the images with a div & set the desired width and height to the div.
Build a Modal Component purely in ReactJS and TailwindCSS
6:16
Your Code Lab
Рет қаралды 20 М.
Build a React Image Slider with Tailwind CSS
18:29
Code Commerce
Рет қаралды 105 М.
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 64 МЛН
How to make Card Slider in React JS | React Slick
9:03
Etisha Garg
Рет қаралды 108 М.
They made React great again?
4:11
Fireship
Рет қаралды 1 МЛН
The Advanced TailwindCSS Crash Course
37:39
Tom Is Loading
Рет қаралды 11 М.
React JS & Tailwind CSS Responsive Website - Beginner Friendly
1:18:16
Code Commerce
Рет қаралды 261 М.
Build an Image Carousel with Embla in React
9:35
Code Commerce
Рет қаралды 14 М.
How To Load Images Like A Pro
15:48
Web Dev Simplified
Рет қаралды 361 М.