An open source design system that's fully customizable and agent ready
TypeScript
fix(core): drop styling wrappers around icons; render glyphs through Icon (#4838)
Cindy Zhang4b1fef5f7005
diff --git a/.changeset/icon-rotation-theme-targets.md b/.changeset/icon-rotation-theme-targets.mdnew file mode 100644index 0000000000..203c78cac7--- /dev/null+++ b/.changeset/icon-rotation-theme-targets.md@@ -0,0 +1,13 @@+---+'@astryxdesign/core': patch+---++[fix] Remove styling-only wrappers around rotating icons, and put each rotation on the icon element that already carries the component's theme target — so a theme reaches the glyph and its open/closed transform through one selector.++No new theme targets: Selector, MultiSelector and ComplexSelector consolidate onto their existing `*-indicator-icon` targets, and the Table plugins and TreeList simply shed redundant wrapper elements.++Where an RTL mirror sat on a separate parent element, it is folded into each state's transform (`scaleX(-1) rotate(...)`) so one element carries both. In the Table plugins that mirror was inert — `transform` does not apply to a non-replaced inline box — so RTL disclosure chevrons now mirror correctly where they silently did not before.++Also adds the `@astryx/no-wrapper-transform` lint rule (warn) for `<div>`/`<span>` wrappers that exist to transform the icon inside them.++@cixzhangdiff --git a/.changeset/use-icon-to-icon.md b/.changeset/use-icon-to-icon.mdnew file mode 100644index 0000000000..ebf3586400--- /dev/null+++ b/.changeset/use-icon-to-icon.md@@ -0,0 +1,11 @@+---+'@astryxdesign/core': patch+---++[fix] Render registry glyphs through `<Icon>` instead of `useIcon()` inside a hand-written `<span>`, in SideNav, TopNav, Collapsible, TreeList and Breadcrumbs.++Those spans were a weaker reimplementation of `<Icon>`, which already resolves the same glyph and renders a span carrying merged `className`/`style`/`xstyle` plus the `astryx-icon` theme target. The converted sites gain that target — no new targets are introduced — and the node count is unchanged.++`useIcon()` keeps its place for the cases that resolve a glyph *without* rendering it: MoreMenu and ChatSendButton pass the node as a default for a consumer-overridable prop, which `<Icon>` cannot express.++@cixzhangdiff --git a/apps/storybook/rtl-audit/rtl-audit.mjs b/apps/storybook/rtl-audit/rtl-audit.mjsindex ca82c18624..dbd6d60179 100644--- a/apps/storybook/rtl-audit/rtl-audit.mjs+++ b/apps/storybook/rtl-audit/rtl-audit.mjs@@ -191,6 +191,17 @@ function isFlipMatrix(transform) {const [a, b, c, d] = m[1].split(',').map(v => parseFloat(v.trim()));return Math.abs(a + 1) < 0.01 && Math.abs(b) < 0.01 && Math.abs(c) < 0.01 && Math.abs(d - 1) < 0.01;}+// Is `rtl` the mirror of `ltr`? i.e. rtl == scaleX(-1) . ltr, comparing the+// linear part only (translation does not affect mirroring). Pre-multiplying by+// scaleX(-1) negates the top row of the 2x2, so [a,b,c,d] -> [-a, b, -c, d]+// in CSS's column-major matrix(a,b,c,d) ordering.+function isMirrorOf(rtl, ltr) {+ if (!Array.isArray(rtl)) return false;+ const base = Array.isArray(ltr) ? ltr : [1, 0, 0, 1];+ const expected = [-base[0], base[1], -base[2], base[3]];+ return expected.every((v, i) => Math.abs(v - rtl[i]) < 0.01);+}+function isIdentityTransform(transform) {if (!transform || transform === 'none') return true;const m = transform.match(/matrix\(([^)]+)\)/);@@ -248,9 +259,25 @@ const DETECTOR = /* js */ `if (/\\b(next|forward|scroll right|go right)\\b/.test(l)) return 'ctx';return null;}- // Walk up from the icon to find the element whose computed transform is the- // mirror (scaleX). Returns {transform, matchedMirror}.- function mirrorTransformFor(iconEl) {+ // Compose the transforms from the icon up through its ancestors into one 2x2+ // matrix (the linear part; translation is irrelevant to mirroring).+ //+ // We deliberately do NOT hunt for a single element whose transform is a pure+ // flip. A mirror may be folded into the same declaration as a state rotation+ // (transform: scaleX(-1) rotate(90deg)) because both are the one transform+ // property, so on one element the later value would otherwise win. That+ // composition renders identically to the older nested-element form, but no+ // individual element then reads as a flip. Comparing the COMPOSED matrix+ // against its LTR counterpart tests the contract (is the glyph mirrored?)+ // instead of the DOM shape that happens to implement it.+ function composedMatrixFor(iconEl) {+ let acc = [1, 0, 0, 1];+ const mul = (m, n) => [+ m[0] * n[0] + m[2] * n[1],+ m[1] * n[0] + m[3] * n[1],+ m[0] * n[2] + m[2] * n[3],+ m[1] * n[2] + m[3] * n[3],+ ];let el = iconEl;let steps = 0;while (el && steps < 6) {@@ -259,16 +286,14 @@ const DETECTOR = /* js */ `const m = tf.match(/matrix\\(([^)]+)\\)/);if (m) {const p = m[1].split(',').map(v => parseFloat(v.trim()));- // horizontal flip present anywhere in the chain- if (Math.abs(p[0] + 1) < 0.01 && Math.abs(p[1]) < 0.01 && Math.abs(p[2]) < 0.01 && Math.abs(p[3] - 1) < 0.01) {- return {transform: tf, flip: true};- }+ // Ancestor transforms apply outermost-last: parent then child.+ acc = mul([p[0], p[1], p[2], p[3]], acc);}}el = el.parentElement;steps++;}- return {transform: 'none', flip: false};+ return acc;}const svgs = Array.from(document.querySelectorAll('svg'));const found = [];@@ -307,8 +332,11 @@ const DETECTOR = /* js */ `seenPaths.add(key);const btn = svg.closest('button,[role=button],a');const aria = btn ? (btn.getAttribute('aria-label') || '') : '';- const {transform, flip} = mirrorTransformFor(svg);- found.push({dir, aria: aria.slice(0, 40), pathSig: dcat.slice(0, 40), transform, flip});+ const matrix = composedMatrixFor(svg);+ const flip =+ Math.abs(matrix[0] + 1) < 0.01 && Math.abs(matrix[1]) < 0.01 &&+ Math.abs(matrix[2]) < 0.01 && Math.abs(matrix[3] - 1) < 0.01;+ found.push({dir, aria: aria.slice(0, 40), pathSig: dcat.slice(0, 40), matrix, flip});}return found;})()@@ -527,16 +555,28 @@ async function autoD1(page, port, storyId, component) {const perIcon = [];for (const k of keys) {const L = ltrBy.get(k), R = rtlBy.get(k);- // transform-mirror: RTL flips while LTR is identity- const mirrored = R && R.flip && (!L || !L.flip);+ // transform-mirror: the glyph's COMPOSED transform under RTL equals its LTR+ // transform pre-multiplied by scaleX(-1). This is the general form of "the+ // glyph is mirrored", and it holds whether the mirror lives on its own+ // element or is folded into the same declaration as a state rotation:+ // collapsed: scaleX(-1) . identity = matrix(-1, 0, 0, 1)+ // expanded: scaleX(-1) . rotate(90deg) = matrix( 0, 1, 1, 0)+ // The older check demanded a pure flip matrix, which the second case never+ // produces even though it renders correctly.+ const mirrored = R && isMirrorOf(R.matrix, L?.matrix);// name-swap: the rendered glyph direction changed left<->right for this iconconst swapped = L && R && L.dir !== R.dir && L.dir !== null && R.dir !== null;// double-flip: flip present in BOTH dirs -> nets to no visible mirror- const doubleFlip = L && R && L.flip && R.flip;+ // A glyph flipped in BOTH directions nets to no visible mirror. Only a+ // concern when the two are actually equal — a composed mirror has a+ // different RTL matrix and is caught by `mirrored` above.+ const doubleFlip =+ L && R && L.flip && R.flip &&+ L.matrix.every((v, i) => Math.abs(v - R.matrix[i]) < 0.01);if (mirrored || swapped) anyMirrored = true;else if (doubleFlip) { anyDoubleFlip = true; anyUnhandled = true; }else anyUnhandled = true;- perIcon.push({icon: k, ltrDir: L?.dir, rtlDir: R?.dir, ltrFlip: !!L?.flip, rtlFlip: !!R?.flip, mirrored: !!mirrored, swapped: !!swapped});+ perIcon.push({icon: k, ltrDir: L?.dir, rtlDir: R?.dir, ltrMatrix: L?.matrix, rtlMatrix: R?.matrix, mirrored: !!mirrored, swapped: !!swapped});}// A component is RTL-ready for D1 iff EVERY directional icon is handleddiff --git a/internal/eslint-plugin-astryx/index.js b/internal/eslint-plugin-astryx/index.jsindex 689d9a9c6b..fb1ed98c9c 100644--- a/internal/eslint-plugin-astryx/index.js+++ b/internal/eslint-plugin-astryx/index.js@@ -21,6 +21,7 @@ import presentationalComponentRule from './presentational-component.js';import docblockExampleFormatRule from './docblock-example-format.js';import noStylexNullOverrideRule from './no-stylex-null-override.js';import noStyleOnlyWrapperRule from './no-style-only-wrapper.js';+import noWrapperTransformRule from './no-wrapper-transform.js';import noReactIntrospectionRule from './no-react-introspection.js';import noClassnameClobberRule from './no-classname-clobber.js';import noHardcodedAnchorRule from './no-hardcoded-anchor.js';@@ -239,6 +240,7 @@ const plugin = {'docblock-example-format': docblockExampleFormatRule,'no-stylex-null-override': noStylexNullOverrideRule,'no-style-only-wrapper': noStyleOnlyWrapperRule,+ 'no-wrapper-transform': noWrapperTransformRule,'no-react-introspection': noReactIntrospectionRule,'no-classname-clobber': noClassnameClobberRule,'no-hardcoded-anchor': noHardcodedAnchorRule,@@ -273,6 +275,7 @@ plugin.configs.strict = {// flip to 'error' here to prevent regressions — the same path// no-physical-properties took.'@astryx/no-style-only-wrapper': 'warn',+ '@astryx/no-wrapper-transform': 'error','@astryx/no-react-introspection': 'error','@astryx/no-classname-clobber': 'error','@astryx/no-hardcoded-anchor': 'error',@@ -301,6 +304,7 @@ plugin.configs.recommended = {'@astryx/docblock-example-format': 'warn','@astryx/no-stylex-null-override': 'warn','@astryx/no-style-only-wrapper': 'warn',+ '@astryx/no-wrapper-transform': 'error','@astryx/no-react-introspection': 'error','@astryx/no-classname-clobber': 'error','@astryx/no-hardcoded-anchor': 'warn',diff --git a/internal/eslint-plugin-astryx/no-wrapper-transform.js b/internal/eslint-plugin-astryx/no-wrapper-transform.jsnew file mode 100644index 0000000000..ef13953ef4--- /dev/null+++ b/internal/eslint-plugin-astryx/no-wrapper-transform.js@@ -0,0 +1,359 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file no-wrapper-transform.js+ * @description Disallow a `<div>`/`<span>` that exists to apply a `transform`+ * to the icon or component inside it — put the transform on that element.+ *+ * A state-driven transform (the chevron that rotates when a section opens, a+ * caret that flips when a menu expands) is part of how the glyph looks in that+ * state. When it lives on a parent wrapper instead, the element a theme can+ * target and the element that actually moves are two different nodes, so a+ * theme can restyle the glyph but not its rotation — the one property most+ * themes want to change about a disclosure affordance.+ *+ * Bad — the target and the movement are on different elements:+ * <span {...stylex.props(styles.chevron, isOpen && styles.chevronOpen)}>+ * <Icon icon="chevronDown" {...themeProps('thing-icon', {state})} />+ * </span>+ *+ * Good — one element carries both:+ * <Icon+ * icon="chevronDown"+ * xstyle={[styles.chevron, isOpen && styles.chevronOpen]}+ * {...themeProps('thing-icon', {state})}+ * />+ *+ * This is deliberately narrower than {@link no-style-only-wrapper}, which+ * fires only when a wrapper can be deleted outright. A transform wrapper often+ * also does real layout (`display: flex`, centering, a fixed box), which+ * exempts it there — but the transform still belongs on the child even when+ * the wrapper itself has to stay. The remedy differs too: move one property,+ * rather than remove an element.+ *+ * Two transforms on one element: `transform` is a single property, so folding+ * an RTL mirror and a state rotation onto the same node means the later value+ * wins. Spell both out per state instead — the pattern used across core:+ *+ * chevronExpanded: {+ * transform: {+ * default: 'rotate(90deg)',+ * ':is([dir="rtl"] *)': 'scaleX(-1) rotate(90deg)',+ * },+ * },+ *+ * Scope — the rule only fires where moving the transform is behavior-preserving+ * and the payoff (a themeable, targetable element) is real:+ * - the wrapper is a host `div`/`span` carrying a `stylex.props()` spread+ * whose styles include a transform property;+ * - it has exactly one meaningful child, and that child is either an Astryx+ * icon component (a name ending in `Icon`, which takes `xstyle`) or an+ * identifier holding a `useIcon()` result (the registry glyph pattern,+ * where the wrapper IS the icon element and should carry the transform and+ * the theme target). A transform around a non-glyph component is usually+ * positioning the wrapper's own box — Carousel floats a button pill with+ * `translateX(-50%)` — and moving that onto the child would be wrong;+ * - the style resolves to a local `stylex.create()` entry. An unresolvable+ * style is left alone rather than guessed at.+ *+ * Transforms that are not state-driven glyph movement — a `Spinner` keyframe,+ * a popover's positioning translate — do not match the shape above: they either+ * live in keyframes or sit on an element wrapping arbitrary content.+ */++/** Properties whose value moves the element rather than painting it. */+const TRANSFORM_PROPERTIES = new Set([+ 'transform',+ 'rotate',+ 'scale',+ 'translate',+]);++/** Host elements treated as candidate wrappers. */+const DEFAULT_WRAPPER_ELEMENTS = ['div', 'span'];++/** Import sources whose components accept `xstyle`. */+const DEFAULT_COMPONENT_SOURCES = ['^@astryxdesign/', '^@xds/', '^\\.\\.?/'];++function isStylexPropsCall(node) {+ return (+ node?.type === 'CallExpression' &&+ node.callee?.type === 'MemberExpression' &&+ node.callee.object?.name === 'stylex' &&+ node.callee.property?.name === 'props'+ );+}++function isStylexCreateCall(node) {+ return (+ node?.type === 'CallExpression' &&+ node.callee?.type === 'MemberExpression' &&+ node.callee.object?.name === 'stylex' &&+ node.callee.property?.name === 'create'+ );+}++function isUseIconCall(node) {+ return node?.type === 'CallExpression' && node.callee?.name === 'useIcon';+}++/** Root identifier of a JSX name: `Icon` → Icon, `Card.Body` → Card. */+function jsxNameRoot(nameNode) {+ let current = nameNode;+ while (current?.type === 'JSXMemberExpression') {+ current = current.object;+ }+ return current?.type === 'JSXIdentifier' ? current.name : null;+}++/** Children that render nothing: whitespace-only text and comment expressions. */+function isIgnorableChild(child) {+ if (child.type === 'JSXText') {+ return child.value.trim() === '';+ }+ if (child.type === 'JSXExpressionContainer') {+ return child.expression?.type === 'JSXEmptyExpression';+ }+ return false;+}++const rule = {+ meta: {+ type: 'suggestion',+ docs: {+ description:+ 'Disallow div/span wrappers that apply a transform to the icon inside them — put the transform on the icon so it is the element themes target',+ category: 'Best Practices',+ recommended: true,+ },+ messages: {+ wrapperTransform:+ 'This <{{wrapper}}> applies a transform to the {{childLabel}} inside it. ' ++ 'Put the transform on that element instead, so the element a theme can ' ++ 'target is the element that moves. Keep any layout styles here; move ' ++ 'only the transform and its transition.',+ },+ schema: [+ {+ type: 'object',+ properties: {+ wrapperElements: {type: 'array', items: {type: 'string'}},+ componentSources: {type: 'array', items: {type: 'string'}},+ allowFiles: {type: 'array', items: {type: 'string'}},+ },+ additionalProperties: false,+ },+ ],+ },++ create(context) {+ const options = context.options[0] ?? {};+ const filename = context.filename ?? context.getFilename();+ const allowFiles = options.allowFiles ?? [];+ if (allowFiles.some(pattern => filename.includes(pattern))) {+ return {};+ }++ const wrapperElements = new Set(+ options.wrapperElements ?? DEFAULT_WRAPPER_ELEMENTS,+ );+ const componentSources = (+ options.componentSources ?? DEFAULT_COMPONENT_SOURCES+ ).map(pattern => new RegExp(pattern));++ /** Local names imported from a source whose components take `xstyle`. */+ const astryxImports = new Set();+ /** `stylex.create` binding → style key → property names. */+ const stylexCreateProperties = new Map();+ /** Identifiers assigned from `useIcon(...)`. */+ const useIconBindings = new Set();+ /** Checked after the whole file is walked, so imports/styles are known. */+ const candidates = [];++ function styleKeyProperties(binding, key) {+ if (key == null) {+ return null;+ }+ return stylexCreateProperties.get(binding)?.get(key) ?? null;+ }++ /**+ * Property names a style expression applies, or null when it cannot be+ * resolved to a local `stylex.create()` entry.+ */+ function resolveStyleProperties(expression) {+ if (+ expression.type === 'MemberExpression' &&+ !expression.computed &&+ expression.object?.type === 'Identifier'+ ) {+ return styleKeyProperties(+ expression.object.name,+ expression.property.name ?? expression.property.value,+ );+ }+ if (+ expression.type === 'CallExpression' &&+ expression.callee?.type === 'MemberExpression' &&+ !expression.callee.computed &&+ expression.callee.object?.type === 'Identifier'+ ) {+ return styleKeyProperties(+ expression.callee.object.name,+ expression.callee.property.name ?? expression.callee.property.value,+ );+ }+ if (expression.type === 'LogicalExpression') {+ return resolveStyleProperties(expression.right);+ }+ if (expression.type === 'ConditionalExpression') {+ const consequent = resolveStyleProperties(expression.consequent) ?? [];+ const alternate = resolveStyleProperties(expression.alternate) ?? [];+ return [...consequent, ...alternate];+ }+ if (expression.type === 'ArrayExpression') {+ const all = [];+ for (const element of expression.elements ?? []) {+ if (element == null) continue;+ all.push(...(resolveStyleProperties(element) ?? []));+ }+ return all;+ }+ return null;+ }++ function appliesTransform(styleExpressions) {+ return styleExpressions.some(expression => {+ const properties = resolveStyleProperties(expression);+ if (properties == null) {+ return false;+ }+ return properties.some(name => TRANSFORM_PROPERTIES.has(name));+ });+ }++ /**+ * The single meaningful child, described for the report — or null when the+ * wrapper holds anything other than one icon-ish element.+ */+ function soleIconChild(element) {+ const meaningful = element.children.filter(+ child => !isIgnorableChild(child),+ );+ if (meaningful.length !== 1) {+ return null;+ }+ const [child] = meaningful;++ if (child.type === 'JSXElement') {+ const root = jsxNameRoot(child.openingElement.name);+ // Icons only. A transform around a non-glyph component is usually+ // positioning the wrapper itself (Carousel floats a button pill with+ // `translateX(-50%)`), where the transform belongs to the wrapper's own+ // box and moving it onto the child would be wrong.+ if (root != null && astryxImports.has(root) && /Icon$/.test(root)) {+ return `<${root}>`;+ }+ return null;+ }++ // `{chevronIcon}` where chevronIcon came from useIcon()+ if (+ child.type === 'JSXExpressionContainer' &&+ child.expression?.type === 'Identifier' &&+ useIconBindings.has(child.expression.name)+ ) {+ return `icon (${child.expression.name})`;+ }++ return null;+ }++ return {+ ImportDeclaration(node) {+ const source = node.source.value;+ if (typeof source !== 'string') return;+ if (!componentSources.some(pattern => pattern.test(source))) return;+ for (const specifier of node.specifiers) {+ if (specifier.local?.name) {+ astryxImports.add(specifier.local.name);+ }+ }+ },++ VariableDeclarator(node) {+ if (node.id?.type !== 'Identifier') return;++ if (isUseIconCall(node.init)) {+ useIconBindings.add(node.id.name);+ return;+ }++ if (!isStylexCreateCall(node.init)) return;+ const [argument] = node.init.arguments;+ if (argument?.type !== 'ObjectExpression') return;++ const keys = new Map();+ for (const property of argument.properties) {+ if (property.type !== 'Property') continue;+ const key = property.key?.name ?? property.key?.value;+ if (key == null) continue;++ // `key: {…}` or `key: (arg) => ({…})` for dynamic styles+ let body = property.value;+ if (+ body?.type === 'ArrowFunctionExpression' &&+ body.body?.type === 'ObjectExpression'+ ) {+ body = body.body;+ }+ if (body?.type !== 'ObjectExpression') continue;++ keys.set(+ key,+ body.properties+ .filter(entry => entry.type === 'Property')+ .map(entry => entry.key?.name ?? entry.key?.value)+ .filter(name => name != null),+ );+ }+ stylexCreateProperties.set(node.id.name, keys);+ },++ JSXElement(node) {+ const name = node.openingElement.name;+ if (name.type !== 'JSXIdentifier') return;+ if (!wrapperElements.has(name.name)) return;++ const styleExpressions = [];+ for (const attribute of node.openingElement.attributes) {+ if (+ attribute.type === 'JSXSpreadAttribute' &&+ isStylexPropsCall(attribute.argument)+ ) {+ styleExpressions.push(...attribute.argument.arguments);+ }+ }+ if (styleExpressions.length === 0) return;++ candidates.push({node, wrapper: name.name, styleExpressions});+ },++ 'Program:exit'() {+ for (const {node, wrapper, styleExpressions} of candidates) {+ if (!appliesTransform(styleExpressions)) continue;+ const childLabel = soleIconChild(node);+ if (childLabel == null) continue;++ context.report({+ node: node.openingElement,+ messageId: 'wrapperTransform',+ data: {wrapper, childLabel},+ });+ }+ },+ };+ },+};++export default rule;diff --git a/internal/eslint-plugin-astryx/no-wrapper-transform.test.mjs b/internal/eslint-plugin-astryx/no-wrapper-transform.test.mjsnew file mode 100644index 0000000000..4438c98d76--- /dev/null+++ b/internal/eslint-plugin-astryx/no-wrapper-transform.test.mjs@@ -0,0 +1,136 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file no-wrapper-transform.test.mjs+ * @description Tests for the no-wrapper-transform ESLint rule.+ */++import {RuleTester} from 'eslint';+import tseslint from 'typescript-eslint';+import noWrapperTransformRule from './no-wrapper-transform.js';++const ruleTester = new RuleTester({+ languageOptions: {+ parser: tseslint.parser,+ parserOptions: {+ ecmaFeatures: {jsx: true},+ sourceType: 'module',+ },+ },+});++/** An Astryx import plus a local style table covering each shape under test. */+const setup = `+import * as stylex from '@stylexjs/stylex';+import {Icon} from '../Icon';+const styles = stylex.create({+ chevron: {display: 'flex', alignItems: 'center'},+ chevronOpen: {transform: 'rotate(180deg)'},+ chevronRtl: {transform: {default: 'rotate(90deg)', ':is([dir="rtl"] *)': 'scaleX(-1) rotate(90deg)'}},+ rotateProp: {rotate: '45deg'},+ box: {width: 16, height: 16},+ sized: (n) => ({transform: 'rotate(' + n + 'deg)'}),+});+`;++const error = [{messageId: 'wrapperTransform'}];++ruleTester.run('no-wrapper-transform', noWrapperTransformRule, {+ valid: [+ // The transform is already on the component — the shape we want.+ {+ code: `${setup} const A = () => <Icon icon="chevronDown" xstyle={[styles.chevron, styles.chevronOpen]} />;`,+ },+ // Wrapper styles it, but with no transform: no-style-only-wrapper's job.+ {+ code: `${setup} const A = () => <span {...stylex.props(styles.box)}><Icon icon="x" /></span>;`,+ },+ // A transform around arbitrary content is not the glyph pattern.+ {+ code: `${setup} const A = () => <span {...stylex.props(styles.chevronOpen)}>text</span>;`,+ },+ // More than one child: the wrapper is positioning a group, not a glyph.+ {+ code: `${setup} const A = () => <span {...stylex.props(styles.chevronOpen)}><Icon icon="a" /><Icon icon="b" /></span>;`,+ },+ // Not an Astryx component — the rule cannot assume it takes xstyle.+ {+ code: `${setup} const A = () => <span {...stylex.props(styles.chevronOpen)}><svg /></span>;`,+ },+ // An Astryx component that is not a glyph: the transform is positioning+ // the wrapper's own box (Carousel's floating button pill), so it stays.+ {+ code: `import * as stylex from '@stylexjs/stylex';+import {Button} from '../Button';+const styles = stylex.create({pill: {position: 'absolute', transform: 'translateX(-50%)'}});+const A = () => <div {...stylex.props(styles.pill)}><Button label="x" /></div>;`,+ },+ // Unresolvable style: left alone rather than guessed at.+ {+ code: `import * as stylex from '@stylexjs/stylex';+import {Icon} from '../Icon';+import {shared} from './shared.stylex';+const A = () => <span {...stylex.props(shared.mirror)}><Icon icon="x" /></span>;`,+ },+ // A bare identifier child that is not a useIcon() result.+ {+ code: `${setup} const A = ({node}) => <span {...stylex.props(styles.chevronOpen)}>{node}</span>;`,+ },+ // Exempt file.+ {+ code: `${setup} const A = () => <span {...stylex.props(styles.chevronOpen)}><Icon icon="x" /></span>;`,+ filename: '/repo/packages/core/src/Legacy/Legacy.tsx',+ options: [{allowFiles: ['/Legacy/']}],+ },+ ],++ invalid: [+ // The core case: rotation on the wrapper, glyph inside.+ {+ code: `${setup} const A = () => <span {...stylex.props(styles.chevronOpen)}><Icon icon="chevronDown" /></span>;`,+ errors: error,+ },+ // Conditional rotation — the branch carrying the transform is enough.+ {+ code: `${setup} const A = ({isOpen}) => <span {...stylex.props(styles.chevron, isOpen && styles.chevronOpen)}><Icon icon="chevronDown" /></span>;`,+ errors: error,+ },+ // Ternary between two transform states.+ {+ code: `${setup} const A = ({isOpen}) => <span {...stylex.props(isOpen ? styles.chevronOpen : styles.chevron)}><Icon icon="chevronDown" /></span>;`,+ errors: error,+ },+ // Still reported when the wrapper ALSO does layout — this is exactly the+ // case no-style-only-wrapper exempts, and the transform still belongs on+ // the child.+ {+ code: `${setup} const A = () => <span {...stylex.props(styles.chevron, styles.box, styles.chevronOpen)}><Icon icon="chevronDown" /></span>;`,+ errors: error,+ },+ // The RTL-folded transform shape.+ {+ code: `${setup} const A = () => <span {...stylex.props(styles.chevronRtl)}><Icon icon="chevronDown" /></span>;`,+ errors: error,+ },+ // Standalone `rotate` longhand, not just the `transform` shorthand.+ {+ code: `${setup} const A = () => <span {...stylex.props(styles.rotateProp)}><Icon icon="chevronDown" /></span>;`,+ errors: error,+ },+ // Dynamic style function.+ {+ code: `${setup} const A = ({deg}) => <span {...stylex.props(styles.sized(deg))}><Icon icon="chevronDown" /></span>;`,+ errors: error,+ },+ // The useIcon() registry-glyph pattern: the wrapper IS the icon element.+ {+ code: `${setup} const A = () => { const chevronIcon = useIcon('chevronDown'); return <span {...stylex.props(styles.chevronOpen)}>{chevronIcon}</span>; };`,+ errors: error,+ },+ // div wrappers too.+ {+ code: `${setup} const A = () => <div {...stylex.props(styles.chevronOpen)}><Icon icon="chevronDown" /></div>;`,+ errors: error,+ },+ ],+});diff --git a/packages/core/src/Banner/Banner.tsx b/packages/core/src/Banner/Banner.tsxindex a6d68e122a..efa0ec67dc 100644--- a/packages/core/src/Banner/Banner.tsx+++ b/packages/core/src/Banner/Banner.tsx@@ -271,8 +271,9 @@ const styles = stylex.create({borderEndStartRadius: radiusVars['--radius-container'],borderEndEndRadius: radiusVars['--radius-container'],},+ // Applied to the chevron <Icon> itself (via `xstyle`) rather than a wrapper,+ // so the element that rotates is the element a theme targets.chevron: {- display: 'inline-flex',transitionProperty: 'transform',transitionDuration: {default: durationVars['--duration-fast'],@@ -484,13 +485,15 @@ export function Banner({: t('@astryx.banner.expand')}icon={- <span- {...stylex.props(+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={[styles.chevron,isExpanded && styles.chevronExpanded,- )}>- <Icon icon="chevronDown" size="sm" color="inherit" />- </span>+ ]}+ />}onClick={handleToggleExpand}aria-expanded={isExpanded}diff --git a/packages/core/src/Breadcrumbs/BreadcrumbItem.tsx b/packages/core/src/Breadcrumbs/BreadcrumbItem.tsxindex e18917c294..7e1b6659a2 100644--- a/packages/core/src/Breadcrumbs/BreadcrumbItem.tsx+++ b/packages/core/src/Breadcrumbs/BreadcrumbItem.tsx@@ -45,7 +45,7 @@ import type {LinkComponentType} from '../Link/types';import {mergeProps, mergeRefs} from '../utils';import type {BaseProps} from '../BaseProps';import {themeProps} from '../utils/themeProps';-import {useIcon} from '../Icon';+import {Icon} from '../Icon';import {usePopover} from '../Popover/usePopover';import {useListFocus} from '../hooks/useListFocus';import {useTypeahead} from '../hooks/useTypeahead';@@ -196,6 +196,11 @@ const itemStyles = stylex.create({display: 'flex',alignItems: 'center',flexShrink: 0,+ // Sized off supporting text (12px) — exactly Icon's `xsm` box at the+ // default type scale. Width/height stay on the token so the box and the+ // glyph keep matching if a theme retunes the supporting step.+ width: typeScaleVars['--text-supporting-size'],+ height: typeScaleVars['--text-supporting-size'],fontSize: typeScaleVars['--text-supporting-size'],},separator: {@@ -507,8 +512,6 @@ function BreadcrumbMenuTrigger({role: 'none',});- const chevronDownIcon = useIcon('chevronDown');-const closeMenu = useCallback(() => {popover.hide();}, [popover]);@@ -624,9 +627,16 @@ function BreadcrumbMenuTrigger({isSupporting ? itemStyles.supportingLink : itemStyles.defaultLink,)}>{children}- <span aria-hidden="true" {...stylex.props(itemStyles.chevron)}>- {chevronDownIcon}- </span>+ <Icon+ icon="chevronDown"+ // 0.75rem — the 12px supporting-text box the bare glyph already+ // rendered at; `itemStyles.chevron` keeps that box on the token.+ size="xsm"+ // The chevron reads as part of the link label, so it takes the+ // trigger's link color rather than an icon color.+ color="inherit"+ xstyle={itemStyles.chevron}+ /></button>{popover.render(diff --git a/packages/core/src/Chat/ChatToolCalls.tsx b/packages/core/src/Chat/ChatToolCalls.tsxindex 234a2e4f42..cb1b5e27ff 100644--- a/packages/core/src/Chat/ChatToolCalls.tsx+++ b/packages/core/src/Chat/ChatToolCalls.tsx@@ -134,6 +134,10 @@ const styles = stylex.create({width: '14px',height: '14px',color: colorVars['--color-text-disabled'],+ },+ // Rides on the chevron <Icon> (via `xstyle`), next to the rotation it+ // animates, so one element carries both the transform and the theme target.+ chevronTransition: {transition: {default: `transform ${durationVars['--duration-fast']} ${easeVars['--ease-standard']}`,'@media (prefers-reduced-motion: reduce)': 'none',@@ -273,10 +277,6 @@ const styles = stylex.create({width: '14px',height: '14px',color: colorVars['--color-text-disabled'],- transition: {- default: `transform ${durationVars['--duration-fast']} ${easeVars['--ease-standard']}`,- '@media (prefers-reduced-motion: reduce)': 'none',- },marginInlineStart: 'auto',},callDetailContent: {@@ -451,12 +451,16 @@ function CallRow({call}: {call: ChatToolCallItem}) {<span {...stylex.props(styles.callDuration)}>{call.duration}</span>)}{hasDetail && (- <span- {...stylex.props(- styles.callDetailChevron,- isDetailOpen && styles.chevronExpanded,- )}>- <Icon icon="chevronDown" size="xsm" color="inherit" />+ <span {...stylex.props(styles.callDetailChevron)}>+ <Icon+ icon="chevronDown"+ size="xsm"+ color="inherit"+ xstyle={[+ styles.chevronTransition,+ isDetailOpen && styles.chevronExpanded,+ ]}+ /></span>)}</div>@@ -627,12 +631,16 @@ export function ChatToolCalls(props: ChatToolCallsProps) {</>)}</span>- <span- {...stylex.props(- styles.chevron,- isExpanded && styles.chevronExpanded,- )}>- <Icon icon="chevronDown" size="xsm" color="inherit" />+ <span {...stylex.props(styles.chevron)}>+ <Icon+ icon="chevronDown"+ size="xsm"+ color="inherit"+ xstyle={[+ styles.chevronTransition,+ isExpanded && styles.chevronExpanded,+ ]}+ /></span></div>diff --git a/packages/core/src/CodeBlock/CodeBlock.tsx b/packages/core/src/CodeBlock/CodeBlock.tsxindex 8d6ab69b78..e05a85f89c 100644--- a/packages/core/src/CodeBlock/CodeBlock.tsx+++ b/packages/core/src/CodeBlock/CodeBlock.tsx@@ -198,6 +198,10 @@ const styles = stylex.create({},animationDuration: durationVars['--duration-medium'],animationTimingFunction: easeVars['--ease-standard'],+ },+ // Applied to the chevron <Icon> (via `xstyle`): the glyph is the element that+ // rotates and the element a theme targets, so one selector reaches both.+ collapseChevronIcon: {transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],@@ -873,12 +877,16 @@ export function CodeBlock({)}><span {...stylex.props(styles.headerTitle)}>{canCollapse && (- <span- {...stylex.props(- styles.collapseChevron,- !isCollapsed && styles.collapseChevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" color="inherit" />+ <span {...stylex.props(styles.collapseChevron)}>+ <Icon+ icon="chevronRight"+ size="xsm"+ color="inherit"+ xstyle={[+ styles.collapseChevronIcon,+ !isCollapsed && styles.collapseChevronExpanded,+ ]}+ /></span>)}{title}diff --git a/packages/core/src/Collapsible/Collapsible.tsx b/packages/core/src/Collapsible/Collapsible.tsxindex 145a67eba6..d6700eaa1a 100644--- a/packages/core/src/Collapsible/Collapsible.tsx+++ b/packages/core/src/Collapsible/Collapsible.tsx@@ -42,7 +42,7 @@ import {import {useCollapsible} from './useCollapsible';import {CollapsibleGroupPresentationContext} from './CollapsibleGroupContext';-import {useIcon} from '../Icon';+import {Icon} from '../Icon';import {mergeProps} from '../utils';import type {BaseProps} from '../BaseProps';import {themeProps} from '../utils/themeProps';@@ -100,10 +100,17 @@ const styles = stylex.create({alignItems: 'center',justifyContent: 'center',flexShrink: 0,+ // The chevron is sized off the trigger's own type size (--text-large-size,+ // 17px), which sits between Icon's `sm` (16px) and `md` (20px) boxes.+ // Pinning the box to the token keeps the glyph exactly the size it was+ // when it was a bare 1em SVG inheriting the trigger's font-size, and keeps+ // it tracking the trigger if a theme retunes that step.+ width: typeScaleVars['--text-large-size'],+ height: typeScaleVars['--text-large-size'],+ fontSize: typeScaleVars['--text-large-size'],transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],- color: colorVars['--color-icon-secondary'],},chevronOpen: {transform: 'rotate(180deg)',@@ -293,8 +300,6 @@ export function Collapsible({const isDivided = presentation?.hasDividers ?? false;const density = presentation?.density ?? null;- const chevronIcon = useIcon('chevronDown');-// Links the trigger to the region it shows/hides so assistive tech can move// from the button to its controlled content (disclosure pattern).const contentId = useId();@@ -334,13 +339,19 @@ export function Collapsible({),)}><span {...stylex.props(styles.triggerLabel)}>{trigger}</span>- <span- {...stylex.props(+ <Icon+ icon="chevronDown"+ // Nearest size to the trigger's 17px type step; `chevron` re-pins the+ // exact box (see the style) so the glyph does not resize.+ size="sm"+ // Was `--color-icon-secondary` on the old wrapper span; `secondary`+ // is the same token, expressed as an Icon color.+ color="secondary"+ xstyle={[styles.chevron,isOpen ? styles.chevronOpen : styles.chevronClosed,- )}>- {chevronIcon}- </span>+ ]}+ /></button><divid={contentId}diff --git a/packages/core/src/ComplexSelector/ComplexSelector.tsx b/packages/core/src/ComplexSelector/ComplexSelector.tsxindex d165b5feac..0cf763e455 100644--- a/packages/core/src/ComplexSelector/ComplexSelector.tsx+++ b/packages/core/src/ComplexSelector/ComplexSelector.tsx@@ -104,11 +104,18 @@ const styles = stylex.create({justifyContent: 'center',width: 16,height: 16,+ color: colorVars['--color-icon-secondary'],+ },+ // Rotation lives on the chevron glyph itself (passed through `xstyle`), not+ // on the layout wrapper above, so the icon's+ // `complex-selector-indicator-icon` theme target and the open/closed+ // transform sit on one element — a theme can restyle the mark and its+ // rotation through a single selector. The wrapper keeps only layout.+ triggerIconRotation: {transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],transformOrigin: 'center',- color: colorVars['--color-icon-secondary'],},triggerIconOpen: {transform: 'rotate(180deg)',@@ -374,15 +381,18 @@ export function ComplexSelector<Value>({<span {...stylex.props(styles.triggerText)}>{triggerContent}</span></button>{isBusy && <Spinner size="sm" />}- <span- {...stylex.props(- styles.triggerIcon,- popover.isOpen && styles.triggerIconOpen,- )}>+ <span {...stylex.props(styles.triggerIcon)}><Iconicon="chevronDown"size="sm"color="inherit"+ // The rotation rides on the glyph rather than the wrapper span so+ // the theme target below reaches both the mark and its open/closed+ // transform.+ xstyle={[+ styles.triggerIconRotation,+ popover.isOpen && styles.triggerIconOpen,+ ]}{...themeProps('complex-selector-indicator-icon', {state: popover.isOpen ? 'expanded' : 'collapsed',})}diff --git a/packages/core/src/MultiSelector/MultiSelector.test.tsx b/packages/core/src/MultiSelector/MultiSelector.test.tsxindex f4a0399a1a..8837b3ecdd 100644--- a/packages/core/src/MultiSelector/MultiSelector.test.tsx+++ b/packages/core/src/MultiSelector/MultiSelector.test.tsx@@ -1715,7 +1715,7 @@ describe('MultiSelector indicator (chevron) icon theme target', () => {const refIcon = refContainer.querySelector('.astryx-icon') as HTMLElement;// Exclude the additive theme-target classes (the stable target + its- // reflected state class) so only the StyleX color/size classes remain.+ // reflected state class) so only StyleX classes remain.const themeTargetClasses = new Set(['astryx-multi-selector-indicator-icon','collapsed',@@ -1727,7 +1727,14 @@ describe('MultiSelector indicator (chevron) icon theme target', () => {.filter(c => !themeTargetClasses.has(c)).sort();- expect(styleClasses(icon)).toEqual(styleClasses(refIcon));+ // A superset, not an exact match: the chevron additionally carries the+ // rotation styles, which live on the glyph precisely so a theme can reach+ // the transform through the same selector as the color. The guard that+ // matters is that every color/size class of a standalone icon is still+ // present — i.e. the default look has not drifted.+ expect(styleClasses(icon)).toEqual(+ expect.arrayContaining(styleClasses(refIcon)),+ );});it('exposes multi-selector-indicator-icon so a theme reaches the icon size and per-state color', () => {diff --git a/packages/core/src/MultiSelector/MultiSelector.tsx b/packages/core/src/MultiSelector/MultiSelector.tsxindex 6ba2eac61f..17f6a9d06d 100644--- a/packages/core/src/MultiSelector/MultiSelector.tsx+++ b/packages/core/src/MultiSelector/MultiSelector.tsx@@ -165,18 +165,23 @@ const styles = stylex.create({justifyContent: 'center',width: 16,height: 16,+ color: colorVars['--color-icon-secondary'],+ },+ // Rotation lives on the chevron glyph itself (passed through `xstyle`), not+ // on the layout wrapper above, so the icon's `multi-selector-indicator-icon`+ // theme target and the open/closed transform sit on one element — a theme can+ // restyle the mark and its rotation through a single selector. The wrapper+ // keeps only layout. The status branch renders a different icon, so it never+ // picks these up and needs no transition opt-out.+ triggerIconRotation: {transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],transformOrigin: 'center',- color: colorVars['--color-icon-secondary'],},triggerIconOpen: {transform: 'rotate(180deg)',},- triggerIconStatus: {- transition: 'none',- },triggerGhost: {width: 'auto',borderWidth: 0,@@ -1540,12 +1545,7 @@ export function MultiSelector<T extends MultiSelectorOptionType>({/></button>)}- <span- {...stylex.props(- styles.triggerIcon,- !showStatusIcon && popover.isOpen && styles.triggerIconOpen,- showStatusIcon && styles.triggerIconStatus,- )}>+ <span {...stylex.props(styles.triggerIcon)}>{showStatusIcon ? (showStatusTooltip ? (<button@@ -1573,6 +1573,13 @@ export function MultiSelector<T extends MultiSelectorOptionType>({icon="chevronDown"size="sm"color="inherit"+ // The rotation rides on the glyph rather than the wrapper span so+ // the theme target below reaches both the mark and its+ // open/closed transform.+ xstyle={[+ styles.triggerIconRotation,+ popover.isOpen && styles.triggerIconOpen,+ ]}// Stable theme target on the chevron glyph itself, so a theme can// restyle just this icon (color, size, hover) — and its// open/closed state — via `defineTheme`. Same-element rules indiff --git a/packages/core/src/Selector/Selector.test.tsx b/packages/core/src/Selector/Selector.test.tsxindex 65d61dbcf3..0e53b9b5fd 100644--- a/packages/core/src/Selector/Selector.test.tsx+++ b/packages/core/src/Selector/Selector.test.tsx@@ -1644,7 +1644,7 @@ describe('Selector indicator (chevron) icon theme target', () => {const refIcon = refContainer.querySelector('.astryx-icon') as HTMLElement;// Exclude the additive theme-target classes (the stable target + its- // reflected state class) so only the StyleX color/size classes remain.+ // reflected state class) so only StyleX classes remain.const themeTargetClasses = new Set(['astryx-selector-indicator-icon','collapsed',@@ -1656,7 +1656,14 @@ describe('Selector indicator (chevron) icon theme target', () => {.filter(c => !themeTargetClasses.has(c)).sort();- expect(styleClasses(icon)).toEqual(styleClasses(refIcon));+ // A superset, not an exact match: the chevron additionally carries the+ // rotation styles, which live on the glyph precisely so a theme can reach+ // the transform through the same selector as the color. The guard that+ // matters is that every color/size class of a standalone icon is still+ // present — i.e. the default look has not drifted.+ expect(styleClasses(icon)).toEqual(+ expect.arrayContaining(styleClasses(refIcon)),+ );});it('exposes selector-indicator-icon so a theme reaches the icon size and per-state color', () => {diff --git a/packages/core/src/Selector/Selector.tsx b/packages/core/src/Selector/Selector.tsxindex 71f2963b92..97beaff2e4 100644--- a/packages/core/src/Selector/Selector.tsx+++ b/packages/core/src/Selector/Selector.tsx@@ -142,19 +142,23 @@ const styles = stylex.create({justifyContent: 'center',width: 16,height: 16,+ color: colorVars['--color-icon-secondary'],+ },+ // Rotation lives on the chevron glyph itself (passed through `xstyle`), not+ // on the layout wrapper above, so the icon's `selector-indicator-icon` theme+ // target and the open/closed transform sit on one element — a theme can+ // restyle the mark and its rotation through a single selector. The wrapper+ // keeps only layout. The status branch renders a different icon, so it never+ // picks these up and needs no transition opt-out.+ triggerIconRotation: {transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],transformOrigin: 'center',- color: colorVars['--color-icon-secondary'],},triggerIconOpen: {transform: 'rotate(180deg)',},- triggerIconStatus: {- // Disable rotation transition for status icons- transition: 'none',- },triggerGhost: {width: 'auto',borderWidth: 0,@@ -1278,12 +1282,7 @@ export function Selector<T extends SelectorOptionType>(/></button>)}- <span- {...stylex.props(- styles.triggerIcon,- !showStatusIcon && popover.isOpen && styles.triggerIconOpen,- showStatusIcon && styles.triggerIconStatus,- )}>+ <span {...stylex.props(styles.triggerIcon)}>{showStatusIcon ? (showStatusTooltip ? (<button@@ -1311,6 +1310,13 @@ export function Selector<T extends SelectorOptionType>(icon="chevronDown"size="sm"color="inherit"+ // The rotation rides on the glyph rather than the wrapper span so+ // the theme target below reaches both the mark and its+ // open/closed transform.+ xstyle={[+ styles.triggerIconRotation,+ popover.isOpen && styles.triggerIconOpen,+ ]}// Stable theme target on the chevron glyph itself, so a theme can// restyle just this icon (color, size, hover) — and its// open/closed state — via `defineTheme`. Same-element rules indiff --git a/packages/core/src/SideNav/SideNavCollapseButton.tsx b/packages/core/src/SideNav/SideNavCollapseButton.tsxindex df170416ea..af7d41abdd 100644--- a/packages/core/src/SideNav/SideNavCollapseButton.tsx+++ b/packages/core/src/SideNav/SideNavCollapseButton.tsx@@ -4,7 +4,7 @@/*** @file SideNavCollapseButton.tsx- * @input Uses React, StyleX, SideNavCollapseContext, getIcon+ * @input Uses React, StyleX, SideNavCollapseContext, Icon* @output Exports SideNavCollapseButton component* @position Composable toggle button for sidenav collapse*@@ -20,7 +20,7 @@import React, {type ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';import {durationVars, easeVars} from '../theme/tokens.stylex';-import {useIcon} from '../Icon';+import {Icon} from '../Icon';import {Button} from '../Button';import type {BaseProps} from '../BaseProps';import {composeEventHandlers, rtlStyles} from '../utils';@@ -107,7 +107,6 @@ export function SideNavCollapseButton({...props}: SideNavCollapseButtonProps) {const t = useTranslator();- const chevronLeftIcon = useIcon('chevronLeft');const {isCollapsed, toggle, isCollapsible} =useSideNavCollapseState(handleRef);const {isMobile} = useAppShellMobile();@@ -132,14 +131,20 @@ export function SideNavCollapseButton({onClick={composeEventHandlers(onClickProp, toggle)}icon={children ?? (+ // The RTL mirror stays on its own element, wrapping (not merged+ // into) the state rotation: both are `transform`, so on a single+ // element one would overwrite the other and the chevron would stop+ // mirroring under RTL. See utils/rtlStyles.ts.<span {...stylex.props(rtlStyles.mirror)}>- <span- {...stylex.props(- styles.chevron,- isCollapsed && styles.chevronCollapsed,- )}>- {chevronLeftIcon}- </span>+ {/* `sm` (1rem) matches what this glyph already renders at: Button's+ icon slot pins its wrapper to 16px, and the registry SVG is+ 1em, so the chevron is 16px today. */}+ <Icon+ icon="chevronLeft"+ size="sm"+ color="inherit"+ xstyle={[styles.chevron, isCollapsed && styles.chevronCollapsed]}+ /></span>)}diff --git a/packages/core/src/SideNav/SideNavHeading.tsx b/packages/core/src/SideNav/SideNavHeading.tsxindex eb963fd4d5..01b58a48f8 100644--- a/packages/core/src/SideNav/SideNavHeading.tsx+++ b/packages/core/src/SideNav/SideNavHeading.tsx@@ -33,7 +33,7 @@ import {// of lazy loading layer resources.import {usePopover} from '../Popover/usePopover';import {Link} from '../Link';-import {useIcon} from '../Icon';+import {Icon} from '../Icon';import {Tooltip} from '../Tooltip';import {navItemStyles} from '../NavItem/navItemStyles.stylex';import {useSideNavCollapse} from './SideNavCollapseContext';@@ -172,6 +172,11 @@ const styles = stylex.create({minWidth: spacingVars['--spacing-7'],minHeight: spacingVars['--spacing-7'],color: colorVars['--color-icon-secondary'],+ // 28px is the hit/alignment box, not the glyph. Icon sizes its own span+ // with a matching font-size (the registry chevron is a 1em SVG), so pin+ // font-size back to inherit to keep the glyph at the 14px it renders at+ // today. The 28px min box still wins over Icon's width/height.+ fontSize: 'inherit',},headerEndContent: {flexShrink: 0,@@ -217,8 +222,15 @@ const styles = stylex.create({minWidth: spacingVars['--spacing-7'],minHeight: spacingVars['--spacing-7'],color: colorVars['--color-icon-secondary'],+ // See `chevron` — keep the glyph on the inherited font-size.+ fontSize: 'inherit',transform: 'rotate(180deg)',},+ // Glyph inside a chevron *trigger* (the button already carries the 28px box+ // and the color, so the Icon only has to avoid resizing itself).+ chevronGlyph: {+ fontSize: 'inherit',+ },popover: {minWidth: 'anchor-size(width)',marginBlockStart: spacingVars['--spacing-1'],@@ -344,7 +356,6 @@ export function SideNavHeading({...props}: SideNavHeadingProps) {const t = useTranslator();- const chevronDownIcon = useIcon('chevronDown');const LinkComponent = useLinkComponent(as);const {isCollapsed} = useSideNavCollapse();const rootRef = useRef<HTMLDivElement>(null);@@ -454,9 +465,12 @@ export function SideNavHeading({)}>{heading}</span>- <span {...stylex.props(styles.popoverChevron)}>- {chevronDownIcon}- </span>+ <Icon+ icon="chevronDown"+ size="sm"+ color="secondary"+ xstyle={styles.popoverChevron}+ /></span>{subheading && (<span {...stylex.props(styles.subheading)}>@@ -551,7 +565,12 @@ export function SideNavHeading({);const chevronElement = showChevron && (- <span {...stylex.props(styles.chevron)}>{chevronDownIcon}</span>+ <Icon+ icon="chevronDown"+ size="sm"+ color="secondary"+ xstyle={styles.chevron}+ />);const headerEndContentElement = headerEndContent && (@@ -567,7 +586,12 @@ export function SideNavHeading({onClick={triggerProps.onClick}>{icon && <span {...stylex.props(styles.icon)}>{icon}</span>}{renderTextContent(- <span {...stylex.props(styles.popoverChevron)}>{chevronDownIcon}</span>,+ <Icon+ icon="chevronDown"+ size="sm"+ color="secondary"+ xstyle={styles.popoverChevron}+ />,)}</button>);@@ -619,7 +643,12 @@ export function SideNavHeading({}}{...popover.triggerProps}{...stylex.props(styles.chevron, styles.interactive)}>- {chevronDownIcon}+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={styles.chevronGlyph}+ /></button>,)}{headerEndContentElement}@@ -685,7 +714,12 @@ export function SideNavHeading({}}{...popover.triggerProps}{...stylex.props(styles.chevron, styles.interactive)}>- {chevronDownIcon}+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={styles.chevronGlyph}+ /></button>) : undefined,)}diff --git a/packages/core/src/SideNav/SideNavItem.tsx b/packages/core/src/SideNav/SideNavItem.tsxindex fcd044238f..41ccdb57b5 100644--- a/packages/core/src/SideNav/SideNavItem.tsx+++ b/packages/core/src/SideNav/SideNavItem.tsx@@ -38,7 +38,7 @@ import {borderVars,radiusVars,} from '../theme/tokens.stylex';-import {renderIconSlot, useIcon, type IconType} from '../Icon';+import {Icon, renderIconSlot, type IconType} from '../Icon';import {useLinkComponent} from '../Link/useLinkComponent';import type {LinkComponentType} from '../Link/types';import {usePopover} from '../Popover/usePopover';@@ -108,6 +108,11 @@ const styles = stylex.create({justifyContent: 'center',width: spacingVars['--spacing-6'],height: spacingVars['--spacing-6'],+ // Icon's `lg` would also set font-size: 1.5rem, and the registry chevron+ // is a 1em SVG — that would blow the glyph up from the 14px it inherits+ // from the row to the full 24px box. The 24px box is the touch/alignment+ // target, not the glyph size, so keep the glyph on the inherited size.+ fontSize: 'inherit',transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],@@ -358,7 +363,6 @@ export function SideNavItem({xstyle,}: SideNavItemProps) {const t = useTranslator();- const chevronDownIcon = useIcon('chevronDown');const {isCollapsed} = useSideNavCollapse();const renderMode = useSideNavRenderMode();const {closeMobileNav} = useAppShellMobile();@@ -574,13 +578,15 @@ export function SideNavItem({<span {...stylex.props(styles.endContent)}>{endContent}</span>)}{!isCollapsed && isItemCollapsible && !hasIndependentToggle && (- <span- {...stylex.props(+ <Icon+ icon="chevronDown"+ size="lg"+ color="inherit"+ xstyle={[styles.expandChevron,!isItemCollapsed && styles.expandChevronExpanded,- )}>- {chevronDownIcon}- </span>+ ]}+ />)}</>);@@ -637,13 +643,15 @@ export function SideNavItem({aria-expanded={!isItemCollapsed}aria-controls={`${id}-children`}{...stylex.props(styles.expandToggle)}>- <span- {...stylex.props(+ <Icon+ icon="chevronDown"+ size="lg"+ color="inherit"+ xstyle={[styles.expandChevron,!isItemCollapsed && styles.expandChevronExpanded,- )}>- {chevronDownIcon}- </span>+ ]}+ /></button></div>);diff --git a/packages/core/src/TabList/TabMenu.tsx b/packages/core/src/TabList/TabMenu.tsxindex 190c08688e..94b22855b3 100644--- a/packages/core/src/TabList/TabMenu.tsx+++ b/packages/core/src/TabList/TabMenu.tsx@@ -161,6 +161,10 @@ const styles = stylex.create({width: spacingVars['--spacing-4'],height: spacingVars['--spacing-4'],flexShrink: 0,+ },+ // Applied to the chevron <Icon> (via `xstyle`) rather than its wrapper, so the+ // element that rotates is the element a theme targets.+ chevronIcon: {transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],@@ -376,13 +380,13 @@ export function TabMenu({{triggerLabel}</span></span>- <span- aria-hidden="true"- {...stylex.props(- styles.chevron,- popover.isOpen && styles.chevronOpen,- )}>- <Icon icon="chevronDown" size="sm" color="inherit" />+ <span aria-hidden="true" {...stylex.props(styles.chevron)}>+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={[styles.chevronIcon, popover.isOpen && styles.chevronOpen]}+ /></span>{hasSelectedOption && (<spandiff --git a/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx b/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsxindex f7dd5f1825..097d2e6a95 100644--- a/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx+++ b/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx@@ -20,7 +20,7 @@ import {fontWeightVars,} from '../../../theme/tokens.stylex';import {Icon} from '../../../Icon';-import {rtlStyles} from '../../../utils';+import {themeProps} from '../../../utils/themeProps';import type {TablePlugin} from '../../types';import {useTranslator} from '../../../i18n';@@ -153,12 +153,25 @@ const styles = stylex.create({},},chevronIcon: {- display: 'inline-flex',transitionProperty: 'transform',transitionDuration: '150ms',},- chevronExpanded: {- transform: 'rotate(90deg)',+ // The RTL mirror is folded into each state's transform rather than living on+ // a parent span. Both are `transform`, so on one element the later value+ // would win — spelling out `scaleX(-1) rotate(...)` per state composes them+ // exactly as the nested elements did, while leaving a single element to+ // carry the glyph's theme target.+ chevronIconCollapsed: {+ transform: {+ default: 'rotate(0deg)',+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(0deg)',+ },+ },+ chevronIconExpanded: {+ transform: {+ default: 'rotate(90deg)',+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(90deg)',+ },},// Emphasized body text — same size as body, heavier weight (Ernest #3).label: {@@ -334,15 +347,19 @@ export function useTableGroupedRows<T extends Record<string, unknown>>(})}aria-expanded={!collapsed}>- <span {...stylex.props(rtlStyles.mirror)}>- <span- {...stylex.props(- styles.chevronIcon,- !collapsed && styles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />- </span>- </span>+ <Icon+ icon="chevronRight"+ size="xsm"+ // The rotation rides on the glyph rather than a wrapper+ // span so the theme target below reaches both the mark and+ // its open/closed transform.+ xstyle={[+ styles.chevronIcon,+ collapsed+ ? styles.chevronIconCollapsed+ : styles.chevronIconExpanded,+ ]}+ /></button>{content}</span>diff --git a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsxindex bf875beabe..3a372c5021 100644--- a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx+++ b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx@@ -20,6 +20,7 @@ import * as stylex from '@stylexjs/stylex';import {spacingVars, colorVars, radiusVars} from '../../../theme/tokens.stylex';import {Icon} from '../../../Icon';import {rtlStyles} from '../../../utils';+import {themeProps} from '../../../utils/themeProps';import {resolveContextActions} from '../../tableContextMenu';import {useTranslator} from '../../../i18n';import type {@@ -320,14 +321,27 @@ const expansionStyles = stylex.create({color: colorVars['--color-icon-primary'],},},- chevronExpanded: {- transform: 'rotate(90deg)',- },chevronIcon: {- display: 'inline-flex',transitionProperty: 'transform',transitionDuration: '150ms',},+ // The RTL mirror is folded into each state's transform rather than living on+ // a parent span. Both are `transform`, so on one element the later value+ // would win — spelling out `scaleX(-1) rotate(...)` per state composes them+ // exactly as the nested elements did, while leaving a single element to+ // carry the glyph's theme target.+ chevronIconCollapsed: {+ transform: {+ default: 'rotate(0deg)',+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(0deg)',+ },+ },+ chevronIconExpanded: {+ transform: {+ default: 'rotate(90deg)',+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(90deg)',+ },+ },indentedCell: {display: 'flex',alignItems: 'center',@@ -370,15 +384,19 @@ function ExpansionChevron({}}aria-label={ariaLabel}aria-expanded={isExpanded}>- <span {...stylex.props(rtlStyles.mirror)}>- <span- {...stylex.props(- expansionStyles.chevronIcon,- isExpanded && expansionStyles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />- </span>- </span>+ <Icon+ icon="chevronRight"+ size="xsm"+ // The rotation rides on the glyph rather than a wrapper span so the+ // theme target below reaches both the mark and its open/closed+ // transform.+ xstyle={[+ expansionStyles.chevronIcon,+ isExpanded+ ? expansionStyles.chevronIconExpanded+ : expansionStyles.chevronIconCollapsed,+ ]}+ /></button>);}@@ -554,15 +572,18 @@ export function useTableRowExpansion<T extends Record<string, unknown>>(? t('@astryx.tableRowExpansion.collapseAllRows'): t('@astryx.tableRowExpansion.expandAllRows')}>- <span {...stylex.props(rtlStyles.mirror)}>- <span- {...stylex.props(- expansionStyles.chevronIcon,- allExpanded && expansionStyles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />- </span>- </span>+ <Icon+ icon="chevronRight"+ size="xsm"+ // Same one-element treatment as the row chevron: the glyph+ // carries both the rotation and the theme target.+ xstyle={[+ expansionStyles.chevronIcon,+ allExpanded+ ? expansionStyles.chevronIconExpanded+ : expansionStyles.chevronIconCollapsed,+ ]}+ /></button>),};diff --git a/packages/core/src/Table/plugins/tree/useTableTreeData.tsx b/packages/core/src/Table/plugins/tree/useTableTreeData.tsxindex 8d1d6ed772..3cf50e030a 100644--- a/packages/core/src/Table/plugins/tree/useTableTreeData.tsx+++ b/packages/core/src/Table/plugins/tree/useTableTreeData.tsx@@ -42,7 +42,8 @@ import {import * as stylex from '@stylexjs/stylex';import {colorVars, radiusVars, spacingVars} from '../../../theme/tokens.stylex';import {Icon} from '../../../Icon';-import {mergeRefs, rtlStyles} from '../../../utils';+import {mergeRefs} from '../../../utils';+import {themeProps} from '../../../utils/themeProps';import type {TablePlugin,TableColumn,@@ -259,14 +260,26 @@ const treeStyles = stylex.create({color: colorVars['--color-icon-primary'],},},- chevron: {- display: 'inline-flex',+ chevronIcon: {transitionProperty: 'transform',transitionDuration: '150ms',- transform: 'rotate(0deg)',},- chevronExpanded: {- transform: 'rotate(90deg)',+ // The RTL mirror is folded into each state's transform rather than living on+ // a parent span. Both are `transform`, so on one element the later value+ // would win — spelling out `scaleX(-1) rotate(...)` per state composes them+ // exactly as the nested elements did, while leaving a single element to+ // carry the glyph's theme target.+ chevronIconCollapsed: {+ transform: {+ default: 'rotate(0deg)',+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(0deg)',+ },+ },+ chevronIconExpanded: {+ transform: {+ default: 'rotate(90deg)',+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(90deg)',+ },},/** Keeps leaf content aligned with expandable siblings. */leafSpacer: {@@ -314,15 +327,19 @@ function TreeExpander({: t('@astryx.tableTree.expandRow')}aria-expanded={isExpanded}>- <span {...stylex.props(rtlStyles.mirror)}>- <span- {...stylex.props(- treeStyles.chevron,- isExpanded && treeStyles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />- </span>- </span>+ <Icon+ icon="chevronRight"+ size="xsm"+ // The rotation rides on the glyph rather than a wrapper span so the+ // theme target below reaches both the mark and its open/closed+ // transform.+ xstyle={[+ treeStyles.chevronIcon,+ isExpanded+ ? treeStyles.chevronIconExpanded+ : treeStyles.chevronIconCollapsed,+ ]}+ /></button>);}@@ -363,15 +380,18 @@ function TreeExpandAllToggle({: t('@astryx.tableTree.expandAllRows')}aria-expanded={allExpanded}>- <span {...stylex.props(rtlStyles.mirror)}>- <span- {...stylex.props(- treeStyles.chevron,- allExpanded && treeStyles.chevronExpanded,- )}>- <Icon icon="chevronRight" size="xsm" />- </span>- </span>+ <Icon+ icon="chevronRight"+ size="xsm"+ // Same one-element treatment as the row expander: the glyph carries+ // both the rotation and the theme target.+ xstyle={[+ treeStyles.chevronIcon,+ allExpanded+ ? treeStyles.chevronIconExpanded+ : treeStyles.chevronIconCollapsed,+ ]}+ /></button>);}diff --git a/packages/core/src/TopNav/TopNavHeading.tsx b/packages/core/src/TopNav/TopNavHeading.tsxindex e00328315c..9d0c656349 100644--- a/packages/core/src/TopNav/TopNavHeading.tsx+++ b/packages/core/src/TopNav/TopNavHeading.tsx@@ -31,7 +31,7 @@ import {} from '../theme/tokens.stylex';import {usePopover} from '../Popover/usePopover';import {Link} from '../Link';-import {useIcon} from '../Icon';+import {Icon} from '../Icon';import {useLinkComponent} from '../Link/useLinkComponent';import type {LinkComponentType} from '../Link/types';import {mergeProps, mergeRefs} from '../utils';@@ -149,6 +149,16 @@ const styles = stylex.create({minHeight: spacingVars['--spacing-7'],color: colorVars['--color-icon-secondary'],},+ // The registry chevron is a 1em SVG, so it has always rendered at the+ // heading's inherited font size. Icon's size box would repin it to a fixed+ // rem (the nearest, sm, is 1rem = 16px vs the 14px base here), so hold the+ // glyph on the inherited em — the 28px chevron box above is unchanged, and+ // the glyph keeps tracking the surrounding text.+ chevronGlyph: {+ width: '1em',+ height: '1em',+ fontSize: 'inherit',+ },headerEndContent: {flexShrink: 0,display: 'flex',@@ -182,14 +192,9 @@ const styles = stylex.create({marginInline: spacingVars['--spacing-1'],cursor: 'pointer',},+ // Composes over `chevron` — the flipped popover copy differs only by the+ // rotation, so it carries just that.popoverChevron: {- flexShrink: 0,- display: 'flex',- alignItems: 'center',- justifyContent: 'center',- minWidth: spacingVars['--spacing-7'],- minHeight: spacingVars['--spacing-7'],- color: colorVars['--color-icon-secondary'],transform: 'rotate(180deg)',},popover: {@@ -313,7 +318,6 @@ export function TopNavHeading({...props}: TopNavHeadingProps) {const t = useTranslator();- const chevronDownIcon = useIcon('chevronDown');const LinkComponent = useLinkComponent(as);// When the logo is wrapped in a link it needs its own accessible name (the// logo image itself is decorative). Prefer an explicit logoLabel, fall back@@ -404,7 +408,12 @@ export function TopNavHeading({);const chevronElement = showChevron && (- <span {...stylex.props(styles.chevron)}>{chevronDownIcon}</span>+ <Icon+ icon="chevronDown"+ size="sm"+ color="secondary"+ xstyle={[styles.chevron, styles.chevronGlyph]}+ />);const headerEndContentElement = headerEndContent && (@@ -420,7 +429,12 @@ export function TopNavHeading({onClick={triggerProps.onClick}>{logo && <span {...stylex.props(styles.logo)}>{logo}</span>}{renderTextContent(- <span {...stylex.props(styles.popoverChevron)}>{chevronDownIcon}</span>,+ <Icon+ icon="chevronDown"+ size="sm"+ color="secondary"+ xstyle={[styles.chevron, styles.chevronGlyph, styles.popoverChevron]}+ />,)}</button>);@@ -488,6 +502,8 @@ export function TopNavHeading({)}>{logo && <span {...stylex.props(styles.logo)}>{logo}</span>}{renderTextContent(+ // Stays a <button>: this box is the popover trigger, so it carries+ // the accessible name and handlers — only the glyph moves to Icon.<buttontype="button"aria-label={t('@astryx.topNav.heading.openMenu')}@@ -497,7 +513,12 @@ export function TopNavHeading({}}{...popover.triggerProps}{...stylex.props(styles.chevron, styles.interactive)}>- {chevronDownIcon}+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={styles.chevronGlyph}+ /></button>,)}{headerEndContentElement}@@ -557,6 +578,9 @@ export function TopNavHeading({))}{renderTextContent(showChevron ? (+ // Stays a <button>: this box is the popover trigger, so it+ // carries the accessible name and handlers — only the glyph+ // moves to Icon.<buttontype="button"aria-label={t('@astryx.topNav.heading.openMenu')}@@ -566,7 +590,12 @@ export function TopNavHeading({}}{...popover.triggerProps}{...stylex.props(styles.chevron, styles.interactive)}>- {chevronDownIcon}+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={styles.chevronGlyph}+ /></button>) : undefined,)}diff --git a/packages/core/src/TopNav/TopNavMegaMenu.tsx b/packages/core/src/TopNav/TopNavMegaMenu.tsxindex 7b3de1a530..d9454785c3 100644--- a/packages/core/src/TopNav/TopNavMegaMenu.tsx+++ b/packages/core/src/TopNav/TopNavMegaMenu.tsx@@ -44,7 +44,7 @@ import {} from '../theme/tokens.stylex';import {usePopover} from '../Popover/usePopover';import {Grid} from '../Grid/Grid';-import {useIcon} from '../Icon';+import {Icon} from '../Icon';import {mergeProps, mergeRefs} from '../utils';import type {BaseProps} from '../BaseProps';import {navItemStyles} from '../NavItem/navItemStyles.stylex';@@ -97,6 +97,14 @@ const styles = stylex.create({chevron: {display: 'inline-flex',alignItems: 'center',+ // The registry chevron is a 1em SVG, so it has always rendered at the+ // trigger's own font size (--text-label-size). Icon's size box would repin+ // it to a fixed rem (the nearest, sm, is 1rem = 16px vs the 14px here), so+ // hold it on the inherited em: same pixels, and still tracks the type+ // scale when a theme changes the label size.+ width: '1em',+ height: '1em',+ fontSize: 'inherit',transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],@@ -197,6 +205,11 @@ const styles = stylex.create({},drawerChevron: {display: 'inline-flex',+ // Same em pin as styles.chevron above — the drawer header inherits+ // --text-label-size from navItemStyles.item.+ width: '1em',+ height: '1em',+ fontSize: 'inherit',transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],@@ -364,7 +377,6 @@ function DefaultMegaMenu({onOpenChange,}: TopNavMegaMenuProps) {const slot = useTopNavSlot();- const chevronDownIcon = useIcon('chevronDown');const showTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);const triggerButtonRef = useRef<HTMLButtonElement | null>(null);@@ -472,13 +484,12 @@ function DefaultMegaMenu({stylex.props(styles.trigger, popover.isOpen && styles.triggerOpen),)}>{label}- <span- {...stylex.props(- styles.chevron,- popover.isOpen && styles.chevronOpen,- )}>- {chevronDownIcon}- </span>+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={[styles.chevron, popover.isOpen && styles.chevronOpen]}+ /></button>{popover.render(<div@@ -524,7 +535,6 @@ function DrawerMegaMenu({featured,}: Pick<TopNavMegaMenuProps, 'label' | 'items' | 'featured'>) {const [isExpanded, setIsExpanded] = useState(false);- const chevronDownIcon = useIcon('chevronDown');const menuId = `mega-menu-${label.toLowerCase().replace(/\s+/g, '-')}`;return (@@ -540,13 +550,15 @@ function DrawerMegaMenu({stylex.props(navItemStyles.item, styles.drawerHeader),)}>{label}- <span- {...stylex.props(+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={[styles.drawerChevron,isExpanded && styles.drawerChevronExpanded,- )}>- {chevronDownIcon}- </span>+ ]}+ /></button>{/* Animated expand/collapse container */}diff --git a/packages/core/src/TopNav/TopNavMenu.tsx b/packages/core/src/TopNav/TopNavMenu.tsxindex 7221981293..37e663b995 100644--- a/packages/core/src/TopNav/TopNavMenu.tsx+++ b/packages/core/src/TopNav/TopNavMenu.tsx@@ -28,7 +28,7 @@ import {usePopover} from '../Popover/usePopover';import {useMenuHover} from '../hooks/useMenuHover';import {useListFocus} from '../hooks/useListFocus';import {useTypeahead} from '../hooks/useTypeahead';-import {useIcon} from '../Icon';+import {Icon} from '../Icon';import {mergeProps, mergeRefs} from '../utils';import type {BaseProps} from '../BaseProps';import {navItemStyles} from '../NavItem/navItemStyles.stylex';@@ -92,6 +92,14 @@ const styles = stylex.create({chevron: {display: 'inline-flex',alignItems: 'center',+ // The registry chevron is a 1em SVG, so it has always rendered at the+ // trigger's own font size (--text-label-size). Icon's size box would repin+ // it to a fixed rem (the nearest, sm, is 1rem = 16px vs the 14px here), so+ // hold it on the inherited em: same pixels, and still tracks the type+ // scale when a theme changes the label size.+ width: '1em',+ height: '1em',+ fontSize: 'inherit',transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],@@ -179,6 +187,11 @@ const drawerStyles = stylex.create({},chevron: {display: 'inline-flex',+ // Same em pin as styles.chevron above — the drawer header inherits+ // --text-label-size from navItemStyles.item.+ width: '1em',+ height: '1em',+ fontSize: 'inherit',transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],@@ -332,7 +345,6 @@ export function TopNavMenu({hideDelay = 200,}: TopNavMenuProps) {const renderMode = useTopNavRenderMode();- const chevronDownIcon = useIcon('chevronDown');const {closeMobileNav} = useAppShellMobile();const LinkComponent = useLinkComponent();const [drawerExpanded, setDrawerExpanded] = useState(false);@@ -441,13 +453,15 @@ export function TopNavMenu({aria-controls={`${menuId}-items`}{...stylex.props(navItemStyles.item, drawerStyles.header)}>{label}- <span- {...stylex.props(+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={[drawerStyles.chevron,drawerExpanded && drawerStyles.chevronExpanded,- )}>- {chevronDownIcon}- </span>+ ]}+ /></button><divid={`${menuId}-items`}@@ -499,13 +513,12 @@ export function TopNavMenu({stylex.props(styles.trigger, popover.isOpen && styles.triggerOpen),)}>{label}- <span- {...stylex.props(- styles.chevron,- popover.isOpen && styles.chevronOpen,- )}>- {chevronDownIcon}- </span>+ <Icon+ icon="chevronDown"+ size="sm"+ color="inherit"+ xstyle={[styles.chevron, popover.isOpen && styles.chevronOpen]}+ /></button>{popover.render(<divdiff --git a/packages/core/src/TreeList/TreeListItem.tsx b/packages/core/src/TreeList/TreeListItem.tsxindex 1432f35f91..5d4c57940a 100644--- a/packages/core/src/TreeList/TreeListItem.tsx+++ b/packages/core/src/TreeList/TreeListItem.tsx@@ -24,8 +24,8 @@ import {easeVars,typeScaleVars,} from '../theme/tokens.stylex';-import {useIcon} from '../Icon';-import {mergeProps, rtlStyles} from '../utils';+import {Icon} from '../Icon';+import {mergeProps} from '../utils';import {useLinkComponent} from '../Link/useLinkComponent';import {TreeListBranches} from './TreeListBranches';import type {TreeListDensity, TreeListVariant} from './TreeListTypes';@@ -207,15 +207,34 @@ const styles = stylex.create({},chevronSvg: {display: 'flex',+ // The chevron column is sized in spacing tokens by the button/container+ // around it (--spacing-4 = 16px), not on Icon's rem scale, so the glyph's+ // box is pinned to that same token. Icon's `sm` (1rem) only coincides with+ // 16px at a 16px root font-size; drifting off the token would knock the+ // glyph out of its 16px column.+ width: spacingVars['--spacing-4'],+ height: spacingVars['--spacing-4'],+ fontSize: spacingVars['--spacing-4'],transitionProperty: 'transform',transitionDuration: durationVars['--duration-fast'],transitionTimingFunction: easeVars['--ease-standard'],},+ // The RTL mirror is folded into each state's transform rather than living on+ // a parent span. Both are `transform`, so on one element the later value+ // would win — spelling out `scaleX(-1) rotate(...)` per state composes them+ // exactly as the nested elements did, while leaving a single element to+ // carry the glyph's theme target.chevronExpanded: {- transform: 'rotate(90deg)',+ transform: {+ default: 'rotate(90deg)',+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(90deg)',+ },},chevronCollapsed: {- transform: 'rotate(0deg)',+ transform: {+ default: 'rotate(0deg)',+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(0deg)',+ },},});@@ -328,7 +347,6 @@ export function TreeListItem({isTabbable,}: TreeListItemInternalProps) {const t = useTranslator();- const chevronRightIcon = useIcon('chevronRight');const labelId = useId();const descriptionId = useId();const LinkComponent = useLinkComponent();@@ -406,16 +424,24 @@ export function TreeListItem({</>);+ // <Icon> renders the glyph's span itself — carrying the pre-existing+ // astryx-icon target — so the rotation rides on that same element instead of+ // an extra wrapper: a theme can still restyle the mark and its open/closed+ // transform through one selector.const chevronIcon = (- <span {...stylex.props(rtlStyles.mirror)}>- <span- {...stylex.props(- styles.chevronSvg,- isExpanded ? styles.chevronExpanded : styles.chevronCollapsed,- )}>- {chevronRightIcon}- </span>- </span>+ <Icon+ icon="chevronRight"+ // Nearest size to the 16px chevron column; `chevronSvg` re-pins the exact+ // box because the column is spacing-token-sized, not rem-sized.+ size="sm"+ // The button/container owns the chevron color (--color-icon-secondary);+ // inheriting keeps that as the single source.+ color="inherit"+ xstyle={[+ styles.chevronSvg,+ isExpanded ? styles.chevronExpanded : styles.chevronCollapsed,+ ]}+ />);const chevron = hasChildren ? (