Skip to content

Commit 081b45a

Browse files
committed
feat(List): rows on a touch screen are as tall as iOS table rows
On iOS 26.2 a table row is 52 pt at the default text size (the .default, .value1 and .value2 styles) and 62 pt with a subtitle, and the Human Interface Guidelines put iOS controls at 44 pt; a List row under a finger was 40 px, 60 px with a description, and 33 px in compact density. Under (pointer: coarse), ListItem now has a minimum height of 52 px, 62 px with a description, 44 px in compact density, read from the UIKit constants table (list.metrics) through a build-time mirror; a theme's min-height on list-item still wins, and mouse and trackpad lists are unchanged.
1 parent d1e37ac commit 081b45a

8 files changed

Lines changed: 273 additions & 8 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[feat] On a touch screen, `List` rows are as tall as iOS table rows: at least 52px, 62px with a description, and at least 44px in `density="compact"`, which used to put rows as short as 33px under a finger. Lists driven by a mouse or a trackpad are unchanged. A theme that sets `min-height` on `list-item` keeps its own value.
6+
7+
@vjeux

‎packages/core/src/List/List.doc.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const docs = {
3232
{
3333
name: 'density',
3434
type: "'compact' | 'balanced' | 'spacious'",
35-
description: 'Spacing density for items.',
35+
description: 'Spacing density for items. On a touch screen (a coarse primary pointer), rows are at least 52px tall, 62px with a description, and never shorter than 44px in compact density, as iOS table rows are.',
3636
default: "'balanced'",
3737
},
3838
{

‎packages/core/src/List/List.test.tsx‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {rulesDeclaredFor} from '../__tests__/pressState';
1616
import {List} from './List';
1717
import {ListItem} from './ListItem';
1818
import {ListMarkerScope} from './ListContext';
19+
import {listRowConsts} from './listRow.stylex';
20+
import {list} from '../motion/uikit/list';
1921

2022
describe('List', () => {
2123
it('forwards ListItem align to its Item row unchanged', () => {
@@ -545,6 +547,72 @@ describe('List', () => {
545547
).toBe(false);
546548
});
547549

550+
// ===========================================================================
551+
// Touch row heights
552+
// ===========================================================================
553+
554+
/**
555+
* The element's own min-height declarations, split by whether they sit
556+
* under the touch media query.
557+
*/
558+
function minHeights(el: Element): {touch: string[]; other: string[]} {
559+
const classes = el.className
560+
.split(/\s+/)
561+
.filter(Boolean)
562+
.map(name => `.${name}`);
563+
const out = {touch: [] as string[], other: [] as string[]};
564+
const visit = (rules: CSSRuleList, touch: boolean) => {
565+
for (const rule of Array.from(rules)) {
566+
if (rule instanceof CSSMediaRule) {
567+
visit(
568+
rule.cssRules,
569+
touch || rule.conditionText.includes('pointer: coarse'),
570+
);
571+
} else if (
572+
rule instanceof CSSStyleRule &&
573+
classes.some(cls => rule.selectorText.startsWith(cls)) &&
574+
rule.style.minHeight !== ''
575+
) {
576+
(touch ? out.touch : out.other).push(rule.style.minHeight);
577+
}
578+
}
579+
};
580+
for (const sheet of Array.from(document.styleSheets)) {
581+
visit(sheet.cssRules, false);
582+
}
583+
return out;
584+
}
585+
586+
it('mirrors the constants table’s touch row heights for the stylesheet', () => {
587+
expect(listRowConsts.touchRowHeight).toBe(`${list.metrics.rowHeight}px`);
588+
expect(listRowConsts.touchSubtitleRowHeight).toBe(
589+
`${list.metrics.subtitleRowHeight}px`,
590+
);
591+
expect(listRowConsts.touchControlSize).toBe(
592+
`${list.metrics.controlSize}px`,
593+
);
594+
});
595+
596+
it('gives rows UIKit’s table heights on a touch screen only', () => {
597+
render(
598+
<>
599+
<List>
600+
<ListItem label="One line" />
601+
<ListItem label="Two lines" description="A description" />
602+
</List>
603+
<List density="compact">
604+
<ListItem label="Compact" description="Still the control size" />
605+
</List>
606+
</>,
607+
);
608+
const row = (text: string) => screen.getByText(text).closest('li')!;
609+
expect(minHeights(row('One line')).touch).toEqual(['52px']);
610+
expect(minHeights(row('Two lines')).touch).toEqual(['62px']);
611+
expect(minHeights(row('Compact')).touch).toEqual(['44px']);
612+
// Nothing outside the touch query: a mouse-driven list is unchanged.
613+
expect(minHeights(row('One line')).other).toEqual([]);
614+
});
615+
548616
// ===========================================================================
549617
// Interactive items — onClick (invisible button pattern)
550618
// ===========================================================================

‎packages/core/src/List/List.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export interface ListProps extends BaseProps<
5353
* - 'compact': Tighter spacing for dense UIs
5454
* - 'balanced': Standard spacing
5555
* - 'spacious': Extra spacing for readability
56+
*
57+
* On a touch screen (a coarse primary pointer), rows are at least 52px
58+
* tall, 62px with a description, and never shorter than 44px in compact
59+
* density, as iOS table rows are.
5660
* @default 'balanced'
5761
*/
5862
density?: ListDensity;

‎packages/core/src/List/ListItem.tsx‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
/**
66
* @file ListItem.tsx
77
* @input Uses React, ReactNode, StyleXStyles, theme tokens, the List row edge
8-
* treatment, the press layer (dividers beside a touch-pressed row hide and
9-
* the layer reaches over the row's own), CheckboxInput, and the marker or task checkbox a
8+
* treatment, the press layer (dividers beside a touch-pressed or held row
9+
* hide and the layer reaches over the row's own), the touch row heights
10+
* (listRow.stylex.ts), CheckboxInput, and the marker or task checkbox a
1011
* ListMarkerScope sets (Markdown's nested lists and the task items of mixed
1112
* lists)
1213
* @output Exports ListItem component, ListItemProps type
@@ -35,10 +36,11 @@ import {
3536
import type {BaseProps} from '../BaseProps';
3637
import {ListContext, type ListMarker} from './ListContext';
3738
import {CheckboxInput} from '../CheckboxInput';
38-
import {mergeProps} from '../utils';
39+
import {isRenderable, mergeProps} from '../utils';
3940
import {Item} from '../Item';
4041
import type {ItemAlign, ItemSwipeActions, ItemSwipeBehavior} from '../Item';
4142
import {themeProps} from '../utils/themeProps';
43+
import {listRowStyles} from './listRow.stylex';
4244

4345
// =============================================================================
4446
// Types
@@ -312,6 +314,11 @@ const NUMBER_STYLES = {
312314
'lower-roman': markerStyles.lowerRoman,
313315
} as const;
314316

317+
/**
318+
* A row's height on a touch screen (primary pointer coarse): UIKit's table
319+
* rows (`list.metrics`), at least that tall, never shorter than the
320+
* platform's control size. A theme's `min-height` on `list-item` replaces it.
321+
*/
315322
const embeddedStyles = stylex.create({
316323
noRadius: {
317324
borderRadius: 0,
@@ -420,6 +427,11 @@ export function ListItem({
420427
hasMarkers && styles.withCounter,
421428
hasDividers && styles.withDivider,
422429
hasDividers && embeddedStyles.noRadius,
430+
density === 'compact'
431+
? listRowStyles.touchCompact
432+
: isRenderable(description)
433+
? listRowStyles.touchTwoLine
434+
: listRowStyles.touchOneLine,
423435
edge === 'flush' && styles.edgeFlush,
424436
edge === 'outset' && styles.edgeOutset,
425437
edge === 'bleed' && styles.edgeBleed,
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
3+
/**
4+
* @file ListTouchRows.interaction.browser.spec.ts
5+
* @input The built List stories in the touch phone context (primary pointer
6+
* coarse) and the row heights from the UIKit constants table
7+
* (motion/uikit/list.ts)
8+
* @output Layout proofs for List rows on a touch screen: a one-line row is
9+
* UIKit's table row height, a row with a description its subtitle height,
10+
* a compact row the platform's control size, dividers included; a
11+
* storyboard of the three
12+
* @position Interaction evidence for ListItem's touch row heights
13+
* (listRow.stylex.ts)
14+
*/
15+
16+
import {expect, test, type Page} from '@playwright/test';
17+
import {
18+
openStory,
19+
Storyboard,
20+
withStorybook,
21+
} from '@astryxdesign/interaction-harness';
22+
import {list} from '../../motion/uikit/list';
23+
24+
const storybook = withStorybook(test);
25+
26+
async function rowHeights(page: Page): Promise<number[]> {
27+
// The story's rows (Storybook's own hidden error page has list items too).
28+
return page
29+
.locator('#storybook-root li')
30+
.evaluateAll(rows =>
31+
rows.map(row => Math.round(row.getBoundingClientRect().height)),
32+
);
33+
}
34+
35+
const isTouch = async (page: Page) =>
36+
page.evaluate(() => matchMedia('(pointer: coarse)').matches);
37+
38+
const CASES = [
39+
{
40+
story: 'core-list--interactive',
41+
what: 'a one-line row is UIKit’s table row height',
42+
height: list.metrics.rowHeight,
43+
},
44+
{
45+
story: 'core-list--basic',
46+
what: 'a row with a description is UIKit’s subtitle row height',
47+
height: list.metrics.subtitleRowHeight,
48+
},
49+
{
50+
story: 'core-list--compact',
51+
what: 'a compact row, divider included, is the platform’s control size',
52+
height: list.metrics.controlSize,
53+
},
54+
] as const;
55+
56+
for (const {story, what, height} of CASES) {
57+
test(`on a touch screen, ${what}`, async ({page}) => {
58+
await openStory(page, storybook(), story);
59+
test.skip(
60+
!(await isTouch(page)),
61+
'this engine reports a fine primary pointer; the touch heights apply under (pointer: coarse)',
62+
);
63+
const heights = await rowHeights(page);
64+
expect(heights.length).toBeGreaterThan(0);
65+
for (const h of heights) {
66+
expect(h).toBe(height);
67+
}
68+
});
69+
}
70+
71+
test('storyboard: List rows on a touch screen @storyboard', async ({
72+
page,
73+
}, testInfo) => {
74+
test.skip(
75+
testInfo.project.name !== 'chromium',
76+
'One engine is enough for the record',
77+
);
78+
const storyboard = new Storyboard(page, {
79+
name: 'list-touch-rows',
80+
columns: 3,
81+
cellScale: 0.6,
82+
});
83+
for (const {story} of CASES) {
84+
await openStory(page, storybook(), story);
85+
// One clip size for every cell of the sheet.
86+
await page.setViewportSize({width: 402, height: 714});
87+
await storyboard.capture(story, 0, {rows: await rowHeights(page)});
88+
}
89+
await storyboard.write(testInfo);
90+
});
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
3+
/**
4+
* @file listRow.stylex.ts
5+
* @input Uses StyleX
6+
* @output Exports `listRowConsts` (the build-time mirror of the touch row
7+
* heights in motion/uikit/list.ts, `list.metrics`) and `listRowStyles` (a
8+
* row's minimum height under the touch media query)
9+
* @position Internal styling utility; ListItem composes `listRowStyles`
10+
*
11+
* StyleX evaluates a style at build time and cannot read the constants
12+
* table, so these are the table's `list.metrics` values as CSS lengths, and
13+
* List.test.tsx fails if they drift. They are sizes, not motion: a theme
14+
* that sets a `min-height` on its `list-item` target replaces them.
15+
*
16+
* The styles live beside the constants on purpose: StyleX inlines a
17+
* `defineConsts` value it reads in the same file, while a value imported
18+
* into another file compiles to a custom property reference that the
19+
* production build never defines.
20+
*
21+
* SYNC: When modified, update motion/uikit/list.ts and List.test.tsx.
22+
*/
23+
24+
import * as stylex from '@stylexjs/stylex';
25+
26+
export const listRowConsts = stylex.defineConsts({
27+
/** `list.metrics.rowHeight`: a one-line row on a touch screen. */
28+
touchRowHeight: '52px',
29+
/** `list.metrics.subtitleRowHeight`: a row with a description. */
30+
touchSubtitleRowHeight: '62px',
31+
/** `list.metrics.controlSize`: the floor of a compact touch row. */
32+
touchControlSize: '44px',
33+
});
34+
35+
/**
36+
* The touch presentation's query (utils/touchPresentation.ts TOUCH_QUERY),
37+
* written out: StyleX needs a literal media key.
38+
*/
39+
const TOUCH = '@media (pointer: coarse)';
40+
41+
/**
42+
* A row's height on a touch screen (primary pointer coarse): UIKit's table
43+
* rows, at least that tall, never shorter than the platform's control size.
44+
* A theme's `min-height` on `list-item` replaces it.
45+
*/
46+
export const listRowStyles = stylex.create({
47+
touchOneLine: {
48+
minHeight: {default: null, [TOUCH]: listRowConsts.touchRowHeight},
49+
},
50+
touchTwoLine: {
51+
minHeight: {default: null, [TOUCH]: listRowConsts.touchSubtitleRowHeight},
52+
},
53+
touchCompact: {
54+
minHeight: {default: null, [TOUCH]: listRowConsts.touchControlSize},
55+
},
56+
});

‎packages/core/src/motion/uikit/list.ts‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@
55
* @input `timing` (the press clocks the touch press model measured)
66
* @output Exports `list`: the clocks and curves of UITableView and
77
* UICollectionView list cells (the cell highlight's release, the selected
8-
* cell's deselect inside a navigation pop)
8+
* cell's deselect inside a navigation pop, the touch row heights)
99
* @position The list domain of the UIKit constants table (motion/uikit);
1010
* read by utils/pressLayer.stylex.ts (row press paint) through its
11-
* build-time mirror, and by utils/selectionHold.ts (a row kept selected
12-
* through a navigation push)
11+
* build-time mirror, by utils/selectionHold.ts (a row kept selected
12+
* through a navigation push), and by List/listRow.stylex.ts (touch row
13+
* heights) through its mirror
1314
*
1415
* Every leaf carries one or more `@source`; GUESS values also carry the
1516
* `@measure` task that will confirm or replace them (MEASUREMENTS.md, M-LI
1617
* rows). uikit.test.ts enforces both. Durations are in ms; curves are
17-
* cubic-bézier control points [x1, y1, x2, y2].
18+
* cubic-bézier control points [x1, y1, x2, y2]; lengths are in points, one
19+
* CSS px each.
1820
*
1921
* SYNC: When modified, update:
2022
* - /packages/core/src/motion/MEASUREMENTS.md
2123
* - /packages/core/src/utils/pressLayer.stylex.ts (`pressLayerConsts` mirrors
2224
* the cell release; pressLayer.test.ts checks it)
25+
* - /packages/core/src/List/listRow.stylex.ts (`listRowConsts` mirrors the
26+
* row heights; List.test.tsx checks it)
2327
*/
2428

2529
import {timing} from './timing';
@@ -67,4 +71,28 @@ export const list = {
6771
*/
6872
navigationPopCurve: [0, 0, 1, 1],
6973
},
74+
metrics: {
75+
/**
76+
* A one-line row's height: the `.default`, `.value1` and `.value2`
77+
* styles at the default text size (`rowHeight` automatic).
78+
* @source measured: UIKit lab (injected host app), iOS 26.2 sim iPhone
79+
* 17 Pro, view frame read (UITableView cells), Oct 23 2026
80+
*/
81+
rowHeight: 52,
82+
/**
83+
* A row with a second line: the `.subtitle` style at the default text
84+
* size.
85+
* @source measured: UIKit lab (injected host app), iOS 26.2 sim iPhone
86+
* 17 Pro, view frame read (UITableView cells), Oct 23 2026
87+
*/
88+
subtitleRowHeight: 62,
89+
/**
90+
* The control size the Human Interface Guidelines recommend on iOS and
91+
* iPadOS: the floor for a touch row, however dense.
92+
* @source apple-docs https://developer.apple.com/design/human-interface-guidelines/accessibility#Mobility
93+
* ("Default control size … iOS, iPadOS 44x44 pt"; the minimum is 28x28
94+
* pt)
95+
*/
96+
controlSize: 44,
97+
},
7098
} as const;

0 commit comments

Comments
 (0)