# Footer

The last area of a page, with a mark, columns of links and a line at the bottom. It uses data, not a set of wrapper parts, because a column of links is a list, so it is a prop. The file holds the arrangement. The block also names each column. Every column is a separate navigation region with its own title as its label. Thus a screen reader announces where each column goes, and does not read five navigation regions with no name. Links are muted at rest and use the full text colour under the pointer. The underline is transparent at rest, so nothing moves when it appears. A footer with no columns is one line: the mark moves down into the bottom row. That is the minimum shape of every app footer, and the data decides it, not a prop. The footer draws no panel of its own, because the page decides what a footer sits on. If you want a footer on a ground, wrap it in a Surface. Icons, a newsletter form and payment marks are not included, for stated reasons. The file is yours, so you can add them to it.

## Files

### footer.tsx

```tsx
/**
 * The site footer: a mark, columns of links, and the line at the bottom.
 *
 * WHY THIS IS A BLOCK AND NOT A COMPONENT. A footer is a POSITION — the last region of a page
 * — and §3 is that a component never owns where it sits. Its substance is entirely the app's
 * (which links, which words, which mark), and §11 has no row for it. What is left for the
 * system to own is an arrangement and a piece of wiring, which is exactly what a copied file
 * carries safely: every colour, distance and step below resolves through the package, so the
 * center stays in the dependency and this file holds only the shape.
 *
 * IT IS DATA-DRIVEN, AND THAT IS THE DECISION. The alternative is a footer as thirteen
 * exports — `Root`, `Main`, `Bottom`, `Brand`, `BrandName`, `Tagline`, `Links`, `LinkGroup`,
 * `Nav`, `Link`, `Legal`, `Social`, `SocialLink` — of which eleven would be a `Flex` or a
 * `Text` with different defaults. That is layout wearing a part's name, which this system
 * refuses (`ComposerRow`'s grouping, `BreadcrumbSeparator`). A column of links is a LIST, and
 * a list is a prop: `groups` says what the footer says, and the file you are reading says how
 * it looks. Nothing is expressible through thirteen wrappers that is not expressible by
 * editing this one.
 *
 * WHAT IT ACTUALLY OWNS is the naming: each column is its own `<nav>` named by its own title
 * through `aria-labelledby`, so a screen reader announces "Support navigation" rather than
 * five unnamed navigation regions in a row. That is a spec rather than a taste, and a spec
 * copied by hand rots — the argument `Field` makes for owning its label wiring and `Tree`
 * makes for owning its keyboard.
 *
 * THE COLUMN TITLE IS NOT A HEADING, and the refusal is deliberate. A heading is a section of
 * the DOCUMENT, and a footer's column title is a label for a navigation region — putting it in
 * the outline makes page furniture compete with the page's own structure, which on a chapter
 * would put "Support" beside the chapter's real sections. The region is named, which is the
 * half that carries the meaning; `aria-labelledby` needs an id, not an `<h2>`.
 *
 * REFUSED, each for a reason the system already states:
 *
 *  - **Social icons.** §8 ships no icon set, so a written one would export an import the
 *    reader's app cannot resolve (the builder's own refusal). A "Follow us" group of links is
 *    the same information, and it is what the references do.
 *  - **A newsletter form.** It needs an endpoint, which is an app's, and a `Field` plus a
 *    `Button` is four lines in a file you own. Giving it a seat here would mean designing a
 *    position for something the system cannot fill.
 *  - **Payment marks and logos.** Images the app owns. `brand` takes a node for the same
 *    reason: the mark is yours.
 *  - **Axis props.** No `size`, no `tone`, no `emphasis`. A block is not a component with an
 *    API to grow — the steps are stated once, below, and if you want other steps you change
 *    them in your copy. That is the whole difference between this and the package.
 *
 * IT DRAWS NO PANE AT ALL, and that is a refusal rather than a default. What a footer sits ON
 * is the page's business, which is §3's own sentence about a component never owning where it
 * sits, said one level up: a footer that wants a ground is `<Surface><Footer/></Surface>`, one
 * element at the call site rather than a prop and a branch in here. A `pane` boolean is the
 * wrong repair for the same reason — it takes the choice into the file instead of leaving it
 * at the call site.
 *
 * A FOOTER WITH NO COLUMNS IS A LINE, and it is DERIVED rather than asked for. The minimal
 * footer — a mark, two or three destinations, a copyright, all on one row — is the second
 * composition that actually recurs in the wild, and it is not a different arrangement so much
 * as this one with nothing to stack: there are no columns, so the mark has nothing to sit
 * above, and leaving it there draws a title over an empty region. So when `groups` is empty the
 * mark joins the sign-off row, and everything else about that row is unchanged — the note keeps
 * the start wall and the legal links keep the end. One `groups.length` reads it, and no call
 * site has to know which footer it is asking for.
 *
 * WHICH IS ALSO WHY THERE IS NO `brand` PLACEMENT PROP, and the mark-beside-the-columns shape
 * every second product site draws is not reachable from this file. It is a taste, not a
 * derivation — and the moment a demo on this block's page shows an arrangement the file cannot
 * produce, the copy button hands over something that does not make the picture. If you want the
 * mark beside the columns, that is a `Flex` around two children in your copy, which is the same
 * answer this file gives about steps and colours.
 */
import * as React from "react";
import { Flex, Stack, Text } from "@kushagradhawan/kookie-ui-react";

import "./footer.css";

export type FooterLink = {
  label: string;
  /** Where it goes. A string, so this file stays framework-free — wrap it in your router's
      own link component if you want client navigation, the way the docs do everywhere else. */
  href: string;
};

export type FooterGroup = {
  /** The column's title, and the name of the navigation region it labels. */
  title: string;
  links: readonly FooterLink[];
};

export type FooterProps = {
  /** The app's mark, sitting above the columns. A node, because §8 ships no icon set and a
      wordmark is the one thing on this page that is unarguably yours. */
  brand?: React.ReactNode;
  /** The columns. Each becomes a named navigation region. */
  groups: readonly FooterGroup[];
  /** The line at the bottom — a copyright, a company, a country. */
  note?: React.ReactNode;
  /** The links that sit opposite the note: privacy, terms, status. Separate from `groups`
      because they are not a subject a reader browses, they are the ones a reader is sent to
      look for, and a column of two would read as a category that ran out. */
  legal?: readonly FooterLink[];
};

export function Footer({ brand, groups, note, legal }: FooterProps) {
  /* One id per mounted footer, so two on one page (a preview beside the real one) cannot both
     claim the same name and leave every `aria-labelledby` pointing at the first. */
  const id = React.useId();

  /* Nothing to stack — see the header. The mark comes down into the row rather than standing
     over an empty region. */
  const line = groups.length === 0;

  /* NO HAIRLINE between the browsing half and the legal half. §15's rule is that a separator
     earns its place only where DISTANCE cannot group, which is not the case here: the outer
     stack already sets these two regions far apart against the intervals inside a column, and
     a rule drawn across a gap that is already doing the work is a line saying what the space
     said. */
  const signOff =
    note || legal?.length || (line && brand) ? (
      <Flex justify="space-between" align="center" gap="5" wrap="wrap">
        {/* The start wall, always rendered even when it holds nothing: one child and
            `space-between` pushes it to the wrong wall, and an empty flex is a cheaper way to
            hold a position than a placeholder element that means nothing to a reader of the
            markup. */}
        <Flex align="center" gap="5" wrap="wrap">
          {line && brand ? brand : null}
          {/* Quiet, the rung §15 minted for something deliberately stood down — a copyright
              line is read once a year and never scanned. */}
          {note ? (
            <Text size="2" emphasis="quiet">
              {note}
            </Text>
          ) : null}
        </Flex>
        {legal?.length ? (
          <Flex gap="5" wrap="wrap" render={<nav aria-label="Legal" />}>
            {legal.map((link) => (
              <Text
                key={`${link.label}|${link.href}`}
                size="2"
                emphasis="medium"
                render={<a className="kb-footer-link" href={link.href} />}
              >
                {link.label}
              </Text>
            ))}
          </Flex>
        ) : null}
      </Flex>
    ) : null;

  /* The landmark is the `<footer>` element itself: it announces as `contentinfo` when it is a
     child of the body rather than of an article, which is where a page footer sits. No `role`,
     because stating the role the element already has is the aria rule this system follows
     everywhere else. */
  /* THE RHYTHM IS 32 / 64 / 96, AND THE SIGN-OFF CARRIES THE LARGEST INTERVAL. One step for
      every region — 48 against the 32 two stacked groups take inside a column — is sixteen
      pixels apart, which is a rhythm nobody can read. With no hairline, distance is the ONLY
      thing separating the browsing half from the sign-off, so it has to be unmistakably the
      largest interval in the block rather than nominally the largest. Doubling each level
      states it: 32 inside the columns, 64 between the mark and them, 96 before the line that
      ends the page.

      Two stacks rather than one gap, because the three intervals are not one relationship:
      the mark and the columns are both what the footer SAYS, and the sign-off is what it
      ends with. */
  return (
    <Stack gap="11" render={<footer />}>
      {line ? null : (
        <Stack gap="10">
          {brand ? <div>{brand}</div> : null}

          {/* THE COLUMNS ARE A CSS COLUMN LAYOUT, and `footer.css` carries why: a grid's row is
              as tall as its tallest item, so six groups of unequal length leave a hole nothing in
              grid can close. A plain `div` because there is no layout prop for this — `columns`
              on Box is `grid-template-columns`, which is the mechanism this had to leave. */}
          <div className="kb-footer-columns">
            {groups.map((group, index) => (
              <Stack
                key={group.title}
                gap="3"
                render={<nav aria-labelledby={`${id}-${index}`} />}
              >
                {/* Full ink at medium against muted links: the title is the one thing in the
                    column that is not a destination, and §15 puts that rank in the ink rather
                    than in a heavier face or a larger step. */}
                <Text size="2" weight="medium" id={`${id}-${index}`}>
                  {group.title}
                </Text>
                <Stack gap="2" render={<ul className="kb-footer-list" />}>
                  {group.links.map((link) => (
                    /* KEYED BY BOTH. `href` alone is not a key: a footer may point two links
                       at one place — a "Status" under Product and under Legal is the ordinary
                       case — and placeholder data pointing every link at "#" makes React report
                       duplicate children. Two entries with the same label AND the same
                       destination are the same link written twice, which is a data mistake
                       rather than a case to key around. */
                    <li key={`${link.label}|${link.href}`}>
                      {/* `medium` IS the muted ink role — the resting rank stated through the
                          system rather than repainted in the block's own stylesheet. */}
                      <Text
                        size="2"
                        emphasis="medium"
                        render={<a className="kb-footer-link" href={link.href} />}
                      >
                        {link.label}
                      </Text>
                    </li>
                  ))}
                </Stack>
              </Stack>
            ))}
          </div>
        </Stack>
      )}

      {signOff}
    </Stack>
  );
}
```

### footer.css

```css
/* ── The footer block's own half ───────────────────────────────────────────────────────────
   Three things this file decides, and it decides no colour, distance or step the package has
   not already decided: every value below resolves through a `--` token, which is the condition
   that makes a copied file safe (THESIS §6 — the center stays in the dependency).

   A LINK LIST IS A LIST. `<ul>` carries the count to a screen reader, and the markers and the
   indent it comes with are the browser's idea of a list of sentences rather than of a column
   of destinations. Reset here rather than avoided by using `<div>`s, because the announcement
   is the reason the element was chosen. */
.kb-footer-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* THE LINK IS NOT `Link`, AND THE ARGUMENT IS BREADCRUMB'S (breadcrumb.css).

   `Link` rests on `accent` and always STAMPS it, which re-scopes all three foreground roles
   onto that family's ink trio — a column of thirty accent links is a footer shouting the whole
   time. What a footer's links want is the tone-LESS roles in two ranks: muted at rest, full ink
   under the pointer, which is the same pair a breadcrumb's crumbs wear and the same pair a menu
   row lights with.

   THE RESTING COLOUR IS NOT HERE, and that is the point: it is `emphasis="medium"` on the
   `Text` in `footer.tsx`, which IS the muted ink role. Writing `color: var(--color-text-muted)`
   in this file loses anyway — measured, the link paints full ink, because `Text` stamps
   `data-emphasis="loud"` and `.kui-type[data-emphasis="loud"]` outranks a bare class. Winning
   that fight would mean a second home for a colour the system already states, so the fight is
   not had: the role says the rest, and this file says only what happens when a pointer
   arrives.

   The underline rests TRANSPARENT rather than absent, so the metrics never move and the pointer
   changes only its colour. Resting invisible is a carve-out from `Link`'s unconditional
   underline and not a drift from it: WCAG 1.4.1's technique F73 is about a link INSIDE A BLOCK
   OF TEXT, where hue is all that separates it from the words around it. Nothing here is inside
   prose — every item in the column is a link, and the column is what says so. */
.kb-footer-link {
  cursor: pointer;

  text-decoration-line: underline;
  text-decoration-thickness: var(--border-width);
  text-decoration-color: transparent;
  /* Relative to the link's own type, for the reason link.css and blockquote.css both state:
     the distance between a rule and the glyphs above it is a property of the glyphs. */
  text-underline-offset: 0.2em;
}

/* Guarded like every hover rule in the system (§8): a touch device synthesises hover on tap and
   holds it until the next tap, so an unguarded rule leaves a tapped link lit.

   `a.kb-footer-link`, not `.kb-footer-link`, and the element is load-bearing rather than
   decorative: the rung it has to beat is `.kui-type[data-emphasis="medium"]` at (0,2,0), and a
   bare class with a pseudo-class ties it. A tie is settled by source order, which across a
   package boundary is a bundler's decision and not a stated one — so it has to be settled by
   RANK. The type selector makes it (0,2,1) and the rule wins by saying something, wherever
   the file lands. */
@media (hover: hover) {
  a.kb-footer-link:hover {
    color: var(--color-text);
    text-decoration-color: currentcolor;
  }
}

/* The system's ring, in the system's tokens — never a second designed value. Drawn here for
   `Link`'s own reason: a footer link is not a `.kui-control`, so it never meets the shared
   layer's rule, and a link that cannot be seen when it is focused is a link a keyboard cannot
   use. */
.kb-footer-link:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

/* ── The columns ───────────────────────────────────────────────────────────────────────────
   MULTICOL, NOT A GRID, AND THE HOLE IS THE REASON.

   A grid's row is as tall as its tallest item, so six groups of wildly different lengths — one
   with ten links, three with three — laid out in two rows put five empty rows under the short
   columns. No grid property fixes it: `align-items: start` sizes the ITEM, not the row, and
   masonry is not a thing that ships.

   Column layout balances by height, which is precisely the arrangement a footer wants: every
   column starts at the top, and how many there are follows from how much room there is.
   `break-inside: avoid` is what keeps a group whole — without it a column can end between a
   title and its own links, which is the one arrangement worse than the hole.

   `20ch`, and the unit is the argument: a column of links is as wide as the words in it, so its
   minimum is a statement about TEXT rather than about a screen — the carve-out `Code`'s padding
   and `Breadcrumb`'s underline offset both make inside the package, and the reason the block's
   own law forbids `px` and allows `ch`. Twenty characters is where a two-word label stops
   wrapping. */
.kb-footer-columns {
  columns: 20ch;
  column-gap: var(--layout-space-7);
}

.kb-footer-columns > * {
  break-inside: avoid;
  margin-block-end: var(--layout-space-7);
}

/* And the block axis pays for that margin exactly once. Every group carries a bottom gap, so
   the column that ends last leaves one hanging under it and the container measures one gap too
   tall. Cancelling it here is the same arithmetic `m="bleed"` does against a surface's padding
   — one token, one sign — rather than a second number chosen to look right. */
.kb-footer-columns {
  margin-block-end: calc(-1 * var(--layout-space-7));
}
```
