Skip to content

Checkbox / Radio

Custom checkbox and radio styling for native form controls in @bnotk/dsx.

Live Preview
<link rel="stylesheet" href="@bnotk/dsx/css/checkbox-radio.css">

Or use the full bundle:

<link rel="stylesheet" href="@bnotk/dsx/css/index.css">
ClassPurpose
.dsx-checkLabel wrapper that aligns the control and text
.dsx-check__inputBase custom control for native checkbox or radio inputs
.dsx-check__labelText label beside the control
.dsx-check-groupVertical stack of checks
.dsx-check-group--inlineHorizontal / wrapped layout
.dsx-check-group--errorError styling for controls inside the group
  • .dsx-check:has(input:disabled) reduces opacity and switches the cursor to not-allowed.
  • Hover changes the control border to var(--ds2-color-main).
  • :focus-visible uses var(--ds2-shadow-focus).
  • Checkboxes use a rounded-square shape, a navy checked state, and SVG data URIs for the checkmark and indeterminate dash.
  • Radios are circular and become solid-ring indicators by increasing border width to 5px when checked.
  • Disabled controls use var(--ds2-color-grey-2) and var(--ds2-color-grey-1).
  • .dsx-check-group--error sets the control border to var(--ds2-color-error).
<label class="dsx-check">
<input class="dsx-check__input" type="checkbox" checked>
<span class="dsx-check__label">Receive updates</span>
</label>
  • Keep the real native <input> in the DOM.
  • Wrap each control with a <label> or connect it through for/id.
  • Use <fieldset> and <legend> for grouped checkboxes or radio sets.
  • Share the same name for mutually exclusive radio buttons.