Repository navigation
Description
Context
Kit headings wrap greedily. On a 320–390px phone, a two-line sheet or screen title often leaves one word alone on its second line. Only two kit elements set text-wrap today, and both use pretty:
- the
EmptyStatebody and note (textWrap,packages/ui-kit/src/conversation/EmptyState.tsx:178) - a
MapViewcaption (textWrap,packages/ui-kit/src/blocks/MapView.tsx:1107)
The print renderer already uses balance on headings and pretty on paragraphs (packages/render-template/src/styles.ts:97, :120).
Guide visual-design/improve-text-layout-and-legibility: "For short text blocks like headings, use text-wrap: balance", and "Avoid elements that have visible boxes such as borders or backgrounds". The guide also notes that Chromium balances at most about 6 lines.
Support:
balance: Chrome Android 114, Samsung 23, Firefox Android 121.pretty: Chrome Android 117, Samsung 24, not in Firefox.
Where a browser lacks either value, it falls back to ordinary wrapping, so no detection is needed.
Scope
text-wrap: balance on these title elements, none of which has its own border or background:
Overlayheaderh2: the.bk-overlay-header h2rule (packages/ui-kit/src/tokens.css:2425)BottomSheettitle span (packages/ui-kit/src/chrome/BottomSheet.tsx:60-62)ScreenHeadertitle (packages/ui-kit/src/chrome/ScreenHeader.tsx:93-100)EmptyStatetitle (titleRef,packages/ui-kit/src/conversation/EmptyState.tsx:164-171)DigestCardtitle (packages/ui-kit/src/conversation/DigestCard.tsx:110-117)HygieneCardheadings (packages/ui-kit/src/decisions/HygieneCard.tsx:103,:206,:250)
text-wrap: pretty on these short captions:
BottomSheetsubtitle (BottomSheet.tsx:70)ScreenHeaderdescription (ScreenHeader.tsx:140)
Out of scope
- A global
h1–h6orprule, and the ui-react markdown prose intheme.css. ActionCardtitles, which render throughGhostedloading text whose width must not jump between ghost and arrival.- Row titles (
ListRow,ChoiceOption), chips and buttons. - The print renderer.
Acceptance criteria
- Each element listed in Scope computes
text-wrap-style: balanceorprettyin a real browser, and no other kit element changes. - A Storybook play test fails before the change and passes after. It renders an
Overlayand aBottomSheetat 320px with a title that wraps to two lines, and asserts that the two lines' widths differ by less than 30% of the wider one. - The re-recorded visual baselines contain only wrapping changes in the listed titles and captions. The PR shows before/after captures at 320px and 390px for review.
- Android support: no detection is needed (see Context), and the PR records that Firefox keeps greedy wrapping for
pretty.
Verification
node scripts/visual.mjs --project=storybook --filter=Overlay.stories
node scripts/visual.mjs --project=storybook --filter=BottomSheet.stories
bun run visual:update && git diff --stat
bun run visual
bun run test
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
@schlessera/brain-ui-kit: visual-only patch.
Activity