Checklist
A short list of things to do that counts how many are done.
On this page
A checklist is a short list of things to do: the steps of a setup, the points of a review. Each step is a native checkbox in a label with a title and a line of help. A step that is done steps back, with a hairline through its title, and the list counts itself.
Checklist
<div class="card max-w(400) mx-auto"> <div class="card-header"> <h3 class="card-title">Get Atlas ready</h3> </div> <ul class="checklist"> <li class="checklist-item"> <label class="checklist-label"> <input type="checkbox" class="checkbox" checked> <span class="checklist-body"> <span class="checklist-title">Create a project</span> <span class="checklist-description">Atlas was created on 3 November.</span> </span> </label> </li> <li class="checklist-item"> <label class="checklist-label"> <input type="checkbox" class="checkbox" checked> <span class="checklist-body"> <span class="checklist-title">Connect a repository</span> <span class="checklist-description">Deploy every push to the main branch.</span> </span> </label> </li> <li class="checklist-item"> <label class="checklist-label"> <input type="checkbox" class="checkbox"> <span class="checklist-body"> <span class="checklist-title">Add a domain</span> <span class="checklist-description">Point a domain you own at the project.</span> </span> <span class="checklist-end"> <span class="badge badge-sm">2 min</span> </span> </label> </li> <li class="checklist-item"> <label class="checklist-label"> <input type="checkbox" class="checkbox"> <span class="checklist-body"> <span class="checklist-title">Invite your team</span> <span class="checklist-description">Members can deploy and read the logs.</span> </span> </label> </li> <li class="checklist-count">steps done</li> </ul></div>#The list counts itself
Two CSS counters do the arithmetic. Every checklist-item adds one to the total, and an item whose checkbox is checked, which the item knows through :has(), adds one to the number done. checklist-count prints both.
Counters run in document order, so the count comes after the steps in the markup: that is where both numbers are final. Its own text follows the numbers, which keeps the words yours to translate. --checklist-of is what stands between the two numbers, ' / ' by default; set it to ' of ' for "2 of 4".
The count is generated content. It is right at every moment, but a change to it is not announced: when finishing the list matters, say so in a status message of your own.
#A step
The label is the whole row, so a press anywhere on the words checks the box. checklist-title is an inline element on purpose: the stroke through a finished title is a background that grows along the text, and it stays one line however the title wraps. checklist-end holds something at the end of a step, such as how long it takes.
Rows part on hairlines that start at the text, as a list's do. The checklist has no surface: put it in a card.
#Accessibility
- Use a
<ul>, or an<ol>when the steps must be done in order. - A checkbox here is state the reader sets. For steps the system completes, show them with steps instead: a checkbox that a reader cannot change is a disabled control, not a record.
- The struck title keeps the muted ink at a readable contrast; the meaning is carried by the checkbox, not by the stroke.
#Classes
| Class | Description |
|---|---|
checklist | The list, on a ul, or an ol when the steps are done in order; it counts its steps and the checked ones |
checklist-item | A step, on the li; it counts itself, and counts itself done while its checkbox is checked |
checklist-label | The label: the checkbox, then the words. The whole row checks the box, and is 44px tall on a touch screen |
checklist-body | The words of a step: a title over a description |
checklist-title | The step's name, on an inline element; a hairline is drawn through it when the step is done |
checklist-description | A muted line of help under the title |
checklist-end | Something at the end of a step: a link, a badge, a time |
checklist-count | Steps done and steps in all, written before its own text; it comes after the last step in the markup |
#Custom properties
| Property | Default | Description |
|---|---|---|
--checklist-of | ' / ' | What stands between the two numbers of the count |
--checklist-gap | .75rem | Space between the checkbox and the words |
#Related
- CheckboxA small native well that fills with ink when checked.
- StepsWhere a reader is in a short sequence.
- ListRows of things with media, words and something at the end.