탐색

v2.1.0
폼

체크리스트

완료한 항목 수를 자동으로 집계하는 간단한 할 일 목록입니다.

이 페이지의 내용

체크리스트는 설정 단계나 검토 항목처럼 해야 할 일을 간단히 정리한 목록입니다. 각 항목의 레이블에는 네이티브 체크박스와 제목, 한 줄짜리 안내 문구가 들어갑니다. 완료한 항목은 덜 강조되며 제목에 가는 취소선이 표시됩니다. 목록은 완료한 항목 수를 자동으로 집계합니다.

체크리스트

<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>
<div className="card max-w(400) mx-auto">  <div className="card-header">    <h3 className="card-title">Get Atlas ready</h3>  </div>  <ul className="checklist">    <li className="checklist-item">      <label className="checklist-label">        <input type="checkbox" className="checkbox" defaultChecked />        <span className="checklist-body">          <span className="checklist-title">Create a project</span>          <span className="checklist-description">Atlas was created on 3 November.</span>        </span>      </label>    </li>    <li className="checklist-item">      <label className="checklist-label">        <input type="checkbox" className="checkbox" defaultChecked />        <span className="checklist-body">          <span className="checklist-title">Connect a repository</span>          <span className="checklist-description">Deploy every push to the main branch.</span>        </span>      </label>    </li>    <li className="checklist-item">      <label className="checklist-label">        <input type="checkbox" className="checkbox" />        <span className="checklist-body">          <span className="checklist-title">Add a domain</span>          <span className="checklist-description">Point a domain you own at the project.</span>        </span>        <span className="checklist-end"><span className="badge badge-sm">2 min</span></span>      </label>    </li>    <li className="checklist-item">      <label className="checklist-label">        <input type="checkbox" className="checkbox" />        <span className="checklist-body">          <span className="checklist-title">Invite your team</span>          <span className="checklist-description">Members can deploy and read the logs.</span>        </span>      </label>    </li>    <li className="checklist-count">steps done</li>  </ul></div>
<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>
<template>  <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></template>
항목을 체크하면 스크립트 없이도 목록 아래의 집계가 갱신됩니다.

#완료 항목 자동 집계

CSS 카운터 두 개로 항목 수를 집계합니다. checklist-item마다 전체 항목 수가 1씩 늘어납니다. 각 항목은 :has()로 체크박스의 선택 여부를 확인하고, 선택된 경우 완료 항목 수를 1 늘립니다. checklist-count는 두 수를 모두 표시합니다.

카운터는 문서 순서대로 집계하므로, 마크업에서는 두 수가 확정되는 항목 목록 뒤에 집계를 배치하세요. 집계 문구는 숫자 뒤에 오므로 원하는 언어로 번역할 수 있습니다. 두 숫자 사이에 들어가는 구분자는 --checklist-of 속성으로 지정하며 기본값은 ' / '입니다. “2 of 4”로 표시하려면 값을 ' of '로 설정하세요.

집계는 CSS에서 생성하는 콘텐츠입니다. 집계 값은 항상 현재 상태를 반영하지만, 값이 바뀌어도 스크린 리더가 알리지 않습니다. 목록 완료 여부를 알려야 한다면 별도의 상태 메시지를 제공하세요.

#체크리스트 항목

레이블이 행 전체를 차지하므로 텍스트 어디를 눌러도 체크박스를 선택할 수 있습니다. checklist-title에는 인라인 요소를 사용합니다. 완료된 제목의 취소선은 텍스트를 따라 길어지는 배경으로 구현되며, 제목이 여러 줄로 줄바꿈되어도 취소선은 한 줄로 유지됩니다. checklist-end에는 소요 시간처럼 항목 끝에 표시할 정보를 넣습니다.

목록과 마찬가지로 텍스트가 시작하는 위치부터 가는 구분선을 그어 행을 나눕니다. 체크리스트 자체에는 표면이 없으므로 카드 안에 배치하세요.

#접근성

  • <ul> 요소를 사용하세요. 정해진 순서대로 완료해야 하는 단계에는 <ol> 요소를 사용하세요.
  • 체크리스트의 체크박스는 사용자가 직접 상태를 설정하는 컨트롤입니다. 시스템이 완료하는 단계는 단계 표시기로 표시하세요. 사용자가 상태를 바꿀 수 없는 체크박스는 기록이 아니라 비활성화된 컨트롤입니다.
  • 취소선이 있는 제목에는 강조를 낮춘 잉크 색을 적용하되 읽을 수 있는 대비를 유지합니다. 완료 여부는 체크박스의 상태로 전달합니다.

#클래스

클래스설명
checklist목록의 ul에 적용합니다. 단계를 순서대로 진행하는 경우에는 ol에 적용합니다. 전체 단계 수와 체크된 단계 수를 집계합니다.
checklist-itemli에 적용하는 단계입니다. 전체 단계 수에 포함되며, 체크박스가 선택된 동안에는 완료 단계 수에도 포함됩니다
checklist-label레이블은 체크박스와 그 뒤의 텍스트로 구성됩니다. 행 어디를 눌러도 체크박스를 선택할 수 있으며, 터치 화면에서 행의 높이는 44px입니다.
checklist-body단계의 제목과 그 아래 설명
checklist-title인라인 요소에 단계 이름을 표시합니다. 단계가 완료되면 이름에 가는 취소선을 긋습니다
checklist-description제목 아래에 낮은 강조도로 표시하는 한 줄 도움말입니다.
checklist-end단계 끝에 배치할 요소. 링크, 배지, 시간 등을 넣을 수 있습니다.
checklist-count완료한 단계 수와 전체 단계 수를 이 요소의 텍스트 앞에 표시합니다. 마크업에서는 이 요소를 마지막 단계 뒤에 배치합니다.

