From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Checkbox example

Checkbox example

Hello and welcome back, we'll start off with our checkbooks control example. We have a checked property in the input HTML element which can be set to a boolean type for the input. You have usually seen a checkbooks control on the forms in many applications where you are actually accepting the terms and services or the privacy policy. The checkbox example is pretty similar to an text input example as well. The only difference is that we have two properties being changed. The type is going to be of type checkbox and there is a checked property. Once you select a type to checkbox, rest of the things are going to remain the same. So let's just quickly do that. Over here, I can close down the previous examples. In the components folder, I can create a checkbox example dot tsx, I'll do rafce and the component is ready. Now for this example, we can simply go to our text input example. We can copy the JSX and replace this JSX with the text input example. Now we are going to define the state…

Contents