FrontendChallenges is a collection of frontend interview questions and answers. It is designed to help you prepare for frontend interviews. It's free and open source.
difficulty: medium
title: Checkbox
template: vanilla
tags: css, design-system, html
Question
One common UI element found in many web applications is a checkbox. While HTML provides a built-in checkbox element, sometimes we need to create custom checkboxes to better suit the design or functionality requirements of our application.
Create a custom checkbox component using HTML, CSS, and JavaScript. The component should have the following features:
Display a custom checkbox icon.
Allow toggling between checked and unchecked states when clicked.
Allow states like hover, focus, intermediate and disabled.
Allow small, medium and large size variants.
Template
styles.css
body {
font-family: sans-serif;
}
h1 {
font-size: 1.5rem;
}
Info
Question
One common UI element found in many web applications is a checkbox. While HTML provides a built-in checkbox element, sometimes we need to create custom checkboxes to better suit the design or functionality requirements of our application.
Create a custom checkbox component using HTML, CSS, and JavaScript. The component should have the following features:
small
,medium
andlarge
size variants.Template
styles.css
index.js
index.html