Skip to content

Tag

For the several labels a person pins on one item, and later filters by.

Data display

Live preview

Source

<ul class="dc-tags">
  <li><span class="dc-tag">용접</span></li>
  <li><span class="dc-tag">고소작업</span></li>
  <li><span class="dc-tag">야간</span></li>
  <li><span class="dc-tag">3공구</span></li>
</ul>
.dc-tags {
  display: flex; flex-wrap: wrap; gap: var(--dc-2);
  margin: 0; padding: 0; list-style: none;
  font-family: var(--dc-font);
}
.dc-tag {
  display: inline-flex; align-items: center; gap: var(--dc-1);
  min-height: 30px; padding: 0 var(--dc-3);
  border: 1px solid var(--dc-line);
  border-radius: var(--dc-r-full);
  background: var(--dc-surface);
  color: var(--dc-text-sub);
  font-family: var(--dc-font); font-size: 13px; line-height: 1;
  white-space: nowrap;
}
.dc-tag--removable { padding-right: var(--dc-1); }
.dc-tag__remove {
  position: relative;
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border: 0; border-radius: var(--dc-r-full);
  background: transparent; color: var(--dc-text-mute);
  font-family: inherit; font-size: 14px; line-height: 1;
  cursor: pointer;
}
.dc-tag__remove::before { content: ""; position: absolute; inset: -11px; }
.dc-tag__remove:hover { background: var(--dc-sunken); color: var(--dc-text); }
.dc-tagset { margin: 0; padding: 0; border: 0; }
.dc-tagset__legend {
  padding: 0 0 var(--dc-2);
  font-family: var(--dc-font); font-size: 13px; font-weight: 700;
  color: var(--dc-text);
}
.dc-tag--choice { position: relative; cursor: pointer; transition: background var(--dc-fast), border-color var(--dc-fast); }
.dc-tag__input {
  position: absolute; width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
}
.dc-tag--choice:has(.dc-tag__input:checked) {
  background: var(--dc-brand-soft);
  border-color: var(--dc-brand);
  color: var(--dc-brand-text);
  font-weight: 700;
}
.dc-tag--choice:has(.dc-tag__input:focus-visible) {
  outline: 2px solid var(--dc-brand); outline-offset: 2px;
}

How to use it

  • Tags are words people chose; badges are states the system set — don't mix them
  • A removable tag names what will be removed in the button's label
  • Selectable tags are checkboxes or radios so the keyboard can reach them

Watch out for

  • The × may look small but its hit area is 44px — a finger can't land on a 12px circle
  • Past three wrapped rows, collapse the list behind a 'show more'

Next