Theme
On this page (5)
Component Skill — components/comment-header/component-skill.md

Native basis

A <header>: the title with the comment count (a Badge), the sort - a native Select inside its <label>, or sort links with aria-current - and optional actions.

Built from

Badge, Select, Button, Toggle Group, Avatar, Alert.

Web Platform APIs

<select><label>aria-current

Classes

.mk-comment-header.mk-comment-header-title.mk-comment-header-actions.mk-comment-header-sort.mk-comment-header-tabs.mk-comment-header-people

Data attributes

data-variant="plain"; .mk-comment-header-tabs for sort links; .mk-comment-header-people (an Avatar group + a sentence).

§Default

Title with the count (a Badge), the sort - a native Select in its label - and a follow action, over a rule.

The sort as links (aria-current marks the order) in a segmented row - no script at all; data-variant='plain' drops the rule.

§Toggle sort and participants

The sort as a Toggle Group (single), and who is talking - an Avatar group with a sentence on its own row (.mk-comment-header-people).

§Closed

A closed thread: the header stays, an Alert explains - the count still tells how much was said.

§CSS view file

/* -- Comment Header (website) ---------------------------------------
   Introduces a discussion: the title with the comment count (a Badge) and
   the sorting - a native Select, or sort links (aria-current) in the tabs
   variant - plus optional actions (follow the thread). */
@layer components {
  .mk-comment-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    box-sizing: border-box;
    width: 100%;
    padding-block-end: 0.875rem;
    border-block-end: 1px solid var(--border);
  }
  .mk-comment-header-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .mk-comment-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }
  /* "Sort by" + the select, one label */
  .mk-comment-header-sort {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    white-space: nowrap;
    & .select { width: auto; }
  }
  /* sort links: a small segmented row */
  .mk-comment-header-tabs {
    display: inline-flex;
    gap: 0.125rem;
    padding: 0.1875rem;
    border-radius: var(--radius-md);
    background: var(--muted);
    & a {
      padding: 0.25rem 0.75rem;
      border-radius: calc(var(--radius-md) - 2px);
      color: var(--muted-foreground);
      font-size: 0.8125rem;
      font-weight: 500;
      text-decoration: none;
      transition: color 120ms, background-color 120ms;
      &:hover { color: var(--foreground); }
      &[aria-current] { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs); }
      &:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
    }
  }
  /* who is talking: an Avatar group + a sentence, on its own row */
  .mk-comment-header-people {
    display: flex;
    flex-basis: 100%;
    align-items: center;
    gap: 0.625rem;
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    & strong { color: var(--foreground); font-weight: 600; }
  }
  /* plain: no rule under the header */
  .mk-comment-header[data-variant="plain"] { padding-block-end: 0; border-block-end: 0; }
  /* -- Accessibility ------------------------------------------- */
  @media (prefers-reduced-motion: reduce) {
    .mk-comment-header-tabs a { transition: none; }
  }
  @media (prefers-contrast: more) {
    .mk-comment-header-sort,
    .mk-comment-header-tabs a { color: var(--foreground); }
  }
  @media (forced-colors: active) {
    .mk-comment-header-tabs { border: 1px solid CanvasText; }
    .mk-comment-header-tabs a[aria-current] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  }
}

Comments, ideas or improvements? Edit this page's source on GitHub