# Article index

A company journal’s index: a featured story with gradient art drawn from tokens, tag filters as toggle `Button`s, a responsive `Grid` of article `Card`s with a tag `Badge`, title, excerpt, author initials, date and reading time, and numbered pages.

**Example: The Fieldnote Journal** (`examples/recipes/article-index.tsx`)

```tsx
'use client'

import { Badge, Body, Button, Card, Grid, Heading, Stack, Text } from '@blocks/design-system'
import { ChevronLeft, ChevronRight } from 'lucide-react'
import { useState } from 'react'
import styles from './article-index.module.css'

const tags = ['Design', 'Engineering', 'Research', 'Culture'] as const
type Tag = (typeof tags)[number]

interface Article {
  slug: string
  tag: Tag
  title: string
  excerpt: string
  author: string
  initials: string
  date: string
  minutes: number
}

const featured: Article = {
  slug: 'design-review-in-half',
  tag: 'Design',
  title: 'How we cut design review time in half',
  excerpt:
    'Reviews used to be a weekly hour-long meeting. Now they’re a written thread with a 24-hour window, a checklist, and a meeting only when the thread can’t settle it.',
  author: 'Priya Natarajan',
  initials: 'PN',
  date: 'Nov 24, 2026',
  minutes: 9,
}

const articles: Article[] = [
  { slug: 'tokens-not-themes', tag: 'Design', title: 'Tokens, not themes', excerpt: 'Why our dark mode is a second set of values, not a second stylesheet.', author: 'Maya Okafor', initials: 'MO', date: 'Nov 19, 2026', minutes: 6 },
  { slug: 'boring-queues', tag: 'Engineering', title: 'In praise of boring queues', excerpt: 'We replaced a clever scheduler with a table and a cron job. Pages went quiet.', author: 'Tomás Reyes', initials: 'TR', date: 'Nov 14, 2026', minutes: 8 },
  { slug: 'interview-twelve', tag: 'Research', title: 'What twelve onboarding interviews taught us', excerpt: 'New admins don’t read the setup guide. They copy a colleague’s workspace.', author: 'Elena Vasquez', initials: 'EV', date: 'Nov 10, 2026', minutes: 11 },
  { slug: 'quiet-fridays', tag: 'Culture', title: 'A year of quiet Fridays', excerpt: 'No meetings, no launches, no pings. What it cost and what it gave back.', author: 'Jun Park', initials: 'JP', date: 'Nov 5, 2026', minutes: 5 },
  { slug: 'focus-rings', tag: 'Design', title: 'Focus rings people don’t turn off', excerpt: 'A visible focus style that suits mouse users too, and how we tested it.', author: 'Maya Okafor', initials: 'MO', date: 'Oct 29, 2026', minutes: 4 },
  { slug: 'flaky-tests', tag: 'Engineering', title: 'Our flaky test budget', excerpt: 'Every team gets three flaky tests. The fourth blocks their next release.', author: 'Sam Whitfield', initials: 'SW', date: 'Oct 22, 2026', minutes: 7 },
  { slug: 'diary-study', tag: 'Research', title: 'Running a diary study on a shoestring', excerpt: 'Two weeks, nine participants, one shared notebook, and no special tools.', author: 'Elena Vasquez', initials: 'EV', date: 'Oct 15, 2026', minutes: 10 },
  { slug: 'writing-weeks', tag: 'Culture', title: 'Writing weeks', excerpt: 'Once a quarter, everyone writes down how their corner of the product works.', author: 'Priya Natarajan', initials: 'PN', date: 'Oct 8, 2026', minutes: 6 },
  { slug: 'edge-cache', tag: 'Engineering', title: 'Moving search to the edge', excerpt: 'Median search latency fell from 240 ms to 60 ms. Here’s what broke on the way.', author: 'Tomás Reyes', initials: 'TR', date: 'Sep 30, 2026', minutes: 12 },
  { slug: 'empty-states', tag: 'Design', title: 'Empty states are onboarding', excerpt: 'The first screen most people see is an empty one. We gave each a job.', author: 'Jun Park', initials: 'JP', date: 'Sep 23, 2026', minutes: 5 },
]

const perPage = 4

function Byline({ article }: { article: Article }) {
  return (
    <Stack direction="row" gap="sm" align="center" marginTop="sm">
      <span className={styles.avatar} aria-hidden>
        {article.initials}
      </span>
      <span className={styles.bylineText}>
        <Text fontSize="xs" fontWeight="semibold">
          {article.author}
        </Text>
        <Text fontSize="xs" color="text-muted">
          <time>{article.date}</time> · {article.minutes} min read
        </Text>
      </span>
    </Stack>
  )
}

// A journal index: the featured story, tag filters (toggle buttons with
// aria-pressed), a responsive grid and numbered pages.
export default function ArticleIndex() {
  const [tag, setTag] = useState<Tag | null>(null)
  const [page, setPage] = useState(1)

  const filtered = tag ? articles.filter((article) => article.tag === tag) : articles
  const pages = Math.max(1, Math.ceil(filtered.length / perPage))
  const shown = filtered.slice((page - 1) * perPage, page * perPage)

  function chooseTag(next: Tag | null) {
    setTag(next)
    setPage(1)
  }

  // Previous and Next stay focusable at the ends (aria-disabled), so focus is never lost.
  const goTo = (next: number) => setPage(Math.min(Math.max(next, 1), pages))

  return (
    <Stack as="section" gap="xl" aria-labelledby="article-index-title" dangerouslySetClassName={styles.root}>
      <Stack gap="xs">
        <Heading as="h2" id="article-index-title" fontSize="xxl">
          The Fieldnote Journal
        </Heading>
        <Body color="text-muted" margin="none">
          Notes from the team on design, engineering and how we work.
        </Body>
      </Stack>

      {(!tag || tag === featured.tag) && (
        <Card as="article" padding="none" borderRadius="xl" aria-labelledby="article-index-featured" dangerouslySetClassName={styles.featured}>
          <div className={styles.featuredArt} aria-hidden />
          <Stack gap="md" padding="lg" justify="center">
            <Stack direction="row" gap="sm" align="center">
              <Badge tone="accent">Featured</Badge>
              <Badge>{featured.tag}</Badge>
            </Stack>
            <Heading as="h3" id="article-index-featured" fontSize="xl">
              <a href={`#${featured.slug}`} className={styles.titleLink}>
                {featured.title}
              </a>
            </Heading>
            <Body fontSize="sm" color="text-muted" margin="none">
              {featured.excerpt}
            </Body>
            <Byline article={featured} />
          </Stack>
        </Card>
      )}

      <Stack gap="lg">
        <fieldset className={styles.filters}>
          <legend className={styles.legend}>Topics</legend>
          <Button type="button" size="sm" borderRadius="pill" variant={tag ? 'base' : 'primary'} aria-pressed={!tag} onClick={() => chooseTag(null)}>
            All
          </Button>
          {tags.map((option) => (
            <Button
              key={option}
              type="button"
              size="sm"
              borderRadius="pill"
              variant={tag === option ? 'primary' : 'base'}
              aria-pressed={tag === option}
              onClick={() => chooseTag(option)}
            >
              {option}
            </Button>
          ))}
        </fieldset>

        <Grid as="ul" columns={{ base: 1, sm: 2 }} gap="md" aria-label={tag ? `${tag} articles` : 'Latest articles'} dangerouslySetClassName={styles.grid}>
          {shown.map((article) => (
            <li key={article.slug}>
              <Card as="article" padding="none" borderRadius="xl" aria-labelledby={`article-index-${article.slug}`} dangerouslySetClassName={styles.card}>
                <div className={styles.art} data-tag={article.tag} aria-hidden />
                <Stack gap="sm" padding="lg" flex="1">
                  <div>
                    <Badge>{article.tag}</Badge>
                  </div>
                  <Heading as="h3" id={`article-index-${article.slug}`} fontSize="md">
                    <a href={`#${article.slug}`} className={styles.titleLink}>
                      {article.title}
                    </a>
                  </Heading>
                  <Body fontSize="sm" color="text-muted" margin="none" dangerouslySetClassName={styles.excerpt}>
                    {article.excerpt}
                  </Body>
                  <Byline article={article} />
                </Stack>
              </Card>
            </li>
          ))}
        </Grid>

        <nav aria-label="Article pages" className={styles.pagination}>
          <Button type="button" size="sm" variant="ghost" aria-disabled={page === 1} onClick={() => goTo(page - 1)}>
            <ChevronLeft aria-hidden size={14} />
            Previous
          </Button>
          <ol className={styles.pages}>
            {Array.from({ length: pages }, (_, index) => index + 1).map((number) => (
              <li key={number}>
                <Button
                  type="button"
                  size="sm"
                  variant={number === page ? 'base' : 'ghost'}
                  aria-label={`Page ${number}`}
                  aria-current={number === page ? 'page' : undefined}
                  onClick={() => goTo(number)}
                >
                  {number}
                </Button>
              </li>
            ))}
          </ol>
          <Button type="button" size="sm" variant="ghost" aria-disabled={page === pages} onClick={() => goTo(page + 1)}>
            Next
            <ChevronRight aria-hidden size={14} />
          </Button>
        </nav>
        <Text as="p" fontSize="xs" color="text-muted" role="status" margin="none" dangerouslySetClassName={styles.count}>
          Showing {(page - 1) * perPage + 1}–{(page - 1) * perPage + shown.length} of {filtered.length} articles
        </Text>
      </Stack>
    </Stack>
  )
}
```

## How it works

- The art is CSS only: layered radial gradients mixed from the theme’s colors with `color-mix`, and each tag swaps in its own hue through a custom property, so it adapts to light and dark with no images.
- Each card’s title link stretches over the whole card with a positioned `::after`, so the card is one target while the link text stays the accessible name.
- Choosing a tag goes back to page 1. Previous and Next use `aria-disabled` at the ends so they stay focusable, the current page has `aria-current="page"`, and a `role="status"` line says which articles are showing.
- The featured card puts its art beside the text when its container is at least 34rem wide; the grid goes from one column to two at the `sm` breakpoint.

## App-owned CSS

`examples/recipes/article-index.module.css`:

```css
.root {
  container-type: inline-size;
}

