Skip to content

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

TypeScript

feat(core): complete RTL physical→logical migration (#4614)

nynexman446478221dee1216
diff --git a/.changeset/rtl-physical-to-logical.md b/.changeset/rtl-physical-to-logical.md
new file mode 100644
index 0000000000..d05c21ddac
--- /dev/null
+++ b/.changeset/rtl-physical-to-logical.md
@@ -0,0 +1,10 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Complete the RTL physical→logical CSS migration across the core package: the final components (Avatar, Banner, Calendar, Chat composer, Chat composer drawer, Markdown, Popover, Slider, Resizable) now use CSS logical properties (`insetInlineStart/End`, `borderStart*/End*` radii, `textAlign: 'end'`) instead of physical `left`/`right`, so they mirror correctly under RTL. The Avatar status dot's outward-push `transform` is now direction-aware, so it hugs the bottom-inline-end corner (bottom-right in LTR, bottom-left in RTL) instead of pulling inward under RTL.
+
+The Popover close button, vertical Slider track/thumb, and ResizeHandle centered grab-zone/pill now consume the shared `rtlStyles.centerInline` helper — fixing an RTL regression where a logical `insetInlineStart: 50%` anchor combined with a physical centering `translate` shifted the element off-center by its own width.
+
+Dialog's `position` prop is intentionally left physical: it exposes physical `left`/`right` as consumer-facing API, so its logical migration is handled separately via a deprecation path in its own PR. LTR rendering is pixel-identical.
+@nynexman4464
diff --git a/packages/core/src/Avatar/Avatar.tsx b/packages/core/src/Avatar/Avatar.tsx
index debef5fc40..4e70edaa86 100644
--- a/packages/core/src/Avatar/Avatar.tsx
+++ b/packages/core/src/Avatar/Avatar.tsx
@@ -215,8 +215,13 @@ const dynamicStyles = stylex.create({
}),
statusPosition: (size: number) => ({
bottom: size * CIRCLE_EDGE_OFFSET_RATIO,
- right: size * CIRCLE_EDGE_OFFSET_RATIO,
- transform: 'translate(50%, 50%)',
+ insetInlineEnd: size * CIRCLE_EDGE_OFFSET_RATIO,
+ // `insetInlineEnd` anchors to the right edge in LTR / left in RTL, so the
+ // outward push must mirror too: +X in LTR, −X in RTL (Y is unaffected).
+ transform: {
+ default: 'translate(50%, 50%)',
+ ':is([dir="rtl"] *)': 'translate(-50%, 50%)',
+ },
}),
});
diff --git a/packages/core/src/Banner/Banner.tsx b/packages/core/src/Banner/Banner.tsx
index 4978e1c506..8266bd6111 100644
--- a/packages/core/src/Banner/Banner.tsx
+++ b/packages/core/src/Banner/Banner.tsx
@@ -243,10 +243,10 @@ const styles = stylex.create({
borderRadius: radiusVars['--radius-container'],
},
headerCardWithContent: {
- borderTopLeftRadius: radiusVars['--radius-container'],
- borderTopRightRadius: radiusVars['--radius-container'],
- borderBottomLeftRadius: 0,
- borderBottomRightRadius: 0,
+ borderStartStartRadius: radiusVars['--radius-container'],
+ borderStartEndRadius: radiusVars['--radius-container'],
+ borderEndStartRadius: 0,
+ borderEndEndRadius: 0,
},
// When there's only a title (no description) and actions, center everything vertically
headerCentered: {
@@ -305,8 +305,8 @@ const styles = stylex.create({
borderBottomColor: colorVars['--color-border'],
},
contentAreaCard: {
- borderBottomLeftRadius: radiusVars['--radius-container'],
- borderBottomRightRadius: radiusVars['--radius-container'],
+ borderEndStartRadius: radiusVars['--radius-container'],
+ borderEndEndRadius: radiusVars['--radius-container'],
},
chevron: {
display: 'inline-flex',
diff --git a/packages/core/src/Calendar/styles.ts b/packages/core/src/Calendar/styles.ts
index d49b6301a2..7845f05953 100644
--- a/packages/core/src/Calendar/styles.ts
+++ b/packages/core/src/Calendar/styles.ts
@@ -215,9 +215,9 @@ export const dayCellStyles = stylex.create({
content: '""',
position: 'absolute',
top: '-2px',
- right: '-2px',
+ insetInlineEnd: '-2px',
bottom: '-2px',
- left: '-2px',
+ insetInlineStart: '-2px',
},
},
diff --git a/packages/core/src/Chat/ChatComposer.tsx b/packages/core/src/Chat/ChatComposer.tsx
index 54db759e0d..0ceced9936 100644
--- a/packages/core/src/Chat/ChatComposer.tsx
+++ b/packages/core/src/Chat/ChatComposer.tsx
@@ -230,16 +230,16 @@ const styles = stylex.create({
paddingBlockEnd:
'calc(var(--_chat-composer-padding) + var(--_chat-composer-radius))',
marginBlockEnd: 'calc(-1 * var(--_chat-composer-radius))',
- borderTopLeftRadius: 'var(--_chat-composer-radius)',
- borderTopRightRadius: 'var(--_chat-composer-radius)',
+ borderStartStartRadius: 'var(--_chat-composer-radius)',
+ borderStartEndRadius: 'var(--_chat-composer-radius)',
},
statusBottom: {
paddingBlockStart:
'calc(var(--_chat-composer-padding) + var(--_chat-composer-radius))',
paddingBlockEnd: 'var(--_chat-composer-padding)',
marginBlockStart: 'calc(-1 * var(--_chat-composer-radius))',
- borderBottomLeftRadius: 'var(--_chat-composer-radius)',
- borderBottomRightRadius: 'var(--_chat-composer-radius)',
+ borderEndStartRadius: 'var(--_chat-composer-radius)',
+ borderEndEndRadius: 'var(--_chat-composer-radius)',
},
statusError: {
backgroundColor: colorVars['--color-error-muted'],
diff --git a/packages/core/src/Chat/ChatComposerDrawer.tsx b/packages/core/src/Chat/ChatComposerDrawer.tsx
index 3d1e1fe975..483d7439d9 100644
--- a/packages/core/src/Chat/ChatComposerDrawer.tsx
+++ b/packages/core/src/Chat/ChatComposerDrawer.tsx
@@ -104,8 +104,8 @@ const styles = stylex.create({
// opaque or translucent.
backgroundColor: colorVars['--color-background-surface'],
backgroundImage: `linear-gradient(${colorVars['--color-background-muted']}, ${colorVars['--color-background-muted']})`,
- borderTopLeftRadius: radiusVars['--radius-chat'],
- borderTopRightRadius: radiusVars['--radius-chat'],
+ borderStartStartRadius: radiusVars['--radius-chat'],
+ borderStartEndRadius: radiusVars['--radius-chat'],
},
// Toggle row — both the bar handle and badge+label live in the
diff --git a/packages/core/src/Dialog/Dialog.tsx b/packages/core/src/Dialog/Dialog.tsx
index 5fee3c1a3d..6352e7350f 100644
--- a/packages/core/src/Dialog/Dialog.tsx
+++ b/packages/core/src/Dialog/Dialog.tsx
@@ -223,8 +223,14 @@ const dynamicStyles = stylex.create({
// When position is set, disable auto margin and use fixed positioning
margin: 0,
top: top !== undefined ? formatPosition(top) : 'auto',
+ // consumer-facing DialogPosition API — physical by contract; logical
+ // start/end migration tracked separately in the Dialog position deprecation PR
+ // eslint-disable-next-line @astryx/no-physical-properties
right: right !== undefined ? formatPosition(right) : 'auto',
bottom: bottom !== undefined ? formatPosition(bottom) : 'auto',
+ // consumer-facing DialogPosition API — physical by contract; logical
+ // start/end migration tracked separately in the Dialog position deprecation PR
+ // eslint-disable-next-line @astryx/no-physical-properties
left: left !== undefined ? formatPosition(left) : 'auto',
}),
});
diff --git a/packages/core/src/Markdown/Markdown.tsx b/packages/core/src/Markdown/Markdown.tsx
index 0854bc4e2b..0b5b0b99fc 100644
--- a/packages/core/src/Markdown/Markdown.tsx
+++ b/packages/core/src/Markdown/Markdown.tsx
@@ -226,7 +226,7 @@ const dynamicStyles = stylex.create({
const cellAlignStyles = stylex.create({
center: {textAlign: 'center'},
- right: {textAlign: 'right'},
+ end: {textAlign: 'end'},
});
const styles = stylex.create({
@@ -1436,7 +1436,7 @@ function renderBlock(
xstyle={[
dynamicStyles.cellMinWidth(`${colMinWidths[i]}px`),
node.alignments[i] === 'center' && cellAlignStyles.center,
- node.alignments[i] === 'right' && cellAlignStyles.right,
+ node.alignments[i] === 'right' && cellAlignStyles.end,
]}>
{h.children.map((c, j) =>
renderInline(
@@ -1462,7 +1462,7 @@ function renderBlock(
key={j}
xstyle={[
node.alignments[j] === 'center' && cellAlignStyles.center,
- node.alignments[j] === 'right' && cellAlignStyles.right,
+ node.alignments[j] === 'right' && cellAlignStyles.end,
]}>
{cell.children.map((c, k) =>
renderInline(
diff --git a/packages/core/src/Popover/usePopover.tsx b/packages/core/src/Popover/usePopover.tsx
index a137938d36..d213475ad2 100644
--- a/packages/core/src/Popover/usePopover.tsx
+++ b/packages/core/src/Popover/usePopover.tsx
@@ -27,6 +27,7 @@ import {
shadowVars,
} from '../theme/tokens.stylex';
import {Button} from '../Button';
+import {rtlStyles} from '../utils';
import {useTranslator} from '../i18n';
import {useDevWarning} from '../hooks/useDevWarning';
@@ -43,12 +44,13 @@ const styles = stylex.create({
contentWrapper: {
position: 'relative',
},
- // Hidden close button wrapper - sr-only until focused, then positioned below popover
+ // Hidden close button wrapper - sr-only until focused, then positioned below
+ // popover. Inline-axis centering (+ the translateY(100%) that drops it below
+ // the surface) comes from rtlStyles.centerInline('100%') at the call site —
+ // it centers correctly in both LTR and RTL.
closeButtonWrapper: {
position: 'absolute',
bottom: 0,
- left: '50%',
- transform: 'translate(-50%, 100%)',
zIndex: 1,
// sr-only by default
width: {
@@ -417,7 +419,11 @@ export function usePopover(options: UsePopoverOptions = {}): UsePopoverReturn {
)}>
{children}
{hasCloseButton && (
- <div {...stylex.props(styles.closeButtonWrapper)}>
+ <div
+ {...stylex.props(
+ styles.closeButtonWrapper,
+ rtlStyles.centerInline('100%'),
+ )}>
<Button
variant="secondary"
label={closeButtonLabel}
diff --git a/packages/core/src/Resizable/ResizeHandle.test.tsx b/packages/core/src/Resizable/ResizeHandle.test.tsx
index 096f0acda2..a60ee10c22 100644
--- a/packages/core/src/Resizable/ResizeHandle.test.tsx
+++ b/packages/core/src/Resizable/ResizeHandle.test.tsx
@@ -290,8 +290,9 @@ describe('ResizeHandle', () => {
it('centers the grab zone on the divider when the pill is centered (no bias)', () => {
render(<Harness handleProps={{pillPlacement: 'center'}} />);
const hitArea = getSeparator().firstElementChild as HTMLElement;
- // No physical offset — a plain logical centering class, no biased transform.
- expect(hitArea.className).toContain('hitAreaCenteredX');
+ // Centered via the shared rtlStyles.centerInline helper (direction-symmetric
+ // left+translateX), not a biased offset.
+ expect(hitArea.className).toContain('centerInline');
expect(hitArea.className).not.toContain('hitAreaOffsetX');
});
diff --git a/packages/core/src/Resizable/ResizeHandle.tsx b/packages/core/src/Resizable/ResizeHandle.tsx
index c279f37e91..9143e5f161 100644
--- a/packages/core/src/Resizable/ResizeHandle.tsx
+++ b/packages/core/src/Resizable/ResizeHandle.tsx
@@ -30,7 +30,7 @@ import {
radiusVars,
spacingVars,
} from '../theme/tokens.stylex';
-import {mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs, rtlStyles} from '../utils';
import type {ResizableProps} from './useResizable';
import {themeProps} from '../utils/themeProps';
import {useTranslator} from '../i18n';
@@ -167,11 +167,8 @@ const styles = stylex.create({
cursor: 'row-resize',
},
// Centered grab zone (pillPlacement 'center' / no bias): sit the hit area on
- // the divider itself. Anchored logically so it centers in both directions.
- hitAreaCenteredX: {
- insetInlineStart: '50%',
- transform: 'translateX(-50%)',
- },
+ // the divider itself. Inline centering comes from rtlStyles.centerInline at
+ // the call site (correct in LTR and RTL); this block owns only the block axis.
hitAreaCenteredY: {
insetBlockStart: '50%',
transform: 'translateY(-50%)',
@@ -188,8 +185,6 @@ const styles = stylex.create({
transitionDuration: durationVars['--duration-fast'],
transitionTimingFunction: easeVars['--ease-standard'],
top: '50%',
- insetInlineStart: '50%',
- transform: 'translate(-50%, -50%)',
},
pillHorizontal: {
width: 3,
@@ -586,7 +581,7 @@ export function ResizeHandle({
// construction so the two stay aligned in LTR and RTL alike.
hitBiasDir == null
? isHorizontal
- ? styles.hitAreaCenteredX
+ ? rtlStyles.centerInline('0px')
: styles.hitAreaCenteredY
: isHorizontal
? dynamicStyles.hitAreaOffsetX(hitBiasDir)
@@ -609,14 +604,15 @@ export function ResizeHandle({
stylex.props(
styles.pill,
isHorizontal ? styles.pillHorizontal : styles.pillVertical,
- effectiveSide !== 'center' &&
- (isHorizontal
+ effectiveSide === 'center'
+ ? rtlStyles.centerInline('-50%')
+ : isHorizontal
? dynamicStyles.pillOffsetX(
effectiveSide === 'start' ? -1 : 1,
)
: dynamicStyles.pillOffsetY(
effectiveSide === 'start' ? -1 : 1,
- )),
+ ),
isAlwaysVisible ? styles.pillVisible : styles.pillHidden,
isInteracting && !isDragging && styles.pillHover,
isDragging && styles.pillActive,
diff --git a/packages/core/src/Slider/Slider.tsx b/packages/core/src/Slider/Slider.tsx
index 26e49a3036..f8142b0df2 100644
--- a/packages/core/src/Slider/Slider.tsx
+++ b/packages/core/src/Slider/Slider.tsx
@@ -40,7 +40,7 @@ import {Tooltip} from '../Tooltip/Tooltip';
import {useTooltip} from '../Tooltip';
import {VisuallyHidden} from '../VisuallyHidden';
import type {InputStatus} from '../Field/types';
-import {mergeProps, mergeRefs} from '../utils';
+import {mergeProps, mergeRefs, rtlStyles} from '../utils';
import {isRtlElement} from '../hooks/isRtlElement';
import type {BaseProps} from '../BaseProps';
import type {SizeValue} from '../utils/types';
@@ -203,8 +203,6 @@ const styles = stylex.create({
top: 0,
bottom: 0,
width: TRACK_SIZE,
- insetInlineStart: '50%',
- transform: 'translateX(-50%)',
},
filledTrack: {
position: 'absolute',
@@ -218,8 +216,6 @@ const styles = stylex.create({
},
filledTrackVertical: {
width: TRACK_SIZE,
- insetInlineStart: '50%',
- transform: 'translateX(-50%)',
},
thumb: {
position: 'absolute',
@@ -249,10 +245,6 @@ const styles = stylex.create({
':is([dir="rtl"] *)': 'translate(50%, -50%)',
},
},
- thumbVertical: {
- insetInlineStart: '50%',
- transform: 'translate(-50%, 50%)',
- },
thumbHover: {
backgroundColor: {
default: colorVars['--color-accent'],
@@ -796,7 +788,9 @@ export function Slider({ref, ...props}: SliderProps) {
}),
stylex.props(
styles.thumb,
- isHorizontal ? styles.thumbHorizontal : styles.thumbVertical,
+ isHorizontal
+ ? styles.thumbHorizontal
+ : rtlStyles.centerInline('50%'),
!isDisabled && styles.thumbHover,
!isDisabled && styles.thumbFocusVisible,
isDisabled && styles.thumbDisabled,
@@ -930,7 +924,9 @@ export function Slider({ref, ...props}: SliderProps) {
themeProps('slider-track', {orientation}),
stylex.props(
styles.track,
- isHorizontal ? styles.trackHorizontal : styles.trackVertical,
+ isHorizontal
+ ? styles.trackHorizontal
+ : [styles.trackVertical, rtlStyles.centerInline('0px')],
),
)}
/>
@@ -943,7 +939,7 @@ export function Slider({ref, ...props}: SliderProps) {
styles.filledTrack,
isHorizontal
? styles.filledTrackHorizontal
- : styles.filledTrackVertical,
+ : [styles.filledTrackVertical, rtlStyles.centerInline('0px')],
),
{style: filledStyle},
)}