Skip to content

Custom Checkboxes and Switches

Restyled Bootstrap 5 checkboxes, large switches, select-all with indeterminate state, radio cards and colored checkbox chips.

Also known as: custom checkbox styles, toggle switch checkbox, radio button cards, select all checkbox

Custom Checkboxes and Switches live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A set of restyled Bootstrap 5 checkboxes, switches and radios in a fresh green settings panel: large switches with helper text, a "select all" checkbox with a mixed state, radio cards for a billing choice and colored round checkbox chips. Use it as a starting point for settings pages, permission editors, filters and onboarding forms.

How it works

The root is section.cs-panel. Every group is a fieldset.cs-card with a legend, laid out in a Bootstrap row g-3 that shows two columns from the md breakpoint. All controls keep the standard Bootstrap markup (form-check, form-switch, form-check-input, form-check-label), so they work like normal inputs. The .cs-row class replaces Bootstrap's float layout with flexbox, which keeps inputs of any size aligned with their label and the optional .cs-hint text inside .cs-row__text.

.cs-switch makes the switch wider and taller, moves it to the right with order: 2 and keeps the knob white, also on focus, by overriding --bs-form-switch-bg. .cs-switch--sm is a compact version. .cs-check draws a rounded square checkbox and .cs-check--round a circle. The billing radios are wrapped in label.cs-tile, and :has(.cs-radio:checked) highlights the selected card. In the "Labels" card, each .cs-chip sets its own color through the .cs-tone-rose, .cs-tone-amber and .cs-tone-sky classes.

The only script handles .cs-group. Changing the [data-cs-all] checkbox checks or clears every [data-cs-item], and changing any item runs sync(), which sets the master to checked, unchecked or indeterminate and writes the "2 of 4 selected" text into .cs-count. Without JavaScript all inputs still work; only the select-all link is missing.

Customization

  • --cs-color and --cs-color-rgb in .cs-panel: change the checked color and the focus ring of every control.
  • --cs-check-size in .cs-panel: make the checkboxes larger or smaller.
  • --cs-switch-width and --cs-switch-height in .cs-panel: resize the switches.
  • --cs-radius in .cs-panel: round or square the cards and radio tiles.
  • Add .cs-tone-rose, .cs-tone-amber or .cs-tone-sky to any .cs-row, or define a new tone class with both color variables.
  • Remove .cs-check--round from a checkbox to give it the rounded square shape.
  • grid-template-columns in .cs-tiles: show the radio cards in one column or add a third option.

Use cases

  • Settings pages: large switches with helper text make preferences easy to turn on and off
  • Permission editors: a select all checkbox shows a mixed state when only some options are chosen
  • Billing pages: radio cards let customers choose between plans with a clear selected state
  • Onboarding and filter forms: colored round checkbox chips make topic or category picking more inviting

Accessibility

The controls are native inputs, so Space toggles them and arrow keys move between the radios. Each group is a fieldset with a legend, the switches use role="switch", and helper text is connected through aria-describedby. The master checkbox exposes the mixed state through the native indeterminate property and is described by the aria-live counter. The focus ring uses the accent color, disabled rows are dimmed and show a not-allowed cursor, and transitions are disabled under prefers-reduced-motion: reduce.

Usage notes

Requires only Bootstrap 5 CSS; the script is optional. The radio highlight uses :has(), which is supported by all current browsers; in older ones the radio itself still shows the selection.

Custom Checkboxes and Switches at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5
Layout
Responsive, works on mobile
Category
Checkboxes & Radios
License
Free for personal and commercial use

Questions about this template

Can I use the Custom Checkboxes and Switches code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
Custom Checkboxes and Switches – free Bootstrap 5 checkbox & radio template
Custom Checkboxes and Switches · free Bootstrap 5 checkbox & radio template

More Checkboxes & Radios

Checkbox List with Select All – free Bootstrap 6 checkbox & radio template

Checkbox List with Select All

Bootstrap 6 member list with a select-all checkbox that turns indeterminate, a live counter, Shift+click ranges and bulk action buttons.

Radio Button Cards – free Bootstrap 6 checkbox & radio template

Radio Button Cards

Bootstrap 6 radio inputs styled as selectable plan and shipping cards with .form-field-card, a live price summary and a simulated submit.

Checkbox and Radio Styles – free Bootstrap 6 checkbox & radio template

Checkbox and Radio Styles

Bootstrap 6 .check and .radio inputs in default, inline, disabled and indeterminate states, with size modifiers and a brand color set by CSS variables.

Radio Card Selector – free Tailwind CSS checkbox & radio template

Radio Card Selector

Tailwind CSS plan picker that turns native radio inputs into selectable pricing cards with a check indicator, focus ring and live summary.