Skip to content

fix(theme): wide tables never break out of the prose column #168

Description

@sanity

Problem

base.css has a deliberate rule letting tables, code blocks and figures extend
past the reading column on wide screens, with a comment explaining why:

/* Tables, code blocks and figures are read by scanning rather than line by
   line, and a text-width column squeezes them ... */
@media screen and (min-width: 1024px) {
    .container.is-prose .content > table,
    .container.is-prose .content > pre,
    .container.is-prose .content > figure {
        margin-inline: calc((var(--measure-content) - var(--breakout)) / 2);
        width: var(--breakout);
    }
}

For tables it has no effect. A later rule caps them:

.content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    width: max-content;
}

max-width: 100% resolves against the 640px content box, so the width: var(--breakout) (52rem, 832px) above is clamped straight back to 640px. Measured
in a headless browser at a 1280px viewport: table width 640px, not 832px.

The result is that a table which was meant to widen instead scrolls sideways
inside the column, on a screen with room to spare. It affects
/build/manual/contract-abi/ and /build/manual/typescript-sdk/, and it shaped
the table on /bug/ (#167), which was written narrower than it wanted
to be to work around this.

pre and figure are probably unaffected since they have no equivalent
max-width: 100% rule, but that is worth confirming rather than assuming.

Suggested fix

Raise the cap inside the same media query, e.g. add max-width: var(--breakout)
alongside the existing width. Below 1024px nothing should change: tables must
keep scrolling in the column rather than pushing the page sideways.

This needs a visual check on the pages that have wide tables before merging,
which is why it is filed rather than folded into #167.

[AI-assisted - Claude]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions