Skip to content

View: add center keyword for insetInline and insetBlock#650

Merged
blvdmitry merged 1 commit into
canaryfrom
claude/view-inset-center-keyword-nm86vg
Jul 4, 2026
Merged

View: add center keyword for insetInline and insetBlock#650
blvdmitry merged 1 commit into
canaryfrom
claude/view-inset-center-keyword-nm86vg

Conversation

@blvdmitry

Copy link
Copy Markdown
Contributor

Summary

  • Adds insetInline and insetBlock props to View (the style mixin already had resolvers for them, but they weren't exposed on the component)
  • Both props support a new "center" keyword value alongside unit numbers and "auto". insetInline="center" centers an absolutely positioned element on the inline axis, insetBlock="center" on the block axis, and setting both centers it fully
  • Centering is implemented as left: 50% (or top: 50%) plus a translate: -50% on the matching axis. The two axes compose through --rs-inset-translate-x/y custom properties (registered with @property … inherits: false so they don't leak into nested centered elements), so using both keywords resolves to translate: -50% -50%
  • The inline/block resolvers moved from the plain attribute-selector CSS to the classname-gated pattern already used by the width resolver (@value center / @value unit), so responsive values like { s: "center", m: 4 } correctly switch between centering and unit insets per viewport, with the translate reset on unit viewports
  • Physical properties (left/top) are used for the center value on purpose: centering is symmetric, so this keeps it direction-agnostic and RTL needs no extra handling
  • Also fixes the zIndex resolver's return type missing classNames, which broke tsc on resolveMixin since the last commit on main

Related Issue

N/A

Screenshots / Recordings

Verified in a real browser (Storybook + Playwright) by measuring bounding boxes against the container center across LTR/RTL and s/m viewports:

Case LTR desktop RTL desktop LTR mobile RTL mobile
insetInline="center" centered x centered x centered x centered x
insetBlock="center" centered y centered y centered y centered y
both centered x+y centered x+y centered x+y centered x+y
insetInline={{ s: "center", m: 4 }} 16px insets 16px insets centered x centered x

All centered cases measured a 0.0px offset from the container center. New story examples were added under the View inset story.

Notes for Reviewers

  • inset.css keeps the attribute-selector rules for inset, insetTop/Bottom/Start/End; only the inline/block rules moved into inset.module.css since they now need value-based classnames
  • The var(--rs-inset-translate-x, 0) fallbacks keep centering working in browsers without @property support (with the minor caveat that the custom properties become inheritable there)
  • Snapshot changes for insetInline/insetBlock resolvers reflect the added classnames; all 181 unit tests pass, tsc (esm and stories configs) and stylelint/oxlint are clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01F6V36sEHRNKzN996awyGmG


Generated by Claude Code

Adds insetInline and insetBlock props to View and supports a new
"center" value on both, which centers absolutely positioned elements
on their axis via 50% inset combined with a translate. Also fixes the
zIndex resolver return type missing classNames, which broke the mixin
typecheck.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6V36sEHRNKzN996awyGmG
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Library / JS 49.2 KB (+1.43% 🔺) 984 ms (+1.43% 🔺) 311 ms (+13.16% 🔺) 1.3 s
Library / CSS 23.03 KB (+3.84% 🔺) 461 ms (+3.84% 🔺) 0 ms (+100% 🔺) 461 ms
Theming / JS 7.81 KB (0%) 157 ms (0%) 236 ms (+1134.93% 🔺) 393 ms
Theming with a default theme definition / JS 8.65 KB (0%) 174 ms (0%) 227 ms (+302.74% 🔺) 400 ms

@blvdmitry blvdmitry changed the base branch from main to canary July 4, 2026 10:18
@blvdmitry blvdmitry marked this pull request as ready for review July 4, 2026 10:21
@blvdmitry blvdmitry merged commit c2ec999 into canary Jul 4, 2026
11 of 12 checks passed
@blvdmitry blvdmitry deleted the claude/view-inset-center-keyword-nm86vg branch July 4, 2026 10:21
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.

2 participants