#사용자 지정 속성

속성기본값설명
--checklist-of' / '개수를 나타내는 두 숫자 사이의 구분자
--checklist-gap.75rem체크박스와 텍스트 사이 간격

#소스

@master/ui/components/checklist.css
/* * Checklist: a short list of things to do, each a native checkbox with a title and a line of help. * A row is a label, so the whole of it checks the box. A step that is done steps back: its title turns to * the muted ink and a hairline is drawn through it from its start, the way a pen would. * The list counts itself. CSS counters add up the rows and, with :has(), the checked ones; checklist-count * writes the two numbers after the rows, so "2 / 5" is always true without a script. * Rows part on hairlines that start at the text, as a list's do. A checklist has no surface of its own. */@layer components.ui {  .checklist {    --checklist-gap: .75rem;    --checklist-padding-y: .6875rem;    /* What stands between the two numbers of the count. */    --checklist-of: ' / ';    display: flex;    flex-direction: column;    min-width: 0;    margin: 0;    padding: 0;    color: var(--color-text-body);    font-size: .875rem;    line-height: 1.45;    list-style: none;    counter-reset: checklist-total checklist-done;    /* On touch a row is 44px: the same line of words with a little more room over and under it. */    @media (pointer: coarse) {      --checklist-padding-y: .75rem;    }  }  /* A step. It counts itself, and counts itself done while its checkbox is checked. */  .checklist-item {    position: relative;    min-width: 0;    margin: 0;    padding: 0;    counter-increment: checklist-total;    &:has(.checkbox:checked) {      counter-increment: checklist-total checklist-done;    }    /* The hairline under a step that another follows; it starts where the words do, past the 18px checkbox. */    &:has(+ .checklist-item)::after {      content: '';      position: absolute;      inset-inline: calc(1.125rem + var(--checklist-gap)) 0;      inset-block-end: 0;      height: 1px;      background: var(--color-line-hair);      pointer-events: none;      /* Forced colors would turn the hairline's fill to the canvas: it keeps a system color. */      @media (forced-colors: active) {        background: GrayText;      }    }  }  /* The label: the checkbox, then the words. The box is level with the first line of the title. */  .checklist-label {    display: flex;    align-items: flex-start;    gap: var(--checklist-gap);    min-width: 0;    padding: var(--checklist-padding-y) 0;    cursor: pointer;    touch-action: manipulation;    -webkit-tap-highlight-color: transparent;    &:has(.checkbox:disabled) {      cursor: not-allowed;    }    .checkbox {      flex: none;      margin-block-start: calc((1lh - var(--check-size)) / 2);    }  }  /* A block, not a grid: an item of a grid is made a block, and the title has to stay inline. */  .checklist-body {    display: block;    flex: 1 1 0;    /* The words and the end share the title's baseline; the box stands on the first line, as the box does. */    align-self: baseline;    min-width: 0;  }  /*   * The title is inline, so the stroke through it is one line however the title wraps: it is a background   * that grows from nothing to the title's whole length.   */  .checklist-title {    background: linear-gradient(currentColor, currentColor) 0 calc(50% + .0625em) / 0 1px no-repeat;    color: var(--color-text-strong);    font-weight: var(--font-weight-control);    /* A long word or an address breaks inside the column, as the line of help under it does. */    overflow-wrap: anywhere;    transition-property: background-size, color;    transition-duration: var(--duration-base), var(--duration-quick);    transition-timing-function: var(--easing-glide);    /* Right to left the pen starts at the right. */    &:dir(rtl) {      background-position-x: 100%;    }    @media (prefers-reduced-motion: reduce) {      transition: none;    }  }  .checklist-item:has(.checkbox:checked) .checklist-title {    background-size: 100% 1px;    color: var(--color-text-muted);  }  .checklist-item:has(.checkbox:disabled) .checklist-title {    color: var(--color-text-disabled);    /* Forced colors would give it the page's text color back: a step that cannot be ticked keeps the system's disabled ink. */    @media (forced-colors: active) {      color: GrayText;    }  }  .checklist-description {    display: block;    margin: .125rem 0 0;    color: var(--color-text-muted);    font-size: .8125rem;    text-wrap: pretty;    overflow-wrap: anywhere;  }  /*   * Something at the end of a step: a link to where it is done, a badge, a time. It belongs to the title, so it   * stands on the title's first line, as the box at the start does, not in the middle of the title and the line of   * help under it.   */  .checklist-end {    display: inline-flex;    flex: none;    align-items: center;    align-self: baseline;    gap: .5rem;    color: var(--color-text-muted);    font-size: .8125rem;    /* A time or a count, in figures of one width, as at the end of a list's row. */    font-variant-numeric: tabular-nums;  }  /*   * The count: how many steps are done, of how many. It comes after the steps in the markup, where the   * counters have their final values; its own words follow the numbers.   */  .checklist-count {    margin: .625rem 0 0;    color: var(--color-text-muted);    font-size: .8125rem;    font-variant-numeric: tabular-nums;    &::before {      content: counter(checklist-done) var(--checklist-of) counter(checklist-total) ' ';      color: var(--color-text-strong);      font-weight: var(--font-weight-control);    }  }}