defuss-shadcn / Website / Comments / comment-header
Comment HeaderBLK
Introduces a discussion with its comment count and sorting options - a native Select, or sort links in a segmented row. Part of the Comments blocks.
On this page (5)
§Default
Title with the count (a Badge), the sort - a native Select in its label - and a follow action, over a rule.
§Sort links
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