Skip to content

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

TypeScript

fix(breadcrumbs): audit pass, hit target, theme targets, focus ring, RTL separator guidance (#5332)

Cindy Zhang580c1bc440cb
diff --git a/.changeset/breadcrumbs-audit-20260822.md b/.changeset/breadcrumbs-audit-20260822.md
new file mode 100644
index 0000000000..cee183ebb5
--- /dev/null
+++ b/.changeset/breadcrumbs-audit-20260822.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Breadcrumbs: button crumbs keep the link's vertical padding, the variant reaches the item theme targets, and interactive crumbs paint the shared focus ring
+
+@cixzhang
diff --git a/apps/storybook/stories/Breadcrumbs.stories.tsx b/apps/storybook/stories/Breadcrumbs.stories.tsx
index c984b83965..c0f69eaba9 100644
--- a/apps/storybook/stories/Breadcrumbs.stories.tsx
+++ b/apps/storybook/stories/Breadcrumbs.stories.tsx
@@ -7,6 +7,8 @@ import {
BreadcrumbMenuItem,
} from '@astryxdesign/core/Breadcrumbs';
import type {BreadcrumbMenuOption} from '@astryxdesign/core/Breadcrumbs';
+import {Icon} from '@astryxdesign/core/Icon';
+import {rtlStyles} from '@astryxdesign/core/utils';
import {HomeIcon, Cog6ToothIcon, FolderIcon} from '@heroicons/react/24/outline';
const meta: Meta<typeof Breadcrumbs> = {
@@ -65,6 +67,8 @@ export const AutoDetectCurrent: Story = {
export const CustomSeparator: Story = {
render: () => (
+ // No rtlStyles.mirror here: U+203A has Unicode Bidi_Mirrored=Yes, so the
+ // browser flips it under RTL already and an explicit mirror would undo that.
<Breadcrumbs separator={'›'}>
<BreadcrumbItem href="/">Home</BreadcrumbItem>
<BreadcrumbItem href="/docs">Docs</BreadcrumbItem>
@@ -232,3 +236,91 @@ export const MenuCrumbComposed: Story = {
</Breadcrumbs>
),
};
+
+/**
+ * An icon separator is an SVG, so the bidi algorithm never mirrors it the way it
+ * mirrors an angle-quote glyph such as `›`. A directional icon therefore needs
+ * `rtlStyles.mirror` through `xstyle`, or it points against the reading
+ * direction in an RTL locale.
+ */
+export const MirroredIconSeparator: Story = {
+ name: 'Mirrored Icon Separator',
+ render: () => (
+ <Breadcrumbs
+ separator={
+ <Icon
+ icon="chevronRight"
+ size="xsm"
+ color="secondary"
+ xstyle={rtlStyles.mirror}
+ />
+ }>
+ <BreadcrumbItem href="/">Home</BreadcrumbItem>
+ <BreadcrumbItem href="/docs">Docs</BreadcrumbItem>
+ <BreadcrumbItem isCurrent>API Reference</BreadcrumbItem>
+ </Breadcrumbs>
+ ),
+};
+
+/**
+ * The trail wraps rather than collapsing behind an overflow control, so a long
+ * label and a narrow container both reflow instead of clipping. Rendered in a
+ * 320px box, the narrowest width the responsive bar covers.
+ */
+export const LongLabelsNarrow: Story = {
+ name: 'Long Labels in a Narrow Container',
+ render: () => (
+ <div style={{width: 320, outline: '1px dashed #ccc'}}>
+ <Breadcrumbs>
+ <BreadcrumbItem href="/">Home</BreadcrumbItem>
+ <BreadcrumbItem href="/reports">
+ Quarterly Financial Reconciliation
+ </BreadcrumbItem>
+ <BreadcrumbItem isCurrent>
+ Consolidated Statement of Operations 2026 Q3
+ </BreadcrumbItem>
+ </Breadcrumbs>
+ </div>
+ ),
+};
+
+/**
+ * A single crumb renders no separator, and an empty trail collapses to nothing
+ * rather than leaving a blank row.
+ */
+export const SingleItem: Story = {
+ render: () => (
+ <Breadcrumbs>
+ <BreadcrumbItem isCurrent>Only Page</BreadcrumbItem>
+ </Breadcrumbs>
+ ),
+};
+
+const teamMenuWithDisabled: BreadcrumbMenuOption[] = [
+ {label: 'Design', onClick: () => console.log('go /team/design')},
+ {label: 'Engineering', isDisabled: true},
+ {type: 'divider'},
+ {label: 'Data', icon: 'chart', onClick: () => console.log('go /team/data')},
+];
+
+/**
+ * A menu item can be disabled. The disabled row is what the A20 hover sweep and
+ * the A21 cursor sweep measure on this component; without a story rendering one
+ * neither has anything to check here.
+ */
+export const MenuCrumbDisabledItem: Story = {
+ name: 'Menu Crumb (disabled item)',
+ render: () => (
+ <Breadcrumbs>
+ <BreadcrumbItem href="/">Home</BreadcrumbItem>
+ <BreadcrumbItem menu={teamMenuWithDisabled}>Teams</BreadcrumbItem>
+ <BreadcrumbItem isCurrent>Overview</BreadcrumbItem>
+ </Breadcrumbs>
+ ),
+ play: async ({canvasElement}) => {
+ const trigger = canvasElement.querySelector('nav button');
+ if (trigger instanceof HTMLElement) {
+ trigger.click();
+ }
+ },
+};
diff --git a/packages/cli/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsCustomSeparator.tsx b/packages/cli/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsCustomSeparator.tsx
index 766730a84e..0fc55eda8c 100644
--- a/packages/cli/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsCustomSeparator.tsx
+++ b/packages/cli/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsCustomSeparator.tsx
@@ -2,25 +2,38 @@
'use client';
+import * as stylex from '@stylexjs/stylex';
import {Breadcrumbs, BreadcrumbItem} from '@astryxdesign/core/Breadcrumbs';
import {Stack} from '@astryxdesign/core/Layout';
import {Text} from '@astryxdesign/core/Text';
+import {rtlStyles} from '@astryxdesign/core/utils';
+// Only a glyph the bidi algorithm does not already flip needs rtlStyles.mirror.
+// U+203A has Unicode Bidi_Mirrored=Yes, so the browser mirrors it under RTL on
+// its own and a second flip would point it back the wrong way; U+2192 has
+// Bidi_Mirrored=No and stays pointing left-to-right unless we mirror it.
const SEPARATORS = [
- {char: '›', label: 'Chevron'},
- {char: '→', label: 'Arrow'},
- {char: '·', label: 'Dot'},
+ {char: '›', label: 'Chevron', needsRtlMirror: false},
+ {char: '→', label: 'Arrow', needsRtlMirror: true},
+ {char: '·', label: 'Dot', needsRtlMirror: false},
];
export default function BreadcrumbsCustomSeparator() {
return (
<Stack direction="vertical" gap={4}>
- {SEPARATORS.map(({char, label}) => (
+ {SEPARATORS.map(({char, label, needsRtlMirror}) => (
<Stack key={label} direction="vertical" gap={1}>
<Text type="supporting" color="secondary">
{label}
</Text>
- <Breadcrumbs separator={char}>
+ <Breadcrumbs
+ separator={
+ needsRtlMirror ? (
+ <span {...stylex.props(rtlStyles.mirror)}>{char}</span>
+ ) : (
+ char
+ )
+ }>
<BreadcrumbItem href="/">Home</BreadcrumbItem>
<BreadcrumbItem href="/docs">Docs</BreadcrumbItem>
<BreadcrumbItem isCurrent>API Reference</BreadcrumbItem>
diff --git a/packages/core/src/Breadcrumbs/BreadcrumbItem.tsx b/packages/core/src/Breadcrumbs/BreadcrumbItem.tsx
index ac5b8e84d8..2e685a5b1b 100644
--- a/packages/core/src/Breadcrumbs/BreadcrumbItem.tsx
+++ b/packages/core/src/Breadcrumbs/BreadcrumbItem.tsx
@@ -39,12 +39,13 @@ import {
typeScaleVars,
radiusVars,
} from '../theme/tokens.stylex';
-import {BreadcrumbContext} from './Breadcrumbs';
+import {BreadcrumbContext, type BreadcrumbsVariant} from './Breadcrumbs';
import {useLinkComponent} from '../Link/useLinkComponent';
import type {LinkComponentType} from '../Link/types';
import {mergeProps, mergeRefs} from '../utils';
import type {BaseProps} from '../BaseProps';
import {themeProps} from '../utils/themeProps';
+import {focusOutlineProps} from '../utils/focusOutline.stylex';
import {Icon} from '../Icon';
import {usePopover} from '../Popover/usePopover';
import {useListFocus} from '../hooks/useListFocus';
@@ -167,11 +168,14 @@ const itemStyles = stylex.create({
':is(:disabled,[aria-disabled="true"])': 'default',
},
},
- // Reset native button styles so onClick-only items match link appearance
+ // Reset native button styles so onClick-only items match link appearance.
+ // paddingInline rather than padding: a blanket `padding` also overrides the
+ // paddingBlock `link` sets above, which shrank the button crumbs to 20px
+ // against their sibling links' 28px.
buttonReset: {
background: 'none',
border: 'none',
- padding: 0,
+ paddingInline: 0,
margin: 0,
font: 'inherit',
},
@@ -354,7 +358,7 @@ export function BreadcrumbItem({
<li
ref={mergeRefs(ref, liRef)}
{...mergeProps(
- themeProps('breadcrumb-item'),
+ themeProps('breadcrumb-item', {variant: ctx.variant}),
stylex.props(
itemStyles.root,
isSupporting ? itemStyles.supportingSize : itemStyles.defaultSize,
@@ -375,7 +379,7 @@ export function BreadcrumbItem({
ref={contentRef}
menu={menu}
menuSize={resolvedMenuSize}
- isSupporting={isSupporting}
+ variant={ctx.variant}
isCurrent
label={children}>
{content}
@@ -403,7 +407,7 @@ export function BreadcrumbItem({
<li
ref={mergeRefs(ref, liRef)}
{...mergeProps(
- themeProps('breadcrumb-item'),
+ themeProps('breadcrumb-item', {variant: ctx.variant}),
stylex.props(
itemStyles.root,
isSupporting ? itemStyles.supportingSize : itemStyles.defaultSize,
@@ -422,7 +426,7 @@ export function BreadcrumbItem({
ref={contentRef}
menu={menu}
menuSize={resolvedMenuSize}
- isSupporting={isSupporting}
+ variant={ctx.variant}
label={children}>
{content}
</BreadcrumbMenuTrigger>
@@ -431,7 +435,7 @@ export function BreadcrumbItem({
ref={contentRef}
href={href}
onClick={onClick}
- {...stylex.props(
+ {...focusOutlineProps.focusVisible(
itemStyles.link,
isSupporting ? itemStyles.supportingLink : itemStyles.defaultLink,
)}>
@@ -442,7 +446,7 @@ export function BreadcrumbItem({
ref={contentRef as React.RefObject<HTMLButtonElement | null>}
type="button"
onClick={onClick}
- {...stylex.props(
+ {...focusOutlineProps.focusVisible(
itemStyles.link,
itemStyles.buttonReset,
isSupporting ? itemStyles.supportingLink : itemStyles.defaultLink,
@@ -480,7 +484,7 @@ interface BreadcrumbMenuTriggerProps {
label: ReactNode;
menu: DropdownMenuOption[] | ReactNode;
menuSize: DropdownMenuSize;
- isSupporting: boolean;
+ variant: BreadcrumbsVariant;
isCurrent?: boolean;
}
@@ -497,11 +501,12 @@ function BreadcrumbMenuTrigger({
label,
menu,
menuSize,
- isSupporting,
+ variant,
isCurrent = false,
}: BreadcrumbMenuTriggerProps) {
const menuId = useId();
const buttonRef = useRef<HTMLButtonElement>(null);
+ const isSupporting = variant === 'supporting';
const popover = usePopover({
onHide: useCallback(() => {
@@ -618,16 +623,21 @@ function BreadcrumbMenuTrigger({
type="button"
onClick={handleClick}
onKeyDown={handleKeyDown}
- {...mergeProps(themeProps('breadcrumb-item-menu-trigger'), {
- ...popover.triggerProps,
- 'aria-haspopup': 'menu' as const,
- 'aria-controls': menuId,
- 'aria-current': isCurrent ? ('page' as const) : undefined,
- })}
- {...stylex.props(
- itemStyles.link,
- itemStyles.buttonReset,
- isSupporting ? itemStyles.supportingLink : itemStyles.defaultLink,
+ {...popover.triggerProps}
+ aria-haspopup="menu"
+ aria-controls={menuId}
+ aria-current={isCurrent ? 'page' : undefined}
+ {...mergeProps(
+ themeProps('breadcrumb-item-menu-trigger', {variant}),
+ // Through mergeProps, not a second spread: a sibling stylex.props()
+ // spread replaces the className themeProps() built, which is how the
+ // documented breadcrumb-item-menu-trigger target came to render on
+ // nothing.
+ focusOutlineProps.focusVisible(
+ itemStyles.link,
+ itemStyles.buttonReset,
+ isSupporting ? itemStyles.supportingLink : itemStyles.defaultLink,
+ ),
)}>
{children}
<Icon
diff --git a/packages/core/src/Breadcrumbs/Breadcrumbs.doc.mjs b/packages/core/src/Breadcrumbs/Breadcrumbs.doc.mjs
index fe9778cd90..ab6d1bf345 100644
--- a/packages/core/src/Breadcrumbs/Breadcrumbs.doc.mjs
+++ b/packages/core/src/Breadcrumbs/Breadcrumbs.doc.mjs
@@ -16,9 +16,12 @@ export const docs = {
{guidance: true, description: 'Keep labels short and match the page titles they link to: "Settings" not "Application Settings Page".'},
{guidance: true, description: 'Use the supporting variant in dense UIs like admin panels or sidebars where the breadcrumb should be subtle.'},
{guidance: true, description: 'Make the last item plain text, not a link; it represents the current page. The component does this automatically when you set isCurrent.'},
+ {guidance: true, description: 'The component implements the WAI-ARIA APG Breadcrumb pattern: a labelled nav landmark wrapping an ordered list, with aria-current="page" on the current item. A crumb with a menu additionally implements the APG Menu Button pattern, opening on Enter, Space or ArrowDown and closing on Escape.'},
+ {guidance: true, description: 'Give each trail its own label when a page renders more than one, so the nav landmarks stay distinguishable in a screen reader landmark list.'},
{guidance: false, description: 'Use breadcrumbs as the primary navigation. They supplement a sidebar or top nav, not replace it.'},
{guidance: false, description: 'Show breadcrumbs on top-level pages that have no parent; they add clutter without helping the user.'},
{guidance: false, description: 'Let the trail grow beyond 5 levels. If you need more, consider simplifying the page hierarchy instead.'},
+ {guidance: false, description: 'Mirror a separator the bidi algorithm already mirrors. An angle-quote glyph such as › is Bidi_Mirrored, so it flips under RTL on its own and rtlStyles.mirror would flip it back. An arrow glyph such as → and any Icon separator are not, so those do need rtlStyles.mirror through xstyle.'},
],
anatomy: [
{name: 'Trail', required: true, description: 'The ordered list of links from root to current page.'},
@@ -29,8 +32,11 @@ export const docs = {
},
theming: {
targets: [
- {className: 'astryx-breadcrumb-item'},
- {className: 'astryx-breadcrumb-item-menu-trigger'},
+ {className: 'astryx-breadcrumb-item', visualProps: ['variant']},
+ {
+ className: 'astryx-breadcrumb-item-menu-trigger',
+ visualProps: ['variant'],
+ },
{className: 'astryx-breadcrumb-menu'},
{className: 'astryx-breadcrumbs', visualProps: ['variant']},
],
@@ -123,6 +129,18 @@ export const docs = {
type: 'LinkComponentType',
description: 'Custom link component to render instead of <a>. Overrides the provider-level default from LinkProvider. Only applies to non-current items.',
},
+ {
+ name: 'menu',
+ type: 'DropdownMenuOption[] | ReactNode',
+ description:
+ 'Menu opened when the item is activated, using the same item API as DropdownMenu/MoreMenu/ContextMenu (a DropdownMenuOption[] array or composed DropdownMenuItem children). Renders a link-styled menu trigger with a chevron and aria-haspopup="menu". Takes precedence over href/onClick.',
+ },
+ {
+ name: 'menuSize',
+ type: "'sm' | 'md' | 'lg'",
+ description:
+ "Size passed to the menu items. Defaults from the breadcrumb variant ('supporting' → 'sm', otherwise 'md').",
+ },
],
},
],
@@ -138,9 +156,12 @@ export const docsZh = {
{guidance: true, description: 'Keep labels short and match the page titles they link to: "Settings" not "Application Settings Page".'},
{guidance: true, description: 'Use the supporting variant in dense UIs like admin panels or sidebars where the breadcrumb should be subtle.'},
{guidance: true, description: 'Make the last item plain text, not a link; it represents the current page. The component does this automatically when you set isCurrent.'},
+ {guidance: true, description: 'The component implements the WAI-ARIA APG Breadcrumb pattern: a labelled nav landmark wrapping an ordered list, with aria-current="page" on the current item. A crumb with a menu additionally implements the APG Menu Button pattern, opening on Enter, Space or ArrowDown and closing on Escape.'},
+ {guidance: true, description: 'Give each trail its own label when a page renders more than one, so the nav landmarks stay distinguishable in a screen reader landmark list.'},
{guidance: false, description: 'Use breadcrumbs as the primary navigation. They supplement a sidebar or top nav, not replace it.'},
{guidance: false, description: 'Show breadcrumbs on top-level pages that have no parent; they add clutter without helping the user.'},
{guidance: false, description: 'Let the trail grow beyond 5 levels. If you need more, consider simplifying the page hierarchy instead.'},
+ {guidance: false, description: 'Mirror a separator the bidi algorithm already mirrors. An angle-quote glyph such as › is Bidi_Mirrored, so it flips under RTL on its own and rtlStyles.mirror would flip it back. An arrow glyph such as → and any Icon separator are not, so those do need rtlStyles.mirror through xstyle.'},
],
},
};
@@ -156,9 +177,12 @@ export const docsDense = {
{guidance: true, description: 'Keep labels short + matching page titles they link to: "Settings" not "Application Settings Page".'},
{guidance: true, description: 'Use supporting variant in dense UIs where the breadcrumb should be subtle.'},
{guidance: true, description: 'Last item plain text, not a link; represents current page; done automatically when you set isCurrent.'},
+ {guidance: true, description: 'Implements APG Breadcrumb: labelled nav landmark + ol + aria-current="page". A menu crumb also implements APG Menu Button (Enter/Space/ArrowDown to open, Escape to close).'},
+ {guidance: true, description: 'Give each trail its own label when a page renders more than one.'},
{guidance: false, description: 'Use as primary navigation; breadcrumbs supplement, not replace, a main nav.'},
{guidance: false, description: 'Show on top-level pages with no parent.'},
{guidance: false, description: 'Let the trail exceed 5 levels; simplify the hierarchy instead.'},
+ {guidance: false, description: 'Mirror a separator that already mirrors itself: › is Bidi_Mirrored and flips under RTL on its own. → and Icon separators are not, so those need rtlStyles.mirror via xstyle.'},
],
},
};
diff --git a/packages/core/src/Breadcrumbs/Breadcrumbs.test.tsx b/packages/core/src/Breadcrumbs/Breadcrumbs.test.tsx
index ddc2d23ed2..5d219cdbd9 100644
--- a/packages/core/src/Breadcrumbs/Breadcrumbs.test.tsx
+++ b/packages/core/src/Breadcrumbs/Breadcrumbs.test.tsx
@@ -676,6 +676,37 @@ describe('BreadcrumbItem menu', () => {
warn.mockRestore();
});
+ it('reflects the variant on the item and menu-trigger theme targets', () => {
+ const {container} = render(
+ <Breadcrumbs variant="supporting">
+ <BreadcrumbItem href="/">Home</BreadcrumbItem>
+ <BreadcrumbItem menu={items}>Teams</BreadcrumbItem>
+ <BreadcrumbItem isCurrent>Overview</BreadcrumbItem>
+ </Breadcrumbs>,
+ );
+ // The variant selects between style objects on both elements, so a theme
+ // needs it as a data attribute on both targets to reach them.
+ for (const item of container.querySelectorAll('.astryx-breadcrumb-item')) {
+ expect(item).toHaveAttribute('data-variant', 'supporting');
+ }
+ expect(
+ container.querySelector('.astryx-breadcrumb-item-menu-trigger'),
+ ).toHaveAttribute('data-variant', 'supporting');
+ });
+
+ it('defaults the item theme target to the default variant', () => {
+ const {container} = render(
+ <Breadcrumbs>
+ <BreadcrumbItem href="/">Home</BreadcrumbItem>
+ <BreadcrumbItem isCurrent>Overview</BreadcrumbItem>
+ </Breadcrumbs>,
+ );
+ expect(container.querySelector('.astryx-breadcrumb-item')).toHaveAttribute(
+ 'data-variant',
+ 'default',
+ );
+ });
+
it('keeps mid-trail separators intact around a menu crumb', () => {
const {container} = render(
<Breadcrumbs>