Skip to content

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

TypeScript

fix(Spinner,Slider): add escape hatches, xdsClassName completeness (#828)

Cindy Zhangb9ceb35a5997
diff --git a/packages/core/src/Slider/XDSSlider.tsx b/packages/core/src/Slider/XDSSlider.tsx
index 3e72db611d..1107c9e973 100644
--- a/packages/core/src/Slider/XDSSlider.tsx
+++ b/packages/core/src/Slider/XDSSlider.tsx
@@ -13,7 +13,6 @@
* - /apps/storybook/stories/Slider.stories.tsx
*/
-
import {
useId,
useRef,
@@ -577,7 +576,10 @@ export function XDSSlider({ref, ...props}: XDSSliderProps) {
style={positionStyle}
onKeyDown={e => handleKeyDown(thumbIndex, e)}
{...mergeProps(
- xdsClassName('slider-thumb', {orientation}),
+ xdsClassName('slider-thumb', {
+ orientation,
+ disabled: isDisabled ? 'disabled' : null,
+ }),
stylex.props(
styles.thumb,
isHorizontal ? styles.thumbHorizontal : styles.thumbVertical,
@@ -659,7 +661,10 @@ export function XDSSlider({ref, ...props}: XDSSliderProps) {
style={style}>
<div
{...mergeProps(
- xdsClassName('slider', {orientation}),
+ xdsClassName('slider', {
+ orientation,
+ disabled: isDisabled ? 'disabled' : null,
+ }),
stylex.props(styles.sliderRow),
)}>
<div
diff --git a/packages/core/src/Spinner/XDSSpinner.tsx b/packages/core/src/Spinner/XDSSpinner.tsx
index d777024dbc..7303b83497 100644
--- a/packages/core/src/Spinner/XDSSpinner.tsx
+++ b/packages/core/src/Spinner/XDSSpinner.tsx
@@ -13,9 +13,9 @@
* - /apps/storybook/stories/Spinner.stories.tsx
*/
-
import {useEffect, useRef} from 'react';
import * as stylex from '@stylexjs/stylex';
+import type {StyleXStyles} from '@stylexjs/stylex';
import {colorVars} from '../theme/tokens.stylex';
import {xdsClassName, mergeProps} from '../utils';
@@ -88,6 +88,22 @@ export interface XDSSpinnerProps {
* @default 'default'
*/
shade?: XDSSpinnerShade;
+ /**
+ * StyleX styles created via `stylex.create()`. Merged with the component's
+ * base styles inside a single `stylex.props()` call for optimal deduplication.
+ *
+ * @example
+ * ```
+ * const overrides = stylex.create({ root: { marginBottom: 8 } });
+ * <Component xstyle={overrides.root} />
+ * ```
+ */
+ xstyle?: StyleXStyles;
+ /**
+ * CSS class name(s) appended to the root element.
+ * If you're using StyleX, prefer `xstyle` for optimal style deduplication.
+ */
+ className?: string;
/**
* Test ID for the root element.
*/
@@ -111,6 +127,8 @@ export interface XDSSpinnerProps {
export function XDSSpinner({
size = 'md',
shade = 'default',
+ xstyle,
+ className,
'data-testid': testId,
ref,
}: XDSSpinnerProps) {
@@ -179,8 +197,9 @@ export function XDSSpinner({
aria-label="Loading"
data-testid={testId}
{...mergeProps(
- xdsClassName('spinner', {size}),
- stylex.props(styles.spinner),
+ xdsClassName('spinner', {size, shade}),
+ stylex.props(styles.spinner, xstyle),
+ className,
)}
style={{width: frameSize, height: frameSize}}>
<canvas ref={canvasRef} {...stylex.props(styles.canvas)} />