From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Creating button component - Next.js Tutorial
From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance
Creating button component
Now, I will create the button component. So I will create the file button.jsx inside the UI folder and then I will create the function, the button itself. I will say export default function button. Now let me go to the product card component and copy the button tag and paste it over here. Now we will take the values for type, onClick, className, children in props. So let me receive the props over here. I will say type is equal to button, then onClick, className, children and props. So the props will contain the rest of the props passed as we are using the rest operators with it. Now let me import the cn function from utils and let me give the values to the button tag. I will say type is equal to type, class name is equal to cn, custom btn comma class name, on click, the on click and here I will say the rest operator and props. Let's save this file and go to the product card component and replace the buttons with a custom button component and let me remove the custom BTN class as we…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Initiating client section1m 53s
-
(Locked)
Creating header component5m 20s
-
(Locked)
Implementing search bar2m 16s
-
(Locked)
Joining Tailwind classes with ideal approach2m 34s
-
(Locked)
RQ: Joining Tailwind classes with ideal approach2m 38s
-
(Locked)
Adding profile drop-down4m 31s
-
(Locked)
useRef() hook4m 42s
-
(Locked)
Close profile drop-down menu on outside click3m 2s
-
(Locked)
RQ: Close profile drop-down menu on outside click2m 36s
-
(Locked)
Creating input component1m 54s
-
(Locked)
Creating home page2m 34s
-
(Locked)
Creating filters section6m 15s
-
(Locked)
Creating custom accordion component10m 58s
-
(Locked)
RQ: Creating custom accordion component1m 37s
-
(Locked)
Completing custom accordion component4m 35s
-
(Locked)
Continue on filter section3m 2s
-
(Locked)
Creating price range slider component4m 39s
-
(Locked)
Creating product card component8m 17s
-
(Locked)
Completing product card component2m 47s
-
(Locked)
Creating button component1m 44s
-
(Locked)
API creation for product listing3m 59s
-
(Locked)
Dynamic product rendering using server action7m 12s
-
(Locked)
API creation for fetching product types1m 41s
-
(Locked)
Dynamic product type rendering using API2m 28s
-
(Locked)
Set filter values into the search params4m 29s
-
(Locked)
Modifying products API to apply filters5m 35s
-
(Locked)
Filter functionality on client side3m 44s
-
(Locked)
Search filter functionality4m 31s
-
(Locked)
Creating product page6m 38s
-
(Locked)
Completing product page3m 21s
-
(Locked)
API creation for fetching a product by its ID2m 54s
-
(Locked)
Dynamic product details rendering using API3m 25s
-
(Locked)
Rendering products based on status2m 42s
-
(Locked)
Creating cart page3m 24s
-
(Locked)
Rendering cart item card6m 22s
-
(Locked)
Completing the cart UI4m 55s
-
(Locked)
Creating context for handling products1m 50s
-
(Locked)
RQ: Creating context for handling products1m 28s
-
(Locked)
Implement cart functionalities8m 4s
-
(Locked)
Making cart page dynamic2m 54s
-
(Locked)
Enabling quantity selection3m 45s
-
(Locked)
Finishing dynamic cart page5m 6s
-
(Locked)
-
-
-
-