This is an example of a form with checkboxes and toggle buttons with the use of HTML, CSS, and JavaScript. JavaScript functions have been used to make the form responsive by checking the width of the screen. If the width is less than 400px, the mobile class will be added with the use of add class to apply the mobile view whereas if the width is greater than 400px, the mobile class will be removed with the use of remove class. The CSS class switch has been used for the toggle button which consists of height as 4.4rem, overflow as hidden, width as 7 rem, position as relative, display as inline-block, margin as 0, and padding as 0 whereas the switch label has the styles of width as 100%, font size as 0.5rem, and text-align as center. The CSS style class text transformation has been used with the value of uppercase to convert the text to uppercase. The hover class has been used with the style of cursor as pointer so the mouse pointer will be displayed on the toggle button on a mouse hover event. The style display has been used with the value ‘none' to hide the elements. Source:
This example can be used in any responsive designs as it is flexible, customizable, on/off toggle switches like regular radio buttons. It just uses the field set element which groups the related items in form, radio button which can be toggled. The styling is written using SCSS, using google fonts, and sass mixins. These mixins can be used to create the CSS code that can be reused throughout the website. They act like classes and can be included to add the properties to the classes. These are included using @include. Later the SaSS transpiler can convert it into CSS. Once you see the responsiveness of the code, the properties are switched from auto width to full width. In smaller screens, it adjusts well and is set in full width where as in larger screens it sets itself to auto width. You can use these for smaller screen applications. Source: