Skip to content

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

TypeScript

Add statusVariant prop to XDSField (#128)

Cindy Zhangf00f41b17d77
diff --git a/packages/core/src/Field/XDSField.tsx b/packages/core/src/Field/XDSField.tsx
index 7c79599b5e..5c9c2aab65 100644
--- a/packages/core/src/Field/XDSField.tsx
+++ b/packages/core/src/Field/XDSField.tsx
@@ -138,6 +138,13 @@ export interface XDSFieldProps extends Omit<
* Tooltip text to display in an info icon at the end of the label.
*/
labelTooltip?: string;
+ /**
+ * How the status message is rendered relative to the input.
+ * - 'attached': Status sits directly below the input (default, for bordered inputs)
+ * - 'detached': Status is a separate element below the field (for checkboxes, switches, sliders)
+ * @default 'attached'
+ */
+ statusVariant?: 'attached' | 'detached';
/**
* The input or control to render inside the field.
*/
@@ -169,6 +176,7 @@ export const XDSField = forwardRef<HTMLDivElement, XDSFieldProps>(
labelStartIcon,
status,
labelTooltip,
+ statusVariant = 'attached',
children,
...props
},
@@ -190,17 +198,31 @@ export const XDSField = forwardRef<HTMLDivElement, XDSFieldProps>(
{description}
</span>
)}
- <div {...stylex.props(styles.inputStatusWrapper)}>
- {children}
- {status?.message && (
- <XDSFieldStatus
- type={status.type}
- message={status.message}
- id={status.messageID}
- variant="attached"
- />
- )}
- </div>
+ {statusVariant === 'attached' ? (
+ <div {...stylex.props(styles.inputStatusWrapper)}>
+ {children}
+ {status?.message && (
+ <XDSFieldStatus
+ type={status.type}
+ message={status.message}
+ id={status.messageID}
+ variant="attached"
+ />
+ )}
+ </div>
+ ) : (
+ <>
+ {children}
+ {status?.message && (
+ <XDSFieldStatus
+ type={status.type}
+ message={status.message}
+ id={status.messageID}
+ variant="detached"
+ />
+ )}
+ </>
+ )}
</div>
);
},
diff --git a/packages/core/src/RadioList/XDSRadioList.tsx b/packages/core/src/RadioList/XDSRadioList.tsx
index 23035119e1..a6b0ba8e1b 100644
--- a/packages/core/src/RadioList/XDSRadioList.tsx
+++ b/packages/core/src/RadioList/XDSRadioList.tsx
@@ -189,6 +189,7 @@ export function XDSRadioList({
: undefined
}
labelTooltip={labelTooltip}
+ statusVariant="detached"
{...stylex.props(xstyle)}>
<div
role="radiogroup"