Skip to content

feat(SegmentedControl): under a finger, the selected surface lifts - #9724

Merged
cixzhang merged 10 commits into
meta:mainfrom
vjeux:segmented-control-lift
Nov 11, 2026
Merged

cixzhang merged 10 commits into
meta:mainfrom
vjeux:segmented-control-lift

Conversation

@vjeux

@vjeux vjeux commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

User need

On iOS 26, pressing a segmented control's selected segment lifts its surface, as Astryx's Switch thumb does. Our SegmentedControl stays flat. Specs decision, Nov 2 2026: the selected surface lifts for consistency with Switch's thumb lift.

Problem and solution fit

  • Lift: under a finger, the pressed selected surface grows by 24 × 16 px on UIKit's measured spring (critically damped, 0.25 s). It settles back at the release, and a drag carries it.
  • Edge: while lifted, it carries the theme's low elevation shadow, as Switch's lifted thumb does, so the track stays visible around it.
  • Who lifts: a finger, or a pen on a touch device. A desktop mouse and Reduce Motion lift nothing. A press on another segment keeps the pressed overlay.
  • Flick: UIKit projects no flick, so the lift's position still decides.

Current specification

Rebased onto main b6b0c68. Main's FR9 and FR10, a slide under every pointer, stand.

  • component:SegmentedControl FR14 (new) and FR11's last sentence. design:user-states DR3 now states the lift, in its rule, anatomy, matrix and example, and FR14 points to it. component:SegmentedControlItem FR5 defers to it.
  • spec:AST-094 FR4 gains segmented.lift, and motion-roles.md is regenerated.
  • component:Switch FR13 is the lift this matches.
  • Owner-gated (/approve-spec <head sha>): AST-094, its motion-roles table, both SegmentedControl records and design:user-states.

Measurements (iOS 26.2 simulator, iPhone 17 Pro)

  • Growth: +24 × +16 pt at every size, for example 96 × 27 to 120 × 43.
  • Spring: UIKit reports UIViewSpringAnimationBehaviorSettings (1.0, 0.25) on the lens. A per-frame fit leaves 0.16 pt rms on the lift and 0.05 pt on the settle.
  • Flick: a 36 ms flick at up to 3,900 pt/s commits where a slow drag to the same point does.

Public delta and caller burden

No API, prop or theme change. The lifted surface paints up to 6 px above and below the track and 10 px past its ends, as UIKit's does.

Design and alternatives

Chosen: a built-in measured motion role, segmented.lift, as for Switch's thumb lift. #8596's general lift role closed without merging. Not in scope: UIKit's cancel rules and its stretch along a slide.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Writing rubric results

FR14, FR11, SegmentedControlItem FR5 and design:user-states DR3: R1–R6 none. FR14's first sentence is the spec owners' wording. Its last sentence now points to DR3.

Testing

In "Default", press and hold the selected segment by touch: its surface grows with a soft shadow, and it settles back when you let go. With a mouse, nothing lifts.

