Checkbox & switch
Real checkbox and radio inputs with the Momo look: ink boxes, a yellow fill when on, and a tiny hard shadow on hover. They work without JavaScript.
Checkbox
Put the input inside a <label class="check">: the whole label is clickable.
<div class="check-group">
<label class="check"><input type="checkbox" checked> Remember me</label>
<label class="check"><input type="checkbox"> Send me product news</label>
<label class="check"><input type="checkbox" data-momo-indeterminate> Some files (mixed)</label>
<label class="check"><input type="checkbox" disabled> Disabled</label>
<label class="check"><input type="checkbox" checked disabled> Disabled and on</label>
</div>Radio
<fieldset class="check-group">
<legend class="form-label">Billing</legend>
<label class="check"><input type="radio" name="billing" checked> Monthly</label>
<label class="check"><input type="radio" name="billing"> Yearly <span class="badge badge-cyan">-20%</span></label>
</fieldset>With a description
Wrap the text in a <span> and add a .check-desc line.
<div class="check-group">
<label class="check">
<input type="checkbox" checked>
<span>Email digest <small class="check-desc">One email every Monday with what changed.</small></span>
</label>
<label class="check">
<input type="checkbox">
<span>Mentions <small class="check-desc">Tell me when someone tags me.</small></span>
</label>
</div>Switch
.switch for on/off settings that take effect right away. .switch-pill rounds it.
<div class="check-group">
<label class="switch"><input type="checkbox" role="switch" checked> Notifications</label>
<label class="switch"><input type="checkbox" role="switch"> Dark mode</label>
<label class="switch switch-pill"><input type="checkbox" role="switch" checked> Pill switch</label>
<label class="switch"><input type="checkbox" role="switch" disabled> Disabled</label>
</div>Switch with words
.switch-text shows a short word in the track from data-on and data-off. Keep the words short (2 to 3 letters).
<div class="check-group">
<label class="switch switch-text"><input type="checkbox" role="switch" data-on="On" data-off="Off" checked> Email digest</label>
<label class="switch switch-text"><input type="checkbox" role="switch" data-on="Yes" data-off="No"> Public profile</label>
</div>Settings rows
.switch-end puts the label first and the switch at the end of the row, like a phone settings screen.
<div class="card">
<div class="card-section">
<label class="switch switch-end"><input type="checkbox" role="switch"> Dark mode</label>
</div>
<div class="card-section">
<label class="switch switch-end switch-text"><input type="checkbox" role="switch" data-on="On" data-off="Off" checked> Email digest</label>
</div>
<div class="card-section">
<label class="switch switch-end"><input type="checkbox" role="switch" checked><span>Sounds <small class="check-desc">Play a sound for new messages.</small></span></label>
</div>
</div>Colors and sizes
.check-<color> or .switch-<color> changes the "on" color. .check-lg and .switch-lg are bigger.
<label class="check check-green"><input type="checkbox" checked> Green</label>
<label class="check check-violet"><input type="radio" name="clr" checked> Violet</label>
<label class="check check-cyan check-lg"><input type="checkbox" checked> Large cyan</label>
<label class="switch switch-pink"><input type="checkbox" role="switch" checked> Pink</label>
<label class="switch switch-green switch-lg"><input type="checkbox" role="switch" checked> Large green</label>Inline group
<fieldset class="check-group check-inline">
<legend class="form-label">Skills</legend>
<label class="check"><input type="checkbox" checked> Business</label>
<label class="check"><input type="checkbox"> Marketing</label>
<label class="check"><input type="checkbox" checked> Interface design</label>
<label class="check"><input type="checkbox"> Development</label>
</fieldset>Choice cards
.check-card makes the whole label a card. The picked one gets a tint and a hard shadow. .check-cards lays them out in a grid.
<fieldset class="check-group">
<legend class="form-label">Plan</legend>
<div class="check-cards">
<label class="check check-card"><input type="radio" name="plan"><span>Basic <small class="check-desc">$0 / month · 1 user</small></span></label>
<label class="check check-card"><input type="radio" name="plan" checked><span>Pro <small class="check-desc">$29 / month · 10 users</small></span></label>
<label class="check check-card"><input type="radio" name="plan"><span>Team <small class="check-desc">$79 / month · unlimited</small></span></label>
</div>
</fieldset>Select all
Give a checkbox data-momo-check-all with a selector: it checks or clears every match, and shows a dash when only some are checked. Needs momo.js.
<div class="check-group">
<label class="check"><input type="checkbox" data-momo-check-all="#files input"> <b>All files</b></label>
<div class="check-group docs-indent" id="files">
<label class="check"><input type="checkbox" checked> UI Design.sketch</label>
<label class="check"><input type="checkbox"> Wireframe for team.figma</label>
<label class="check"><input type="checkbox"> Presentation approval.key</label>
</div>
</div>Validation
You need to agree to continue.
<label class="check"><input type="checkbox" class="is-invalid" aria-invalid="true" aria-describedby="terms-msg"> I agree to the terms</label>
<p class="form-error" id="terms-msg"><i class="mi mi-circle-alert"></i> You need to agree to continue.</p>Accessibility
- The label wraps the input, so tapping the text works and screen readers read it.
- Add
role="switch"on switches so they are read as on/off. - Group related boxes in a
<fieldset>with a<legend>. - On touch screens each row is at least 40px tall.
Variables
| Variable | Default |
|---|---|
--check-color | Brand (the "on" fill) |
--check-mark | Ink (check, dot and knob when on) |
--check-size | 1.25rem |
--check-card-min | 200px (on .check-cards) |