Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(Button): a labelled button grows with its label (#10588)

Cindy Zhang7bc8230f8b9d
diff --git a/.changeset/butter-button-keeps-height.md b/.changeset/butter-button-keeps-height.md
new file mode 100644
index 0000000000..4127169af2
--- /dev/null
+++ b/.changeset/butter-button-keeps-height.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/theme-butter': patch
+---
+
+[fix] Butter's labelled buttons keep their element heights now that a `Button`'s size is a minimum height: the theme no longer adds block padding to buttons.
+
+@cixzhang
diff --git a/.changeset/button-grows-with-text.md b/.changeset/button-grows-with-text.md
new file mode 100644
index 0000000000..ce6e56f61e
--- /dev/null
+++ b/.changeset/button-grows-with-text.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] A labelled `Button`'s size is now a minimum height: a label larger than the element size grows the button, so the label stays inside it. At the default text size Buttons keep their size, and icon-only buttons keep their fixed square. A caller `height` override no longer brings a labelled Button below its size; override `minHeight` instead. A theme or caller block padding on a labelled Button now counts toward its height, so it can make the button taller than its size.
+
+@cixzhang
diff --git a/.changeset/table-filter-header-actions-keep-size.md b/.changeset/table-filter-header-actions-keep-size.md
new file mode 100644
index 0000000000..d11e38e72d
--- /dev/null
+++ b/.changeset/table-filter-header-actions-keep-size.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/cli': patch
+---
+
+[fix] The `table-filter` template's link-style header actions keep their compact height now that a labelled `Button`'s size is a minimum height.
+
+@cixzhang
diff --git a/docs/specs/AST-102-typography-theme-owned/spec.md b/docs/specs/AST-102-typography-theme-owned/spec.md
index d9228cf202..573e75c89e 100644
--- a/docs/specs/AST-102-typography-theme-owned/spec.md
+++ b/docs/specs/AST-102-typography-theme-owned/spec.md
@@ -113,10 +113,9 @@ the person's device.
- Defects under FR3 and FR4:
- On iOS and iPadOS, text ignores Dynamic Type in every theme.
- Controls hold fixed heights, such as 40 px elements, `component:Badge`
- FR1's block size, `component:Button` FR4's and `component:Token` FR1's
- element sizes, and InputGroup's row height in `family:input-fields`, so a
- larger label can overflow; those records treat their sizes as minimums
- under FR4.
+ FR1's block size, `component:Token` FR1's element size, and InputGroup's
+ row height in `family:input-fields`, so a larger label can overflow; those
+ records treat their sizes as minimums under FR4.
- Whether Chrome on Android carries the system font scale to Astryx text is
unverified until the emulator check FR3 names.
diff --git a/docs/specs/components/Button/Button.spec.md b/docs/specs/components/Button/Button.spec.md
index ff1bbe18c4..0fb961cf44 100644
--- a/docs/specs/components/Button/Button.spec.md
+++ b/docs/specs/components/Button/Button.spec.md
@@ -17,6 +17,7 @@ verified_by:
packages/core/src/ButtonGroup/ButtonGroup.test.tsx,
packages/core/src/Button/__tests__/Button.a11y.test.tsx,
packages/core/src/Button/__tests__/Button.a11y.chromium.spec.ts,
+ packages/core/src/Button/__tests__/ButtonTextSize.interaction.browser.spec.ts,
packages/core/src/__tests__/ReducedMotionPress.a11y.chromium.spec.ts,
packages/core/src/Layout/__tests__/edgeCompensation.test.tsx,
packages/core/src/utils/pressFeedback.test.ts,
@@ -125,7 +126,7 @@ Consumer migration instructions belong in consumer docs and release notes.
| FR1 | Without link mode Button renders one native `<button>` with `type="button"` unless `type` says otherwise; `name`, `value`, and `form` reach that element. | `family:buttons` FR2; current source and tests |
| FR2 | Content renders in this order: the leading `icon` slot, the label text (`children` when supplied, else `label`), then `endContent`. Icon-only renders the icon alone and omits the label text and `endContent`. `endContent` inherits the Button's text color. | `family:buttons` AV2; current source and tests |
| FR3 | An Astryx Icon in the `icon` slot without an explicit size renders `sm` in `sm` and `md` Buttons and `md` in `lg` Buttons; an explicit Icon size wins. | `family:buttons` FR7; current source |
-| FR4 | Height comes from the shared element size for the resolved size, as a minimum that grows with a set text size under `spec:AST-102` FR4 (today's fixed height is a gap): an explicit `size` wins, then the nearest size provider, then `md`. Icon-only is square (`--button-icon-only-aspect`, default `1 / 1`) with no padding. | `family:buttons` FR7; `architecture:component-size-cascade` INV3–INV5 |
+| FR4 | Height comes from the shared element size for the resolved size, as a minimum that grows with a set text size under `spec:AST-102` FR4, so a label stays inside its own button: an explicit `size` wins, then the nearest size provider, then `md`. A labelled button has no block padding, so its label's line box decides any height above the minimum. Icon-only is square (`--button-icon-only-aspect`, default `1 / 1`) with no padding and keeps the element size, since its glyph does not grow with the text. | `family:buttons` FR7; `architecture:component-size-cascade` INV3–INV5 |
| FR5 | The label stays on one line. A labelled Button may shrink in a row, never exceeds its container's inline size, and truncates the label with an ellipsis. An explicit `width` applies in button and link modes and is still capped at the container. Icon-only does not shrink and is not capped. | Current source and tests |
| FR6 | On activation `onClick` runs first. If it calls `preventDefault()`, `clickAction` does not run. Otherwise `clickAction` runs, and the Button is pending until its promise settles. | `family:buttons` FR5; current source and tests |
| FR7 | A fire-once `clickAction` runs once per in-flight action: a second activation while it is pending, including a same-tick double-click, does nothing. With `isInterruptible`, a pending Button stays operable and each activation starts a new `clickAction`. | `family:buttons` FR5; current source and tests |
@@ -256,36 +257,36 @@ anatomy-theming map.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
-| FR1, FR2, AR1 | `Button.test.tsx` label, children, icon-only, end-content presence, and `type` cases; `Button.a11y.test.tsx`; `Button.a11y.chromium.spec.ts` | Text, icon-only, composed label, end content, submit type | A lost name, a wrong default `type`, or end content in icon-only fails. | `audit:Button/anatomy` |
-| FR1, FR2 (gaps) | Evidence gap: no test passes `name`, `value`, or `form`, or asserts the order of icon, label, and end content | — | — | `audit:Button/anatomy` |
-| FR3 | Evidence gap: no Button-level test of the text-mode icon slot default | `sm`, `md`, `lg` with an unsized Icon | — | `audit:Button/anatomy` |
-| FR4 | Evidence gap: no test asserts the height per size or the explicit `size`, then nearest provider, then `md` order | `sm`, `md`, `lg`; inside a size provider | — | `audit:Button/layout` |
-| FR5 | `Button.test.tsx` width and narrow-row suites; InputGroup addon case | Numeric and string width, link mode, icon-only, grouped | A Button that overflows its row, stops truncating, or squeezes icon-only fails. | `audit:Button/layout` |
-| FR6, FR7 | `Button.test.tsx` click, double-click, and interruptible suites | onClick then clickAction; preventDefault; double-click; re-click | Order flips, a prevented click runs the action, or a fire-once action runs twice fails. | `audit:Button/behavior` |
-| FR8, AR4 | `Button.test.tsx` loading, spinner shade, and live-region suites | `isLoading`; pending `clickAction`; first render loading | Missing `aria-busy`, a wrong Spinner shade, or a live region mounted with text fails. | `audit:Button/behavior` |
-| FR8 (hide and delay) | Evidence gap: no test asserts the hidden content, the reveal delay, or the reduced-motion path; the shipped Spinner fade fails the fine-pointer reduced-motion clause (Current-state impact) | `isLoading`; pending `clickAction`; interruptible | Under reduced motion with a fine pointer, a Spinner opacity below 1 after the loading state starts. | `audit:Button/behavior` |
-| FR8 (outer size) | Evidence gap: no test measures that a pending Button keeps its outer size | Loading text, icon-only, and end-content Buttons | — | `audit:Button/layout` |
-| FR9, FR10, AR5 | `Button.test.tsx` aria-disabled, busy-only, and native-disabled suites; `Button.a11y.chromium.spec.ts` | Busy-only, tooltip-disabled, disabled, disabled and loading | A busy Button loses focus, an inert Button fires, or a click reaches an ancestor fails. Native-disabled assertions match the FR10 gap. | `audit:Button/accessibility` |
-| FR11 | `Button.test.tsx` link-mode suites | Link, busy-only link, disabled `href` | A disabled link navigates or a busy link turns into a `<button>` fails. | `audit:Button/behavior` |
-| FR12 | `Button.a11y.chromium.spec.ts` described state | Disabled with tooltip | A tooltip that does not describe the Button fails. | `audit:Button/accessibility` |
-| FR12 (placement and order) | Evidence gap: no test asserts that the tooltip opens above the Button or that its id follows a caller `aria-describedby` | Tooltip with and without a caller description | — | `audit:Button/accessibility` |
-| FR13, FR14 | `Button.test.tsx` theme-target and elevation suites; `ButtonGroup.test.tsx` "reports flat on a member, since the group owns the surface" for the grouped `data-elevation="none"` | `secondary` target attributes; every elevation tier | A missing target, or a `data-elevation` other than the effective tier, fails. | `audit:Button/theming` |
-| FR13 (painted shadow) | Evidence gap: no test reads the painted shadow, so a grouped Button that paints its own shadow, or swapped tier shadows, would pass | Standalone tiers; grouped member | — | `audit:Button/theming` |
-| FR14 (per variant) | Evidence gap: `data-variant` is asserted for `secondary` only | Other variants | — | `audit:Button/theming` |
-| FR15 | `Button.test.tsx` touch pressed-state suite | Touch press on and fading | Losing the touch press arm or its release fade fails. | `audit:Button/behavior` |
-| FR15 (disabled paint) | `pressFeedback.test.ts` "paints nothing on a disabled surface, and does not light the row around it" for the touch press. Evidence gap: no test of the hover and pressed overlays or the mouse scale on a Button exposed as disabled | Native disabled; `aria-disabled` | A disabled surface that takes the touch press fails. | `audit:Button/behavior` |
-| FR15 (reduced motion) | `ReducedMotionPress.a11y.chromium.spec.ts` ("a pressed button never scales under reduced motion, with a mouse or a finger (DR1)") | Mouse press; touch press | A computed transform other than `none` or `scale(1)` during the press. | `audit:Button/behavior` |
-| `spec:AST-094` FR42 | `Button.hitArea.test.tsx`: a standalone and a link Button take the touch band on their content wrapper, and a caller's `::after` stays on the button; a disabled, busy-only or grouped Button takes none | standalone; link; caller `::after`; disabled; busy-only; grouped | A Button without the band, or a disabled, busy-only or grouped Button with its own, fails. | `audit:Button/behavior` |
-| FR15 (hover and mouse scale) | Evidence gap: no test asserts the hover overlay or the 0.98 mouse-press scale | Hover; mouse press, standalone and grouped | — | `audit:Button/behavior` |
-| FR16 | `edgeCompensation.test.tsx` Button data-attribute suite | Ghost and primary | A ghost Button without the marker, or a primary Button with it, fails. | `audit:Button/layout` |
-| FR17 | `Button.test.tsx` ref suites and the caller `aria-disabled`/`aria-busy` case | Initial render and rerender; caller `aria-busy` and `aria-disabled` | A dropped or detached ref, or a dropped caller `aria-busy` or `aria-disabled`, fails. Evidence gap: no test asserts that a caller `aria-disabled` leaves the Button operable. | `audit:Button/behavior` |
-| ORD1, ORD5 | Evidence gap: no test asserts size precedence (see FR4) or that caller `xstyle`, `className`, and `style` win over Button's own styles | — | — | `audit:Button/behavior` |
-| ORD4 | `Button.test.tsx` icon-only and composed-label cases. Evidence gap: no test asserts the `aria-label` set while pending or when `children` differs from `label`, or the content name with icon-slot or end-content text | Icon-only; composed label | An icon-only Button without `aria-label`, or a composed label that gains one, fails. | `audit:Button/accessibility` |
-| AR2 | `Button.a11y.chromium.spec.ts` activation and tab-reachability checks. Evidence gap: no test of Enter activation in link mode | Text and icon-only Buttons | A Button that Enter or Space does not activate, or that Tab skips, fails. | `audit:Button/accessibility` |
-| AR3 | Evidence gap: no test asserts the focus outline or the destructive error-colored ring | Keyboard focus; destructive | — | `audit:Button/accessibility` |
-| AR6, PR1 | Evidence gap: no test measures the target size or asserts that an idle Button schedules nothing | — | — | `audit:Button/behavior` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
+| FR1, FR2, AR1 | `Button.test.tsx` label, children, icon-only, end-content presence, and `type` cases; `Button.a11y.test.tsx`; `Button.a11y.chromium.spec.ts` | Text, icon-only, composed label, end content, submit type | A lost name, a wrong default `type`, or end content in icon-only fails. | `audit:Button/anatomy` |
+| FR1, FR2 (gaps) | Evidence gap: no test passes `name`, `value`, or `form`, or asserts the order of icon, label, and end content | — | — | `audit:Button/anatomy` |
+| FR3 | Evidence gap: no Button-level test of the text-mode icon slot default | `sm`, `md`, `lg` with an unsized Icon | — | `audit:Button/anatomy` |
+| FR4 | `ButtonTextSize.interaction.browser.spec.ts` (a label larger than the element size grows its button; the default size keeps the element size). Evidence gap: no test asserts the explicit `size`, then nearest provider, then `md` order | `sm`, `md`, `lg`; inside a size provider | — | `audit:Button/layout` |
+| FR5 | `Button.test.tsx` width and narrow-row suites; InputGroup addon case | Numeric and string width, link mode, icon-only, grouped | A Button that overflows its row, stops truncating, or squeezes icon-only fails. | `audit:Button/layout` |
+| FR6, FR7 | `Button.test.tsx` click, double-click, and interruptible suites | onClick then clickAction; preventDefault; double-click; re-click | Order flips, a prevented click runs the action, or a fire-once action runs twice fails. | `audit:Button/behavior` |
+| FR8, AR4 | `Button.test.tsx` loading, spinner shade, and live-region suites | `isLoading`; pending `clickAction`; first render loading | Missing `aria-busy`, a wrong Spinner shade, or a live region mounted with text fails. | `audit:Button/behavior` |
+| FR8 (hide and delay) | Evidence gap: no test asserts the hidden content, the reveal delay, or the reduced-motion path; the shipped Spinner fade fails the fine-pointer reduced-motion clause (Current-state impact) | `isLoading`; pending `clickAction`; interruptible | Under reduced motion with a fine pointer, a Spinner opacity below 1 after the loading state starts. | `audit:Button/behavior` |
+| FR8 (outer size) | Evidence gap: no test measures that a pending Button keeps its outer size | Loading text, icon-only, and end-content Buttons | — | `audit:Button/layout` |
+| FR9, FR10, AR5 | `Button.test.tsx` aria-disabled, busy-only, and native-disabled suites; `Button.a11y.chromium.spec.ts` | Busy-only, tooltip-disabled, disabled, disabled and loading | A busy Button loses focus, an inert Button fires, or a click reaches an ancestor fails. Native-disabled assertions match the FR10 gap. | `audit:Button/accessibility` |
+| FR11 | `Button.test.tsx` link-mode suites | Link, busy-only link, disabled `href` | A disabled link navigates or a busy link turns into a `<button>` fails. | `audit:Button/behavior` |
+| FR12 | `Button.a11y.chromium.spec.ts` described state | Disabled with tooltip | A tooltip that does not describe the Button fails. | `audit:Button/accessibility` |
+| FR12 (placement and order) | Evidence gap: no test asserts that the tooltip opens above the Button or that its id follows a caller `aria-describedby` | Tooltip with and without a caller description | — | `audit:Button/accessibility` |
+| FR13, FR14 | `Button.test.tsx` theme-target and elevation suites; `ButtonGroup.test.tsx` "reports flat on a member, since the group owns the surface" for the grouped `data-elevation="none"` | `secondary` target attributes; every elevation tier | A missing target, or a `data-elevation` other than the effective tier, fails. | `audit:Button/theming` |
+| FR13 (painted shadow) | Evidence gap: no test reads the painted shadow, so a grouped Button that paints its own shadow, or swapped tier shadows, would pass | Standalone tiers; grouped member | — | `audit:Button/theming` |
+| FR14 (per variant) | Evidence gap: `data-variant` is asserted for `secondary` only | Other variants | — | `audit:Button/theming` |
+| FR15 | `Button.test.tsx` touch pressed-state suite | Touch press on and fading | Losing the touch press arm or its release fade fails. | `audit:Button/behavior` |
+| FR15 (disabled paint) | `pressFeedback.test.ts` "paints nothing on a disabled surface, and does not light the row around it" for the touch press. Evidence gap: no test of the hover and pressed overlays or the mouse scale on a Button exposed as disabled | Native disabled; `aria-disabled` | A disabled surface that takes the touch press fails. | `audit:Button/behavior` |
+| FR15 (reduced motion) | `ReducedMotionPress.a11y.chromium.spec.ts` ("a pressed button never scales under reduced motion, with a mouse or a finger (DR1)") | Mouse press; touch press | A computed transform other than `none` or `scale(1)` during the press. | `audit:Button/behavior` |
+| `spec:AST-094` FR42 | `Button.hitArea.test.tsx`: a standalone and a link Button take the touch band on their content wrapper, and a caller's `::after` stays on the button; a disabled, busy-only or grouped Button takes none | standalone; link; caller `::after`; disabled; busy-only; grouped | A Button without the band, or a disabled, busy-only or grouped Button with its own, fails. | `audit:Button/behavior` |
+| FR15 (hover and mouse scale) | Evidence gap: no test asserts the hover overlay or the 0.98 mouse-press scale | Hover; mouse press, standalone and grouped | — | `audit:Button/behavior` |
+| FR16 | `edgeCompensation.test.tsx` Button data-attribute suite | Ghost and primary | A ghost Button without the marker, or a primary Button with it, fails. | `audit:Button/layout` |
+| FR17 | `Button.test.tsx` ref suites and the caller `aria-disabled`/`aria-busy` case | Initial render and rerender; caller `aria-busy` and `aria-disabled` | A dropped or detached ref, or a dropped caller `aria-busy` or `aria-disabled`, fails. Evidence gap: no test asserts that a caller `aria-disabled` leaves the Button operable. | `audit:Button/behavior` |
+| ORD1, ORD5 | Evidence gap: no test asserts size precedence (see FR4) or that caller `xstyle`, `className`, and `style` win over Button's own styles | — | — | `audit:Button/behavior` |
+| ORD4 | `Button.test.tsx` icon-only and composed-label cases. Evidence gap: no test asserts the `aria-label` set while pending or when `children` differs from `label`, or the content name with icon-slot or end-content text | Icon-only; composed label | An icon-only Button without `aria-label`, or a composed label that gains one, fails. | `audit:Button/accessibility` |
+| AR2 | `Button.a11y.chromium.spec.ts` activation and tab-reachability checks. Evidence gap: no test of Enter activation in link mode | Text and icon-only Buttons | A Button that Enter or Space does not activate, or that Tab skips, fails. | `audit:Button/accessibility` |
+| AR3 | Evidence gap: no test asserts the focus outline or the destructive error-colored ring | Keyboard focus; destructive | — | `audit:Button/accessibility` |
+| AR6, PR1 | Evidence gap: no test measures the target size or asserts that an idle Button schedules nothing | — | — | `audit:Button/behavior` |
## Current-state impact
diff --git a/packages/cli/assets/templates/pages/table-filter/page.tsx b/packages/cli/assets/templates/pages/table-filter/page.tsx
index 66d1485550..737985ca37 100644
--- a/packages/cli/assets/templates/pages/table-filter/page.tsx
+++ b/packages/cli/assets/templates/pages/table-filter/page.tsx
@@ -1698,6 +1698,7 @@ const styles = stylex.create({
fontSize: typeScaleVars['--text-body-size'],
fontWeight: typeScaleVars['--text-body-weight'],
height: 'auto',
+ minHeight: 0,
lineHeight: typeScaleVars['--text-body-leading'],
paddingBlock: 0,
paddingInline: 0,
diff --git a/packages/cli/assets/templates/themes/butter/butterTheme.ts b/packages/cli/assets/templates/themes/butter/butterTheme.ts
index d591917473..e022683c77 100644
--- a/packages/cli/assets/templates/themes/butter/butterTheme.ts
+++ b/packages/cli/assets/templates/themes/butter/butterTheme.ts
@@ -394,8 +394,9 @@ export const butterTheme = defineTheme({
// Radius intentionally not pinned, so buttons keep core's
// `var(--_button-radius, --radius-element)`: standalone buttons stay 8px,
// while the chat composer (which sets --_button-radius) rounds them fully.
+ // Inline padding only: a labelled button's size is its minimum height,
+ // and block padding would add to it.
base: {
- paddingBlock: 'var(--spacing-3)',
paddingInline: 'var(--spacing-4)',
},
'variant:secondary': SECONDARY_BUTTON,
diff --git a/packages/core/src/AlertDialog/AlertDialog.test.tsx b/packages/core/src/AlertDialog/AlertDialog.test.tsx
index f2f28dd189..cf9c809f4d 100644
--- a/packages/core/src/AlertDialog/AlertDialog.test.tsx
+++ b/packages/core/src/AlertDialog/AlertDialog.test.tsx
@@ -291,7 +291,7 @@ describe('AlertDialog', () => {
for (const button of buttons) {
const computed = getComputedStyle(button);
expect(computed.whiteSpace).toBe('nowrap');
- expect(computed.height).toBe('var(--size-element-md)');
+ expect(computed.minHeight).toBe('var(--size-element-md)');
expect(computed.maxWidth).toBe('100%');
}
});
diff --git a/packages/core/src/Button/Button.tsx b/packages/core/src/Button/Button.tsx
index 5a14feb06f..41809f63b4 100644
--- a/packages/core/src/Button/Button.tsx
+++ b/packages/core/src/Button/Button.tsx
@@ -118,7 +118,6 @@ const styles = stylex.create({
alignItems: 'center',
justifyContent: 'center',
gap: spacingVars['--spacing-2'],
- paddingBlock: spacingVars['--spacing-2'],
paddingInline: spacingVars['--spacing-3'],
borderWidth: 0,
borderStyle: 'none',
@@ -269,16 +268,20 @@ const dynamicStyles = stylex.create({
width: (width: SizeValue | null) => ({width}),
});
+// A label can outgrow the element size when the text size grows. The size is
+// a minimum, so the button grows and its label stays inside the tap target.
const sizeStyles = stylex.create({
- sm: {
- height: sizeVars['--size-element-sm'],
- },
- md: {
- height: sizeVars['--size-element-md'],
- },
- lg: {
- height: sizeVars['--size-element-lg'],
- },
+ sm: {minHeight: sizeVars['--size-element-sm']},
+ md: {minHeight: sizeVars['--size-element-md']},
+ lg: {minHeight: sizeVars['--size-element-lg']},
+});
+
+// An icon-only button holds its glyph, which does not grow with the text, so
+// it keeps a fixed square size.
+const iconOnlySizeStyles = stylex.create({
+ sm: {height: sizeVars['--size-element-sm']},
+ md: {height: sizeVars['--size-element-md']},
+ lg: {height: sizeVars['--size-element-lg']},
});
/**
@@ -823,7 +826,7 @@ export function Button({
// Shared StyleX props for both button and link rendering
const sharedStylexProps = focusOutlineProps.focusVisible(
styles.base,
- sizeStyles[size],
+ isIconOnly ? iconOnlySizeStyles[size] : sizeStyles[size],
isIconOnly && styles.iconOnly,
interactionOverlayStyles.backgroundImage,
// The press the controller writes, on a layer under the label whose
diff --git a/packages/core/src/Button/__tests__/ButtonTextSize.interaction.browser.spec.ts b/packages/core/src/Button/__tests__/ButtonTextSize.interaction.browser.spec.ts
new file mode 100644
index 0000000000..76a1f2deac
--- /dev/null
+++ b/packages/core/src/Button/__tests__/ButtonTextSize.interaction.browser.spec.ts
@@ -0,0 +1,98 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file ButtonTextSize.interaction.browser.spec.ts
+ * @input The built Button stories, with the button labels' text enlarged
+ * while the element sizes stay put, as iOS Dynamic Type does
+ * @output Real-browser evidence that a labelled button grows with its label,
+ * so the label stays inside its own tap target, and that the default text
+ * size keeps every button at its element size
+ * @position Browser proof of Button FR4 (AST-102 FR4)
+ */
+
+import {expect, test, type Page} from '@astryxdesign/a11y-spec/playwright';
+import {
+ DEFAULT_STORYBOOK_DIR,
+ serveStorybook,
+ type StaticServer,
+} from '@astryxdesign/a11y-spec/storybook';
+
+let storybook: StaticServer;
+
+test.beforeAll(async () => {
+ storybook = await serveStorybook(
+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,
+ );
+});
+
+test.afterAll(async () => {
+ await storybook?.close();
+});
+
+async function openStory(
+ page: Page,
+ story: string,
+ theme = 'neutral',
+): Promise<void> {
+ await page.goto(
+ `${storybook.origin}/iframe.html?id=core-button--${story}&viewMode=story&globals=astryxTheme:${theme}`,
+ );
+ await page.locator('#storybook-root button').first().waitFor();
+}
+
+/** Each labelled button's box against its label's line box. */
+async function readButtons(page: Page) {
+ return page.evaluate(() =>
+ [...document.querySelectorAll<HTMLElement>('#storybook-root button')]
+ .filter(button => (button.textContent ?? '').trim() !== '')
+ .map(button => {
+ const range = document.createRange();
+ range.selectNodeContents(button);
+ const label = range.getBoundingClientRect();
+ const box = button.getBoundingClientRect();
+ return {
+ name: (button.textContent ?? '').trim(),
+ height: box.height,
+ above: box.top - label.top,
+ below: label.bottom - box.bottom,
+ };
+ }),
+ );
+}
+
+// Butter pads its buttons inline only, so its labelled buttons keep their
+// element heights too.
+for (const theme of ['neutral', 'butter']) {
+ test(`at the default text size each size keeps its element height: ${theme}`, async ({
+ page,
+ }) => {
+ await openStory(page, 'size-variants', theme);
+ const fits = await page.evaluate(() =>
+ [...document.querySelectorAll<HTMLElement>('#storybook-root button')].map(
+ button =>
+ Math.round(button.getBoundingClientRect().height) ===
+ Math.round(parseFloat(getComputedStyle(button).minHeight)),
+ ),
+ );
+ expect(fits).toEqual([true, true, true]);
+ });
+}
+
+for (const story of ['primary', 'size-variants', 'icon-with-text']) {
+ test(`a label larger than the element size grows its button: ${story}`, async ({
+ page,
+ }) => {
+ await openStory(page, story);
+ // Grows the labels' text, but not the element sizes, the way iOS Dynamic
+ // Type grows theme text at its accessibility sizes.
+ await page.addStyleTag({
+ content: '#storybook-root button { font-size: 40px; line-height: 60px; }',
+ });
+ const buttons = await readButtons(page);
+ expect(buttons.length).toBeGreaterThan(0);
+ for (const button of buttons) {
+ expect(button.above, button.name).toBeLessThanOrEqual(1);
+ expect(button.below, button.name).toBeLessThanOrEqual(1);
+ }
+ });
+}
diff --git a/packages/core/src/DateInput/TouchDateField.tsx b/packages/core/src/DateInput/TouchDateField.tsx
index 653efb140d..7e41c91c7d 100644
--- a/packages/core/src/DateInput/TouchDateField.tsx
+++ b/packages/core/src/DateInput/TouchDateField.tsx
@@ -353,7 +353,10 @@ const styles = stylex.create({
* honours.
*/
resetButton: {
- minBlockSize: {default: null, '@media (pointer: coarse)': TOUCH_TARGET},
+ minBlockSize: {
+ default: sizeVars['--size-element-sm'],
+ '@media (pointer: coarse)': TOUCH_TARGET,
+ },
},
/**
* The month and year, and the toggle into the wheels. Leading, so it reads
diff --git a/packages/core/src/DateTimeInput/TouchDateTimeField.tsx b/packages/core/src/DateTimeInput/TouchDateTimeField.tsx
index d63b3d0b49..274b0b7a17 100644
--- a/packages/core/src/DateTimeInput/TouchDateTimeField.tsx
+++ b/packages/core/src/DateTimeInput/TouchDateTimeField.tsx
@@ -351,7 +351,7 @@ const styles = stylex.create({
},
touchResetButton: {
minBlockSize: {
- default: null,
+ default: sizeVars['--size-element-sm'],
'@media (pointer: coarse)': dateInputTouchSizes.daySize,
},
},
diff --git a/packages/core/src/Toast/ToastViewport.test.tsx b/packages/core/src/Toast/ToastViewport.test.tsx
index 4e313c2799..2b60c4eb41 100644
--- a/packages/core/src/Toast/ToastViewport.test.tsx
+++ b/packages/core/src/Toast/ToastViewport.test.tsx
@@ -205,7 +205,7 @@ describe('Toast responsive layout', () => {
expect(getComputedStyle(endArea).height).toBe(
'calc(var(--text-body-size) * var(--text-body-leading))',
);
- expect(getComputedStyle(actionControl).height).toBe(
+ expect(getComputedStyle(actionControl).minHeight).toBe(
'var(--size-element-lg)',
);
expect(getComputedStyle(dismissControl).height).toBe(
diff --git a/packages/themes/butter/src/butterTheme.ts b/packages/themes/butter/src/butterTheme.ts
index d591917473..e022683c77 100644
--- a/packages/themes/butter/src/butterTheme.ts
+++ b/packages/themes/butter/src/butterTheme.ts
@@ -394,8 +394,9 @@ export const butterTheme = defineTheme({
// Radius intentionally not pinned, so buttons keep core's
// `var(--_button-radius, --radius-element)`: standalone buttons stay 8px,
// while the chat composer (which sets --_button-radius) rounds them fully.
+ // Inline padding only: a labelled button's size is its minimum height,
+ // and block padding would add to it.
base: {
- paddingBlock: 'var(--spacing-3)',
paddingInline: 'var(--spacing-4)',
},
'variant:secondary': SECONDARY_BUTTON,