/* Art from the tokens: soft color fields that follow the theme */
.featuredArt,
.art {
  --art-hue: var(--ds-color-accent);
  --art-wash: var(--ds-color-accent-subtle);

  background:
    radial-gradient(circle at 18% 28%, color-mix(in srgb, var(--art-hue) 70%, transparent), transparent 46%),
    radial-gradient(circle at 82% 78%, color-mix(in srgb, var(--ds-color-info) 45%, transparent), transparent 52%),
    radial-gradient(circle at 70% 18%, color-mix(in srgb, var(--art-hue) 30%, transparent), transparent 40%),
    linear-gradient(135deg, var(--art-wash), var(--ds-color-bg-subtle));
}

.art[data-tag='Engineering'] {
  --art-hue: var(--ds-color-info);
  --art-wash: var(--ds-color-info-subtle);
}

.art[data-tag='Research'] {
  --art-hue: var(--ds-color-success);
  --art-wash: var(--ds-color-success-subtle);
}

.art[data-tag='Culture'] {
  --art-hue: var(--ds-color-warning);
  --art-wash: var(--ds-color-warning-subtle);
}

.featured,
.card {
  position: relative;
  overflow: hidden;
  background-color: var(--ds-color-bg);
  transition: border-color var(--ds-duration-fast) var(--ds-easing-standard);

  &:hover {
    border-color: var(--ds-color-border-strong);
  }
}

.featured {
  display: grid;
}

.featuredArt {
  min-block-size: 10rem;
}

@container (width >= 34rem) {
  .featured {
    grid-template-columns: 2fr 3fr;
  }

  .featuredArt {
    min-block-size: 16rem;
  }
}

.card {
  display: flex;
  flex-direction: column;
  block-size: 100%;
  box-sizing: border-box;
}

.art {
  block-size: 5rem;
}

/* The title link stretches over its card, so the whole card is one target */
.titleLink {
  color: inherit;
  text-decoration: none;

  &::after {
    content: '';
    position: absolute;
    inset: 0;
  }

  &:hover {
    text-decoration: underline;
  }

  &:focus-visible {
    outline: none;

    &::after {
      outline: var(--ds-border-width-md) solid var(--ds-color-focus-ring);
      outline-offset: calc(var(--ds-border-width-md) * -1);
      border-radius: var(--ds-border-radius-xl);
    }
  }
}

.excerpt {
  flex: 1;
}

.avatar {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  inline-size: var(--ds-control-height-sm);
  block-size: var(--ds-control-height-sm);
  font-size: var(--ds-font-size-xxs);
  font-weight: var(--ds-font-weight-semibold);
  color: var(--ds-color-accent-text);
  background-color: var(--ds-color-accent-subtle);
  border-radius: var(--ds-border-radius-circle);
}

.bylineText {
  display: grid;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ds-space-sm);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: none;
}

.legend {
  float: left;
  margin-right: var(--ds-space-sm);
  padding: 0;
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-semibold);
}

.grid,
.pages {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-sm);
}

.pages {
  display: flex;
  gap: var(--ds-space-xs);
}

.count {
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .featured,
  .card {
    transition: none;
  }
}
```
