Components / Forms
Checkbox
A control that allows the user to toggle between checked and not checked.
<div class="field" data-orientation="horizontal">
<input class="checkbox" type="checkbox" id="demo-checkbox" checked>
<label class="label" for="demo-checkbox">Accept terms and conditions</label>
</div>Installation
pnpm dlx loseta add checkboxnpx loseta add checkboxExamples
With description
By clicking this checkbox, you agree to the terms and conditions.
<div class="field" data-orientation="horizontal">
<input class="checkbox" type="checkbox" id="demo-checkbox-description" checked>
<section>
<label class="label" for="demo-checkbox-description">Accept terms and conditions</label>
<p>By clicking this checkbox, you agree to the terms and conditions.</p>
</section>
</div>Disabled
<div class="field">
<label class="label" for="demo-checkbox-disabled">
<input class="checkbox" type="checkbox" id="demo-checkbox-disabled" disabled>
Enable notifications
</label>
</div>Invalid
You must accept the terms and conditions to continue.
<div class="field" data-orientation="horizontal" aria-invalid="true">
<input class="checkbox" type="checkbox" id="demo-checkbox-invalid" aria-invalid="true">
<section>
<label class="label" for="demo-checkbox-invalid">Accept terms and conditions</label>
<p role="alert">You must accept the terms and conditions to continue.</p>
</section>
</div>Group
<fieldset class="fieldset" style="max-width: 20rem">
<legend data-variant="label">Show these items on the desktop:</legend>
<p>Select the items you want to show on the desktop.</p>
<div role="group" data-slot="checkbox-group" aria-label="Items shown on the desktop">
<div class="field" data-orientation="horizontal">
<input class="checkbox" type="checkbox" id="demo-checkbox-hard-disks" name="desktop-items" value="hard-disks" checked>
<label class="label" for="demo-checkbox-hard-disks">Hard disks</label>
</div>
<div class="field" data-orientation="horizontal">
<input class="checkbox" type="checkbox" id="demo-checkbox-external-disks" name="desktop-items" value="external-disks">
<label class="label" for="demo-checkbox-external-disks">External disks</label>
</div>
<div class="field" data-orientation="horizontal">
<input class="checkbox" type="checkbox" id="demo-checkbox-cds" name="desktop-items" value="cds" checked>
<label class="label" for="demo-checkbox-cds">CDs, DVDs, and iPods</label>
</div>
<div class="field" data-orientation="horizontal">
<input class="checkbox" type="checkbox" id="demo-checkbox-servers" name="desktop-items" value="servers">
<label class="label" for="demo-checkbox-servers">Connected servers</label>
</div>
</div>
</fieldset>With title
<div class="field" style="max-width: 28rem">
<label class="label" for="demo-checkbox-notifications">
<div class="field" data-orientation="horizontal">
<input class="checkbox" type="checkbox" id="demo-checkbox-notifications" checked>
<section>
<h3>Enable notifications</h3>
<p>You can enable or disable notifications at any time.</p>
</section>
</div>
</label>
</div>In table
| Name | Role | ||
|---|---|---|---|
| Sarah Chen | sarah.chen@example.com | Admin | |
| Marcus Rodriguez | marcus.rodriguez@example.com | User | |
| Priya Patel | priya.patel@example.com | User | |
| David Kim | david.kim@example.com | Editor |
<div class="table-container">
<table class="table">
<caption>Team members and their roles.</caption>
<thead>
<tr>
<th>
<input class="checkbox" type="checkbox" role="checkbox" aria-label="Select all rows">
</th>
<th>Name</th>
<th>Email</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<tr aria-selected="true">
<td><input class="checkbox" type="checkbox" role="checkbox" aria-label="Select Sarah Chen" checked></td>
<td>Sarah Chen</td>
<td>sarah.chen@example.com</td>
<td>Admin</td>
</tr>
<tr aria-selected="true">
<td><input class="checkbox" type="checkbox" role="checkbox" aria-label="Select Marcus Rodriguez" checked></td>
<td>Marcus Rodriguez</td>
<td>marcus.rodriguez@example.com</td>
<td>User</td>
</tr>
<tr>
<td><input class="checkbox" type="checkbox" role="checkbox" aria-label="Select Priya Patel"></td>
<td>Priya Patel</td>
<td>priya.patel@example.com</td>
<td>User</td>
</tr>
<tr>
<td><input class="checkbox" type="checkbox" role="checkbox" aria-label="Select David Kim"></td>
<td>David Kim</td>
<td>david.kim@example.com</td>
<td>Editor</td>
</tr>
</tbody>
</table>
</div>Accessibility and behavior
- The .checkbox class is required. Use native checked/disabled and aria-invalid="true"; set the indeterminate property from JavaScript. Groups compose with .fieldset, a legend and [data-slot="checkbox-group"].
Files
components/checkbox.cssbasestyles/nova/checkbox.cssstyleInstall contract
The CLI writes the base file under components/, the visual file for the selected style under styles/<name>/, and any primitive dependency underprimitives/. The generated index.css imports them in the right layer order.