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

Native basis

A <header> - category link, the title (h1), a subtitle, the byline (Avatar, author link, <time>, read time) and an optional <figure> lead image with its <figcaption>.

Built from

Avatar, Breadcrumb, Badge, Button, Swap, Progress.

Web Platform APIs

<figure><time>Container queriestext-wrap: balance

Classes

.mk-article-header.mk-article-header-category.mk-article-header-title.mk-article-header-subtitle.mk-article-header-byline.mk-article-header-author.mk-article-header-meta.mk-article-header-media.mk-article-header-tags.mk-article-header-actions.mk-article-header-series

Data attributes

data-align="center", data-variant="cover"; data-variant (split, editorial); .mk-article-header-tags, .mk-article-header-actions, .mk-article-header-series.

§Default

Category, title, subtitle, the byline (Avatar, author, date, read time) and a 16:9 lead image with its caption.

§Centered

data-align='center' - for essays and announcements.

§Cover

data-variant='cover': the image fills the header and the copy sits on a dark gradient; the caption becomes a credit in the corner.

§Breadcrumb, series and actions

A Breadcrumb instead of the category, a series line (Part 2 of 4 + a Progress bar), tag Badges, two authors in an Avatar group and actions at the end of the byline: listen, a bookmark Swap, share.

§Split

data-variant='split': the copy beside a tall image - the image moves under the copy when the header is narrow (a container query).

§Editorial

data-variant='editorial': a serif title, an italic subtitle and ornament rules around the byline - long-form essays.

§CSS view file

/* -- Article Header (website) ---------------------------------------
   Presents an article: category, the title (h1), a subtitle, the byline
   (Avatar, author link, date, read time) and an optional lead image with
   its caption. Centered, or as a cover - the copy over the image. */
@layer components {
  .mk-article-header {
    container: mk-article-header / inline-size;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    box-sizing: border-box;
    width: 100%;
    max-width: 52rem;
    margin-inline: auto;
    padding-inline: 1.25rem;
  }
  .mk-article-header-category {
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    &:hover { text-decoration: underline; text-underline-offset: 0.2em; }
    &:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-sm); }
  }
  .mk-article-header-title {
    margin: 0;
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
    text-wrap: balance;
  }
  .mk-article-header-subtitle {
    margin: 0;
    color: var(--muted-foreground);
    font-size: 1.1875rem;
    line-height: 1.5;
    text-wrap: pretty;
  }
  .mk-article-header-byline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-block-start: 0.5rem;
    font-size: 0.875rem;
  }
  .mk-article-header-author {
    color: var(--foreground);
    font-weight: 600;
    text-decoration: none;
    &:hover { text-decoration: underline; text-underline-offset: 0.2em; }
    &:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-sm); }
  }
  /* date · read time · … - dots between the parts */
  .mk-article-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.5rem;
    color: var(--muted-foreground);
    & > * + *::before { content: "·"; margin-inline-end: 0.5rem; }
  }
  .mk-article-header-media {
    width: 100%;
    margin: 1rem 0 0;
    & img {
      display: block;
      width: 100%;
      aspect-ratio: 16 / 9;
      object-fit: cover;
      border-radius: var(--radius-lg);
      background: var(--muted);
    }
    & figcaption {
      margin-block-start: 0.5rem;
      color: var(--muted-foreground);
      font-size: 0.8125rem;
    }
  }
  /* tags (Badges) and actions (listen, save, share) - each a row */
  .mk-article-header-tags { display: flex; flex-wrap: wrap; gap: 0.375rem; }
  .mk-article-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin-inline-start: auto;
  }
  /* the byline grows to hold actions at its end */
  .mk-article-header-byline:has(.mk-article-header-actions) { align-self: stretch; flex-wrap: wrap; }
  /* a series line: "Part 2 of 4" + a Progress bar */
  .mk-article-header-series {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    & .progress { width: 8rem; }
    & strong { color: var(--foreground); font-weight: 600; }
  }
  @container mk-article-header (min-width: 40rem) {
    .mk-article-header-title { font-size: 3rem; }
  }
  /* split: the copy beside the image (wraps under it when narrow) */
  .mk-article-header[data-variant="split"] {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    align-items: center;
    gap: 1rem 2.5rem;
    max-width: 80rem;
    & > :not(.mk-article-header-media) { grid-column: 1; }
    & .mk-article-header-media { grid-column: -2; grid-row: 1 / span 6; margin: 0; }
    & .mk-article-header-media img { aspect-ratio: 4 / 5; }
  }
  /* one column: the image follows the copy */
  @container mk-article-header (max-width: 47rem) {
    .mk-article-header[data-variant="split"] .mk-article-header-media { grid-row: auto; }
  }
  /* editorial: serif, centered, an ornament and an italic subtitle */
  .mk-article-header[data-variant="editorial"] {
    align-items: center;
    text-align: center;
    & .mk-article-header-category { color: var(--muted-foreground); font-size: 0.75rem; letter-spacing: 0.2em; text-transform: uppercase; }
    & .mk-article-header-title { font-family: var(--font-serif); font-weight: 700; letter-spacing: -0.015em; }
    & .mk-article-header-subtitle { font-family: var(--font-serif); font-style: italic; }
    & .mk-article-header-byline::before,
    & .mk-article-header-byline::after { content: ""; width: 2rem; height: 1px; background: var(--border); }
  }
  .mk-article-header[data-align="center"] {
    align-items: center;
    text-align: center;
  }
  /* cover: the image fills the header, the copy sits on it */
  .mk-article-header[data-variant="cover"] {
    justify-content: flex-end;
    max-width: 80rem;
    min-height: 26rem;
    padding: 2rem 1.5rem;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: #0b0b0f;
    color: #fff;
    & .mk-article-header-media {
      position: absolute;
      inset: 0;
      margin: 0;
      & img { height: 100%; aspect-ratio: auto; border-radius: 0; }
      & figcaption {
        position: absolute;
        inset-block-start: 0.75rem;
        inset-inline-end: 1rem;
        margin: 0;
        color: rgb(255 255 255 / 0.75);
        font-size: 0.75rem;
      }
      &::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(to top, rgb(0 0 0 / 0.85), rgb(0 0 0 / 0.3) 60%, rgb(0 0 0 / 0.15));
      }
    }
    & > :not(.mk-article-header-media) { position: relative; z-index: 1; max-width: 44rem; }
    & :is(.mk-article-header-subtitle, .mk-article-header-meta) { color: rgb(255 255 255 / 0.82); }
    & :is(.mk-article-header-category, .mk-article-header-author) { color: #fff; }
  }
  /* -- Accessibility ------------------------------------------- */
  @media (prefers-contrast: more) {
    .mk-article-header-subtitle,
    .mk-article-header-meta { color: var(--foreground); }
  }
  @media (forced-colors: active) {
    .mk-article-header[data-variant="cover"] { border: 1px solid CanvasText; }
    .mk-article-header-media::after { display: none; }
  }
}

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