Check (this head, 9c73784: f6995a5's two fixes, plus merges of main f27380a and d9d7b10) Result
This pull request's own lines through the merges unchanged apart from the spec table's padding, except one sentence of the SegmentedControl docs that #10978 also edits; it carries both edits
Red first: the component CSS variable check (derivedVarRegistry.test.ts) at 4bd76ea fails: the radiogroup declared an undocumented custom property for the lifted edge
The same check at this head passes: the lens takes the --shadow-low token directly, and the radiogroup declares nothing new
Red first: a press on the segment a tap just chose, while the lens slides there (unit), at fe4ae27 fails: the press drops the slide's 617 px/s to 0, so the lens stays where the slide had got to
The same case at this head passes: the lens keeps its velocity and lands on that segment, lifted
SegmentedControl and motion interaction specs, 1 worker (CI's profile) Chromium 217/217; WebKit 202 passed, 15 skipped
SegmentedControl label contrast, PressedState and RadioGroup accessibility, Chromium 39/39
pnpm lint:strict (CI's mode), core typecheck, check:knowledge, motion roles, changesets pass: 0 lint errors
Unit: the whole ui project, which CI shards four ways 24419 pass
CLI suite 11868 pass, 1 fail: in interactive-guard.test.mjs, the astryx experimental theme preview app x case ran past its 20 s deadline under machine load. This pull request changes no CLI code
The rows below ran at 25e8e4c (rebased onto main b6b0c68). 4c03cd5 adds only the DR3 record change
Typecheck, knowledge, changesets, sync, i18n runtime, motion roles, specs:for --diff pass
Unit: SegmentedControl, motion and Switch 1257 pass
Red-first on the Nov 2 base's code and build (ce667be) 6 units red; the new lift browser case red (no lens on a hold)
Red-first for the lifted edge after a committing drag, on 91c7ee4 the unit red (copied shadow); the browser case red (a visible lens with no shadow)

Public and internal API delta

  • Public: none. No export, prop, type, default, theme variable or theme target changes.
  • Internal motion role segmented.lift: a spring (response 0.25 s, damping ratio 1) in the internal motion-role table, beside segmented.selectionSpring. spec:AST-094 FR4 lists it. Usage: this.springLens(lifted, this.springFrom(lifted, 'lift')). Why: the lift and its settle use UISegmentedControl's measured spring.
  • Internal table value segmentedControl.liftGrowth: [24, 16] px. Usage: const [width, height] = segmentedControl.liftGrowth;. Why: UISegmentedControl's measured growth while pressed.
  • Component-internal method SegmentedSelectionMotion.highlighted(): SegmentedControl's touch tracking calls it when a press highlights. Usage: if (isHighlighted) motion.highlighted();. Why: the lift starts at the press highlight, as Switch's does. Nothing outside SegmentedControl calls it.
  • The lifted edge writes the existing --shadow-low token into the lens's existing box-shadow layer property. No custom property is added.
  • Size: +552/−127 lines (d9d7b10..9c73784): source +155/−29, tests +326/−41, records and docs +71/−57.
  • App-level size: +414 B gzip, eager, on the Sandbox's /pages/segmented-control-cases/ page, measured against main with the same page.

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 11, 2026 1:35pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 11, 2026, 2:12 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 3, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 9c73784

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
SegmentedControl 99.9 kB (+391 B) · 6.9 kB CSS (0) — ✗ · ✓ · ✓
SegmentedControlItem 18.5 kB (0) · 4.3 kB CSS (0) — ✗ · ✓ · ✓
DateTimeInput 215.0 kB (+445 B) · 18.8 kB CSS (0) — — · — · —
Visual changes: 1 snapshot in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
SegmentedControl · Default (neutral, dark) before frame after frame diff frame

Package size: measured; main has no measurement of the merge base to compare yet.

API changes: unknown (base surface unavailable): richtext, theme-butter, theme-chocolate, theme-gothic, theme-matcha, theme-neutral, theme-stone, theme-y2k

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 96b5d65

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the lift behaves as the approved FR14 describes, but two things need fixing first.

  • In the default light and dark themes the lifted selected surface is the page's own colour with no edge, so holding a segment erases the track around it (an end segment loses the track's end, a middle segment splits it in two); give the lifted surface a visible edge, such as the theme's elevation shadow Switch puts on its lifted thumb, and add a browser assertion that the track stays visible around a held segment.
  • The usage description in SegmentedControl.doc.mjs now says both that pressing the selected segment lifts it and that "nothing lifts or dims"; end it with "a pressed unselected segment shows the shared pressed overlay, and nothing dims" instead.

The spec changes are approved for this revision and the unit suites pass. The rest is optional: a stale line in motion/MEASUREMENTS.md, two comment wordings, and the FR14 row of the verification map, which fills only two of its five columns.

[Automated review]

@vjeux
vjeux force-pushed the segmented-control-lift branch from 96b5d65 to 91c7ee4 Compare November 3, 2026 09:11
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 91c7ee4

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the lift and its new edge behave as the approved FR14 describes while a segment is held, but two things need fixing first.

  • design:user-states DR3 (its rule, anatomy and matrix rows, and example) and component:SegmentedControlItem FR5 still say the selected segment keeps its raised surface unchanged during a hold under every pointer, so amend them in this PR to allow the touch lift (or drop the lift), and update the "selected-segment exception" line in the SegmentedControl record.
  • After a drag that commits another segment, select() repaints the lens from the destination (useSegmentedSelectionMotion.ts:633) and drops the lifted shadow while the surface is still grown, so for about 0.1 s the white surface again covers the track's edges; keep the lifted shadow until the hand-back and assert it after a committing drag.

The spec changes are approved for this revision, the consumer description now reads consistently, and the unit and Chromium lift tests pass. One optional cleanup: the browser spec comment at SegmentedControl.interaction.browser.spec.ts:450-451 still gives the old "a pressed thumb's lift is a theme's" reason.

[Automated review]

@vjeux
vjeux force-pushed the segmented-control-lift branch from 91c7ee4 to c2bc372 Compare November 3, 2026 10:12
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@vjeux
vjeux force-pushed the segmented-control-lift branch 2 times, most recently from ba3e59d to 76c0718 Compare November 3, 2026 10:27
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 76c0718

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the lift and its edge behave as the owner-approved FR14 describes, but one current record still contradicts them.

  • design:user-states DR3 (its rule, anatomy row, matrix row and example) still says the selected SegmentedControl item keeps its surface unchanged during a hold under every pointer, and FR14's "one exception" sentence cannot override another current record (architecture:knowledge-contracts INV9 and DEC-1), so restore the DR3 amendment from the previous push, have DR3 link to FR14 instead, or drop the lift.

The edge now survives a committing drag, which settles the earlier finding. One optional comment-style suggestion is inline.

[Automated review]

@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/revoke-spec 76c0718

Under a finger, a press on the selected segment grows its surface by
24 × 16 pt on UIKit's measured lift spring (critically damped, 0.25 s),
and it settles back on that spring at the release. While lifted it
carries the theme's low elevation shadow, as Switch's lifted thumb does,
until the surface is handed back, so the track stays visible around it.
The lift follows the presentation: a finger or a pen on a touch device
lifts it, while a desktop mouse and Reduce Motion lift nothing. The
record gains FR14 and the `segmented.lift` motion role. FR14 names the
lift as the one exception to design:user-states DR3's unchanged surface,
which this change leaves as it is. UIKit projects no flick, so the
release position still decides the segment.
@vjeux
vjeux force-pushed the segmented-control-lift branch from 76c0718 to 25e8e4c Compare November 10, 2026 03:01
@vjeux vjeux changed the title feat(SegmentedControl): under a finger, a press on the selected segment lifts its surface, as UIKit's does feat(SegmentedControl): under a finger, the selected surface lifts Nov 10, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the touch lift behaves as the owner-approved component:SegmentedControl FR14 describes, but one case leaves the selected surface in the wrong place.

  • Miss: tapping a segment and pressing it again while its slide is still running pins the lifted surface where the slide had got to, over the previous segments, until the finger lets go, against FR9's slide to the new segment; in lift() (useSegmentedSelectionMotion.ts:698-710) hold() ends the running slide and only the scale springs, so also spring x to 0 on the selection spring with the captured velocity, and add a test that holds the selected segment mid-slide.

The record changes carry an engineering owner's approval for this revision, no public API changes, and the SegmentedControl unit tests and the 59 Chromium interaction cases pass. CI has not run on this head yet because the pull request is a draft.

Automated review (maintainer link)

A finger that presses the segment a tap just chose, while the lens
still slides there, lifted the lens where the slide had got to. The
hold stops the running slide, and the lift sprang only the scale. The
lift now also springs the lens's offset to its segment on the slide
spring, with the slide's own velocity.
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec f6995a5

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this revision yet, because the pull request is a draft. It runs once the pull request is marked ready for review.

The touch lift matches the owner-approved component:SegmentedControl FR14 and the amended design:user-states DR3. The last review's blocker is fixed: a press on the segment a tap has just chosen now lets the surface finish its slide and lift there, and the new unit case covers it. Two optional comment rewrites remain in useSegmentedSelectionMotion.ts (the lift() JSDoc and the showLiftedEdge() doc).

Automated review (maintainer link)

Comment on lines +685 to +686
* The lens binds on the selected segment and grows by `liftGrowth` on the
* `lift` spring. A slide still on its way goes on to that segment on the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional (comment style, INV29): the first sentence narrates the body below. Suggested: "A running slide keeps its speed to this segment. Under the touch presentation any pointer lifts the lens, as Switch's thumb does. A fine primary pointer and Reduce Motion keep it at its resting size."

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 11, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 12b9d7f

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 11, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this revision yet, because the pull request is a draft. It runs once the pull request is marked ready for review.

The touch lift matches the owner-approved component:SegmentedControl FR14 and the amended design:user-states DR3, and the merge of main leaves the pull request's own changes as they were. Two optional comment rewrites remain in useSegmentedSelectionMotion.ts (the lift() JSDoc and the showLiftedEdge() doc).

Automated review (maintainer link)

@vjeux
vjeux marked this pull request as ready for review November 11, 2026 11:16
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 12b9d7f

@cixzhang

Copy link
Copy Markdown
Contributor

Decision: D-20261111-287

github-actions Bot added a commit that referenced this pull request Nov 11, 2026
@vjeux
vjeux marked this pull request as draft November 11, 2026 12:32
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 11, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 9c73784

@cixzhang

Copy link
Copy Markdown
Contributor

Decision: D-20261111-324

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 11, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. The touch lift matches the owner-approved component:SegmentedControl FR14 and the amended design:user-states DR3: a finger's or a pen's press on the selected segment grows it by 24 × 16 px with the theme's low shadow and settles back at the release, while a mouse, a trackpad or Reduce Motion lifts nothing. CI passes on this revision.

Optional:

  • design:user-states DEC-1 still says the selected segment's raised surface stays "stable"; a sentence after its unchanged Decider line pointing to the touch lift would keep the decision in step with DR3.

Automated review (maintainer link)

@vjeux
vjeux marked this pull request as ready for review November 11, 2026 13:50
github-actions Bot added a commit that referenced this pull request Nov 11, 2026
@cixzhang
cixzhang merged commit f8f9ce9 into meta:main Nov 11, 2026
134 checks passed
@vjeux
vjeux deleted the segmented-control-lift branch November 11, 2026 14:22

This branch was successfully deployed

1 active deployment
Preview — 9c737840 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants