Skip to content

Shrink a heading whose widest word is wider than its column - #391

Merged
singhharsh1708 merged 2 commits into
mainfrom
design/headings-shrink-to-fit
Sep 11, 2026
Merged

singhharsh1708 merged 2 commits into
mainfrom
design/headings-shrink-to-fit

Conversation

@singhharsh1708

Copy link
Copy Markdown
Owner

Greenshift opens with the statement "Decarbonisation at enterprise scale." At 143px the word "Decarbonisation" is 1091px wide, which is wider than any column the layouts give it. The section's mask reveal ends at clip-path: inset(0), which clips at the box edge, so from 1440 wide up the heading read "Decarbonisa". Any site with a long enough word in a statement would hit the same thing.

Every heading's font size is now multiplied by var(--sc-fit, 1). Each renderer measures every heading on first paint, after web fonts load, and on resize. When a heading's widest word is wider than its column, the renderer sets --sc-fit just below the ratio that makes it fit. A heading that already fits keeps 1, so nothing else changes size. The factor never goes below one half. The preview, the exported page and the plugin engine all do this.

This table counts headings wider than their column, across all 21 templates, measured in headless Chrome against a production build:

viewport before after
1280x720 0 0
1280x800 1 0
1366x768 0 0
1440x900 1 0
1536x864 1 0
1920x1080 1 0
390x844 0 0

Across the 21 templates, the only heading that shrinks is Greenshift's statement, and it comes out at 102 to 103px at every desktop size. Its factor runs from 0.970 at 1280x800 to 0.719 at 1920x1080. At every size, no section got taller than its frame and nothing scrolls sideways. I recaptured Greenshift's gallery still, which is the only one that changed.

I also opened a real exported page and a real plugin bundle in Chrome, each with that statement. Both set --sc-fit to 0.781 at 1920x1080 and to 0.937 at 1440x900, and the heading fits its 800px column. At phone width both leave it at 1.

Three new tests run the fit code emitted by the export and by the plugin bundle against fake headings, and a parity check covers all three renderers. They fail against main. Also checked: tsc, eslint, 503 vitest tests, and a production build.

Greenshift's statement word Decarbonisation is 1091px at 143px, wider than
any column, and the mask reveal clips at the box edge, so from 1440 wide
the heading read Decarbonisa. Every heading's size is now multiplied by
--sc-fit, which each renderer sets below 1 only for a heading whose widest
word overflows, after layout, after fonts load and on resize.
@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scrollcraft Ready Ready Preview Sep 11, 2026 9:10pm UTC

@singhharsh1708
singhharsh1708 merged commit b7136dd into main Sep 11, 2026
3 checks passed
@singhharsh1708
singhharsh1708 deleted the design/headings-shrink-to-fit branch September 11, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant