Skip to content

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

TypeScript

feat(lint): add boolean prop naming ESLint rule (#121)

Cindy Zhangbc39329ee5c1
diff --git a/apps/storybook/stories/Button.stories.tsx b/apps/storybook/stories/Button.stories.tsx
index cc43f76f19..6abb8898ac 100644
--- a/apps/storybook/stories/Button.stories.tsx
+++ b/apps/storybook/stories/Button.stories.tsx
@@ -21,7 +21,7 @@ const meta: Meta<typeof XDSButton> = {
options: ['sm', 'md', 'lg'],
description: 'Size variant',
},
- loading: {
+ isLoading: {
control: 'boolean',
description: 'Loading state',
},
@@ -67,7 +67,7 @@ export const Loading: Story = {
args: {
label: 'Loading...',
variant: 'primary',
- loading: true,
+ isLoading: true,
},
};
@@ -141,10 +141,10 @@ export const AllVariants: Story = {
<XDSButton label="Destructive" variant="destructive" />
</div>
<div style={{display: 'flex', gap: '12px'}}>
- <XDSButton label="Loading..." variant="primary" loading />
- <XDSButton label="Loading..." variant="secondary" loading />
- <XDSButton label="Loading..." variant="ghost" loading />
- <XDSButton label="Loading..." variant="destructive" loading />
+ <XDSButton label="Loading..." variant="primary" isLoading />
+ <XDSButton label="Loading..." variant="secondary" isLoading />
+ <XDSButton label="Loading..." variant="ghost" isLoading />
+ <XDSButton label="Loading..." variant="destructive" isLoading />
</div>
<div style={{display: 'flex', gap: '12px'}}>
<XDSButton label="Disabled" variant="primary" isDisabled />
diff --git a/apps/storybook/stories/Center.stories.tsx b/apps/storybook/stories/Center.stories.tsx
index ecb8011b9d..6813afdced 100644
--- a/apps/storybook/stories/Center.stories.tsx
+++ b/apps/storybook/stories/Center.stories.tsx
@@ -61,7 +61,7 @@ const meta: Meta<typeof XDSCenter> = {
description:
'Height of the container (number for px, string for any unit)',
},
- inline: {
+ isInline: {
control: 'boolean',
description: 'Whether to render as inline-flex',
},
@@ -135,7 +135,7 @@ export const FullSize: Story = {
export const Inline: Story = {
args: {
- inline: true,
+ isInline: true,
children: null,
},
render: args => (
diff --git a/apps/storybook/stories/Link.stories.tsx b/apps/storybook/stories/Link.stories.tsx
index d63f429650..d346996964 100644
--- a/apps/storybook/stories/Link.stories.tsx
+++ b/apps/storybook/stories/Link.stories.tsx
@@ -43,7 +43,7 @@ const meta: Meta<typeof XDSLink> = {
control: 'text',
description: 'Tooltip text on hover',
},
- standalone: {
+ isStandalone: {
control: 'boolean',
description: 'Standalone (applies base font sizing)',
},
@@ -119,7 +119,7 @@ export const Standalone: Story = {
args: {
label: 'Standalone Link',
href: '/standalone',
- standalone: true,
+ isStandalone: true,
children: 'Standalone Link',
},
};
@@ -146,20 +146,20 @@ export const AllVariants: Story = {
maxWidth: '600px',
}}>
<div style={{display: 'flex', gap: '16px', alignItems: 'center'}}>
- <XDSLink label="Active (default)" href="/active" standalone>
+ <XDSLink label="Active (default)" href="/active" isStandalone>
Active (default)
</XDSLink>
- <XDSLink label="Primary" href="/primary" color="primary" standalone>
+ <XDSLink label="Primary" href="/primary" color="primary" isStandalone>
Primary
</XDSLink>
<XDSLink
label="Secondary"
href="/secondary"
color="secondary"
- standalone>
+ isStandalone>
Secondary
</XDSLink>
- <XDSLink label="Inherit" href="/inherit" color="inherit" standalone>
+ <XDSLink label="Inherit" href="/inherit" color="inherit" isStandalone>
Inherit
</XDSLink>
</div>
@@ -168,26 +168,30 @@ export const AllVariants: Story = {
label="With underline"
href="/underlined"
hasUnderline
- standalone>
+ isStandalone>
With underline
</XDSLink>
<XDSLink
label="External"
href="https://example.com"
isExternalLink
- standalone>
+ isStandalone>
External
</XDSLink>
<XDSLink
label="With tooltip"
href="/tooltip"
tooltip="Helpful info"
- standalone>
+ isStandalone>
With tooltip
</XDSLink>
</div>
<div style={{display: 'flex', gap: '16px', alignItems: 'center'}}>
- <XDSLink label="Disabled active" href="/disabled" isDisabled standalone>
+ <XDSLink
+ label="Disabled active"
+ href="/disabled"
+ isDisabled
+ isStandalone>
Disabled active
</XDSLink>
<XDSLink
@@ -195,7 +199,7 @@ export const AllVariants: Story = {
href="/disabled"
color="secondary"
isDisabled
- standalone>
+ isStandalone>
Disabled secondary
</XDSLink>
</div>
@@ -215,14 +219,14 @@ export const ExternalLinks: Story = {
label="GitHub"
href="https://github.com"
isExternalLink
- standalone>
+ isStandalone>
GitHub
</XDSLink>
<XDSLink
label="MDN Web Docs"
href="https://developer.mozilla.org"
isExternalLink
- standalone>
+ isStandalone>
MDN Web Docs
</XDSLink>
<XDSLink
@@ -230,7 +234,7 @@ export const ExternalLinks: Story = {
href="https://react.dev"
isExternalLink
hasUnderline
- standalone>
+ isStandalone>
React Documentation
</XDSLink>
</div>
@@ -244,14 +248,14 @@ export const LinksWithTooltips: Story = {
label="Settings"
href="/settings"
tooltip="Configure your account settings"
- standalone>
+ isStandalone>
Settings
</XDSLink>
<XDSLink
label="Profile"
href="/profile"
tooltip="View and edit your profile"
- standalone>
+ isStandalone>
Profile
</XDSLink>
<XDSLink
@@ -259,7 +263,7 @@ export const LinksWithTooltips: Story = {
href="/help"
tooltip="Get help and support"
color="secondary"
- standalone>
+ isStandalone>
Help
</XDSLink>
</div>
diff --git a/apps/storybook/stories/Table.stories.tsx b/apps/storybook/stories/Table.stories.tsx
index 1a44649a6b..ad4439da83 100644
--- a/apps/storybook/stories/Table.stories.tsx
+++ b/apps/storybook/stories/Table.stories.tsx
@@ -85,11 +85,11 @@ const meta: Meta<typeof XDSTable> = {
options: ['rows', 'columns', 'grid', 'none'],
description: 'Divider style between cells',
},
- striped: {
+ isStriped: {
control: 'boolean',
description: 'Alternate row background color',
},
- hover: {
+ hasHover: {
control: 'boolean',
description: 'Highlight rows on hover',
},
@@ -134,8 +134,8 @@ export const StripedWithHover: Story = {
data: users,
columns,
idKey: 'id',
- striped: true,
- hover: true,
+ isStriped: true,
+ hasHover: true,
},
};
@@ -173,7 +173,7 @@ export const AutoColumns: Story = {
{name: 'Alice', role: 'Engineer', status: 'Active'},
{name: 'Bob', role: 'Designer', status: 'Away'},
]}
- hover
+ hasHover
/>
),
};
@@ -217,13 +217,13 @@ export const CustomCellRenderer: Story = {
{key: 'age', header: 'Age', width: pixel(80)},
];
- return <XDSTable data={users} columns={cols} idKey="id" hover />;
+ return <XDSTable data={users} columns={cols} idKey="id" hasHover />;
},
};
export const ChildrenMode: Story = {
render: () => (
- <XDSTable density="balanced" dividers="rows" striped hover>
+ <XDSTable density="balanced" dividers="rows" isStriped hasHover>
<XDSTableRow>
<XDSTableCell>Alice</XDSTableCell>
<XDSTableCell>[email protected]</XDSTableCell>
@@ -289,7 +289,7 @@ export const KitchenSink: Story = {
idKey: 'id',
density: 'compact',
dividers: 'grid',
- striped: true,
- hover: true,
+ isStriped: true,
+ hasHover: true,
},
};
diff --git a/internal/eslint-plugin-xds/boolean-prop-naming.js b/internal/eslint-plugin-xds/boolean-prop-naming.js
new file mode 100644
index 0000000000..b9eef63ac8
--- /dev/null
+++ b/internal/eslint-plugin-xds/boolean-prop-naming.js
@@ -0,0 +1,185 @@
+/**
+ * @file boolean-prop-naming.js
+ * @description ESLint rule enforcing XDS boolean prop naming conventions.
+ *
+ * Boolean props in *Props interfaces/types must use:
+ * - `is` prefix for state/condition booleans (isDisabled, isRequired, isLoading)
+ * - `has` prefix for feature toggles (hasAutoFocus, hasClear, hasSeconds)
+ * - `initialIs` / `initialHas` for uncontrolled boolean defaults
+ *
+ * Exceptions:
+ * - aria-* and data-* attributes (follow their own conventions)
+ * - Properties in interfaces/types that don't end with "Props"
+ * - Union types containing boolean (e.g. boolean | string) — not purely boolean
+ */
+
+// Well-known native HTML boolean attributes that get a specific suggestion
+const NATIVE_BOOLEAN_SUGGESTIONS = {
+ disabled: 'isDisabled',
+ required: 'isRequired',
+ checked: 'isChecked',
+ readOnly: 'isReadOnly',
+ hidden: 'isHidden',
+ selected: 'isSelected',
+ open: 'isOpen',
+ loading: 'isLoading',
+ inline: 'isInline',
+ standalone: 'isStandalone',
+ striped: 'isStriped',
+ hover: 'hasHover',
+ wrap: 'hasWrap',
+};
+
+/**
+ * Check if a property name follows the boolean naming convention.
+ */
+function isValidBooleanPropName(name) {
+ return (
+ name.startsWith('is') ||
+ name.startsWith('has') ||
+ name.startsWith('initialIs') ||
+ name.startsWith('initialHas')
+ );
+}
+
+// Props that are excluded from the naming convention check.
+// These are either native HTML attributes or standard React controlled-component patterns.
+const EXCLUDED_PROP_NAMES = new Set([
+ 'value', // Controlled component value (can be boolean for toggles)
+ 'defaultValue', // Uncontrolled default value
+ 'defaultChecked', // Native HTML uncontrolled checkbox default
+]);
+
+/**
+ * Check if a property name should be excluded from the rule.
+ */
+function isExcludedPropName(name) {
+ return (
+ name.startsWith('aria-') ||
+ name.startsWith('data-') ||
+ EXCLUDED_PROP_NAMES.has(name)
+ );
+}
+
+/**
+ * Suggest a corrected name for a boolean prop.
+ */
+function suggestName(name) {
+ if (NATIVE_BOOLEAN_SUGGESTIONS[name]) {
+ return NATIVE_BOOLEAN_SUGGESTIONS[name];
+ }
+ // Default: prefix with "is" and capitalize
+ const capitalized = name.charAt(0).toUpperCase() + name.slice(1);
+ return `is${capitalized}`;
+}
+
+/**
+ * Check if a type annotation node is purely `boolean` (not a union like `boolean | string`).
+ */
+function isPureBooleanType(typeAnnotation) {
+ if (!typeAnnotation) return false;
+
+ // Direct boolean keyword: `prop: boolean`
+ if (typeAnnotation.type === 'TSBooleanKeyword') {
+ return true;
+ }
+
+ // Handle TSTypeAnnotation wrapper
+ if (typeAnnotation.type === 'TSTypeAnnotation') {
+ return isPureBooleanType(typeAnnotation.typeAnnotation);
+ }
+
+ return false;
+}
+
+/**
+ * Get the name of the enclosing interface or type alias, if it ends with "Props".
+ */
+function getEnclosingPropsName(node) {
+ let current = node.parent;
+ while (current) {
+ // Interface declaration: `interface XDSButtonProps { ... }`
+ if (current.type === 'TSInterfaceDeclaration') {
+ const name = current.id?.name;
+ if (name && name.endsWith('Props')) {
+ return name;
+ }
+ return null;
+ }
+ // Type alias: `type XDSButtonProps = { ... }`
+ if (current.type === 'TSTypeAliasDeclaration') {
+ const name = current.id?.name;
+ if (name && name.endsWith('Props')) {
+ return name;
+ }
+ return null;
+ }
+ current = current.parent;
+ }
+ return null;
+}
+
+const booleanPropNamingRule = {
+ meta: {
+ type: 'suggestion',
+ docs: {
+ description:
+ 'Enforce XDS boolean prop naming conventions (is/has prefix)',
+ category: 'Best Practices',
+ recommended: true,
+ },
+ messages: {
+ invalidBooleanPropName:
+ 'Boolean prop "{{name}}" in {{interfaceName}} should use "is" or "has" prefix. Suggested: "{{suggestion}}".',
+ },
+ hasSuggestions: true,
+ schema: [],
+ },
+ create(context) {
+ return {
+ TSPropertySignature(node) {
+ // Only check properties with a type annotation
+ if (!node.typeAnnotation) return;
+
+ // Only check purely boolean types (skip unions like boolean | string)
+ if (!isPureBooleanType(node.typeAnnotation)) return;
+
+ // Get property name
+ const propName = node.key?.name || node.key?.value;
+ if (!propName) return;
+
+ // Skip aria-* and data-* attributes
+ if (isExcludedPropName(propName)) return;
+
+ // Only apply to interfaces/types ending with "Props"
+ const interfaceName = getEnclosingPropsName(node);
+ if (!interfaceName) return;
+
+ // Check if the name follows convention
+ if (isValidBooleanPropName(propName)) return;
+
+ const suggestion = suggestName(propName);
+
+ context.report({
+ node: node.key,
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: propName,
+ interfaceName,
+ suggestion,
+ },
+ suggest: [
+ {
+ desc: `Rename to "${suggestion}"`,
+ fix(fixer) {
+ return fixer.replaceText(node.key, suggestion);
+ },
+ },
+ ],
+ });
+ },
+ };
+ },
+};
+
+export default booleanPropNamingRule;
diff --git a/internal/eslint-plugin-xds/boolean-prop-naming.test.mjs b/internal/eslint-plugin-xds/boolean-prop-naming.test.mjs
new file mode 100644
index 0000000000..9e86a8ce49
--- /dev/null
+++ b/internal/eslint-plugin-xds/boolean-prop-naming.test.mjs
@@ -0,0 +1,319 @@
+/**
+ * @file boolean-prop-naming.test.mjs
+ * @description Tests for the XDS boolean prop naming ESLint rule.
+ */
+
+import {describe, it} from 'vitest';
+import {RuleTester} from 'eslint';
+import tseslint from 'typescript-eslint';
+import booleanPropNamingRule from './boolean-prop-naming.js';
+
+const ruleTester = new RuleTester({
+ languageOptions: {
+ parser: tseslint.parser,
+ parserOptions: {
+ ecmaFeatures: {jsx: true},
+ },
+ },
+});
+
+describe('boolean-prop-naming', () => {
+ it('passes RuleTester valid/invalid cases', () => {
+ ruleTester.run('boolean-prop-naming', booleanPropNamingRule, {
+ valid: [
+ // ✅ Correct "is" prefix
+ {
+ code: `
+ interface XDSButtonProps {
+ isDisabled?: boolean;
+ }
+ `,
+ },
+ // ✅ Correct "has" prefix
+ {
+ code: `
+ interface XDSTextInputProps {
+ hasAutoFocus?: boolean;
+ }
+ `,
+ },
+ // ✅ Correct "initialIs" prefix
+ {
+ code: `
+ interface XDSDialogProps {
+ initialIsOpen?: boolean;
+ }
+ `,
+ },
+ // ✅ Correct "initialHas" prefix
+ {
+ code: `
+ interface XDSSelectorProps {
+ initialHasSelection?: boolean;
+ }
+ `,
+ },
+ // ✅ Non-boolean prop — should be ignored
+ {
+ code: `
+ interface XDSButtonProps {
+ label: string;
+ size?: 'sm' | 'md' | 'lg';
+ }
+ `,
+ },
+ // ✅ Boolean in non-Props interface — should be ignored
+ {
+ code: `
+ interface TableContextValue {
+ striped: boolean;
+ hover: boolean;
+ }
+ `,
+ },
+ // ✅ Boolean in non-Props type alias — should be ignored
+ {
+ code: `
+ type ItemData = {
+ disabled?: boolean;
+ };
+ `,
+ },
+ // ✅ Union type with boolean — should be ignored (not purely boolean)
+ {
+ code: `
+ interface XDSHeadingProps {
+ truncateTooltip?: boolean | string;
+ }
+ `,
+ },
+ // ✅ aria-* props — excluded
+ {
+ code: `
+ interface XDSButtonProps {
+ 'aria-pressed'?: boolean;
+ }
+ `,
+ },
+ // ✅ data-* props — excluded
+ {
+ code: `
+ interface XDSButtonProps {
+ 'data-active'?: boolean;
+ }
+ `,
+ },
+ // ✅ value prop — excluded (controlled component pattern)
+ {
+ code: `
+ interface XDSSwitchProps {
+ value: boolean;
+ }
+ `,
+ },
+ // ✅ defaultValue prop — excluded
+ {
+ code: `
+ interface XDSToggleProps {
+ defaultValue?: boolean;
+ }
+ `,
+ },
+ // ✅ Type alias with Props suffix — correct naming
+ {
+ code: `
+ type XDSCardProps = {
+ isFullBleed?: boolean;
+ };
+ `,
+ },
+ // ✅ Multiple valid props
+ {
+ code: `
+ interface XDSFieldProps {
+ isLabelHidden?: boolean;
+ isOptional?: boolean;
+ isRequired?: boolean;
+ isDisabled?: boolean;
+ hasAutoFocus?: boolean;
+ }
+ `,
+ },
+ ],
+
+ invalid: [
+ // ❌ Missing prefix — should suggest "isDisabled"
+ {
+ code: `
+ interface XDSButtonProps {
+ disabled?: boolean;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'disabled',
+ interfaceName: 'XDSButtonProps',
+ suggestion: 'isDisabled',
+ },
+ },
+ ],
+ },
+ // ❌ Missing prefix — should suggest "isLoading"
+ {
+ code: `
+ interface XDSButtonProps {
+ loading?: boolean;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'loading',
+ interfaceName: 'XDSButtonProps',
+ suggestion: 'isLoading',
+ },
+ },
+ ],
+ },
+ // ❌ Missing prefix — should suggest "isInline"
+ {
+ code: `
+ interface XDSCenterProps {
+ inline?: boolean;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'inline',
+ interfaceName: 'XDSCenterProps',
+ suggestion: 'isInline',
+ },
+ },
+ ],
+ },
+ // ❌ Missing prefix — should suggest "isStandalone"
+ {
+ code: `
+ interface XDSLinkProps {
+ standalone?: boolean;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'standalone',
+ interfaceName: 'XDSLinkProps',
+ suggestion: 'isStandalone',
+ },
+ },
+ ],
+ },
+ // ❌ Missing prefix in type alias
+ {
+ code: `
+ type XDSTableProps = {
+ striped?: boolean;
+ };
+ `,
+ errors: [
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'striped',
+ interfaceName: 'XDSTableProps',
+ suggestion: 'isStriped',
+ },
+ },
+ ],
+ },
+ // ❌ "required" should suggest "isRequired"
+ {
+ code: `
+ interface XDSFieldProps {
+ required?: boolean;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'required',
+ interfaceName: 'XDSFieldProps',
+ suggestion: 'isRequired',
+ },
+ },
+ ],
+ },
+ // ❌ "checked" should suggest "isChecked"
+ {
+ code: `
+ interface XDSCheckboxProps {
+ checked?: boolean;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'checked',
+ interfaceName: 'XDSCheckboxProps',
+ suggestion: 'isChecked',
+ },
+ },
+ ],
+ },
+ // ❌ Multiple violations in one interface
+ {
+ code: `
+ interface XDSTableProps {
+ striped?: boolean;
+ hover?: boolean;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'striped',
+ interfaceName: 'XDSTableProps',
+ suggestion: 'isStriped',
+ },
+ },
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'hover',
+ interfaceName: 'XDSTableProps',
+ suggestion: 'hasHover',
+ },
+ },
+ ],
+ },
+ // ❌ Unknown prop gets generic "is" prefix suggestion
+ {
+ code: `
+ interface XDSWidgetProps {
+ active?: boolean;
+ }
+ `,
+ errors: [
+ {
+ messageId: 'invalidBooleanPropName',
+ data: {
+ name: 'active',
+ interfaceName: 'XDSWidgetProps',
+ suggestion: 'isActive',
+ },
+ },
+ ],
+ },
+ ],
+ });
+ });
+});
diff --git a/internal/eslint-plugin-xds/index.js b/internal/eslint-plugin-xds/index.js
index 983ee0b991..9ccdead8bc 100644
--- a/internal/eslint-plugin-xds/index.js
+++ b/internal/eslint-plugin-xds/index.js
@@ -1,12 +1,18 @@
/**
* @file ESLint plugin for XDS design system
- * @description Enforces usage of design tokens instead of hardcoded values in StyleX
+ * @description Enforces usage of design tokens and XDS conventions
+ *
+ * Rules:
+ * - no-hardcoded-styles: Enforces usage of design tokens instead of hardcoded values in StyleX
+ * - boolean-prop-naming: Enforces is/has prefix on boolean props in *Props interfaces
*
* Philosophy: Strict for agents (CI), lenient for humans (local dev)
* - "strict" config: All rules as errors - use in CI/agent environments
* - "recommended" config: All rules as warnings - use for human development
*/
+import booleanPropNamingRule from './boolean-prop-naming.js';
+
// =============================================================================
// Rule: no-hardcoded-styles
// Detects hardcoded CSS values that should use XDS tokens
@@ -206,6 +212,7 @@ const plugin = {
},
rules: {
'no-hardcoded-styles': noHardcodedStylesRule,
+ 'boolean-prop-naming': booleanPropNamingRule,
},
configs: {},
};
@@ -217,6 +224,7 @@ plugin.configs.strict = {
},
rules: {
'@xds/no-hardcoded-styles': 'error',
+ '@xds/boolean-prop-naming': 'error',
},
};
@@ -227,6 +235,7 @@ plugin.configs.recommended = {
},
rules: {
'@xds/no-hardcoded-styles': 'warn',
+ '@xds/boolean-prop-naming': 'warn',
},
};
diff --git a/packages/core/src/Button/README.md b/packages/core/src/Button/README.md
index c7a95e3d89..4b80d07a93 100644
--- a/packages/core/src/Button/README.md
+++ b/packages/core/src/Button/README.md
@@ -1,6 +1,6 @@
# /packages/core/src/Button
-XDSButton component with multiple variants, sizes, and loading state support.
+XDSButton component with multiple variants, sizes, and isLoading state support.
<!-- SYNC: When files in this directory change, update this document. -->
@@ -23,8 +23,8 @@ import { XDSButton } from '@xds/core/Button';
// With size
<XDSButton label="Large button" variant="primary" size="lg" />
-// With loading state
-<XDSButton label="Saving..." variant="primary" loading />
+// With isLoading state
+<XDSButton label="Saving..." variant="primary" isLoading />
// Destructive action
<XDSButton label="Delete" variant="destructive" />
@@ -37,7 +37,7 @@ import { XDSButton } from '@xds/core/Button';
| `label` | `string` | — | Accessible label (required) |
| `variant` | `'primary' \| 'secondary' \| 'ghost' \| 'destructive'` | `'secondary'` | Visual style variant |
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size variant |
-| `loading` | `boolean` | `false` | Shows loading spinner |
+| `isLoading` | `boolean` | `false` | Shows isLoading spinner |
| `isDisabled` | `boolean` | `false` | Disables the button |
| `icon` | `ReactNode` | — | Icon element |
| `children` | `ReactNode` | — | Button content |
diff --git a/packages/core/src/Button/XDSButton.test.tsx b/packages/core/src/Button/XDSButton.test.tsx
index bdb7b933d4..14b1033728 100644
--- a/packages/core/src/Button/XDSButton.test.tsx
+++ b/packages/core/src/Button/XDSButton.test.tsx
@@ -59,8 +59,8 @@ describe('XDSButton', () => {
expect(screen.getByTestId('icon')).toBeInTheDocument();
});
- it('shows loading state with spinner', () => {
- render(<XDSButton label="Submit" loading />);
+ it('shows isLoading state with spinner', () => {
+ render(<XDSButton label="Submit" isLoading />);
const button = screen.getByRole('button');
// Button should be disabled when loading
expect(button).toBeDisabled();
@@ -87,7 +87,7 @@ describe('XDSButton', () => {
it('does not fire click when loading', async () => {
const user = userEvent.setup();
const handleClick = vi.fn();
- render(<XDSButton label="Click me" loading onClick={handleClick} />);
+ render(<XDSButton label="Click me" isLoading onClick={handleClick} />);
await user.click(screen.getByRole('button'));
expect(handleClick).not.toHaveBeenCalled();
diff --git a/packages/core/src/Button/XDSButton.tsx b/packages/core/src/Button/XDSButton.tsx
index 9de762b197..ba8dfab8dc 100644
--- a/packages/core/src/Button/XDSButton.tsx
+++ b/packages/core/src/Button/XDSButton.tsx
@@ -216,7 +216,7 @@ export interface XDSButtonProps extends Omit<
* Whether the button is in a loading state.
* @default false
*/
- loading?: boolean;
+ isLoading?: boolean;
/**
* Icon element to render in the button.
* If provided without children, button becomes icon-only (square).
@@ -293,7 +293,7 @@ export const XDSButton = forwardRef<HTMLButtonElement, XDSButtonProps>(
variant = 'secondary',
size = 'md',
isDisabled = false,
- loading = false,
+ isLoading = false,
icon,
children,
tooltip,
@@ -301,7 +301,7 @@ export const XDSButton = forwardRef<HTMLButtonElement, XDSButtonProps>(
},
ref,
): ReactElement => {
- const buttonDisabled = isDisabled || loading;
+ const buttonDisabled = isDisabled || isLoading;
const useLightSpinner = variant === 'primary' || variant === 'destructive';
const isIconOnly = icon != null && children == null;
@@ -322,10 +322,10 @@ export const XDSButton = forwardRef<HTMLButtonElement, XDSButtonProps>(
themeVariantOverride,
isIconOnly && styles.iconOnly,
buttonDisabled && styles.disabled,
- loading && loadingStyles.loading,
+ isLoading && loadingStyles.loading,
)}
{...props}>
- {loading && (
+ {isLoading && (
<span
{...stylex.props(
loadingStyles.spinner,
diff --git a/packages/core/src/Center/README.md b/packages/core/src/Center/README.md
index 3acb2bdad9..e0696d9382 100644
--- a/packages/core/src/Center/README.md
+++ b/packages/core/src/Center/README.md
@@ -22,7 +22,7 @@ import {XDSCenter} from '@xds/core/Center';
</XDSCenter>
// Inline centering for icons
-<XDSCenter inline>
+<XDSCenter isInline>
<XDSIcon icon={StarIcon} />
</XDSCenter>
```
diff --git a/packages/core/src/Center/XDSCenter.test.tsx b/packages/core/src/Center/XDSCenter.test.tsx
index 99a83a1d05..19b9717083 100644
--- a/packages/core/src/Center/XDSCenter.test.tsx
+++ b/packages/core/src/Center/XDSCenter.test.tsx
@@ -80,9 +80,9 @@ describe('XDSCenter', () => {
expect(element).toBeInTheDocument();
});
- it('renders as inline-flex when inline is true', () => {
+ it('renders as inline-flex when isInline is true', () => {
render(
- <XDSCenter inline data-testid="center">
+ <XDSCenter isInline data-testid="center">
<div>Inline Content</div>
</XDSCenter>,
);
diff --git a/packages/core/src/Center/XDSCenter.tsx b/packages/core/src/Center/XDSCenter.tsx
index a11f0cdaed..d9e9350e0b 100644
--- a/packages/core/src/Center/XDSCenter.tsx
+++ b/packages/core/src/Center/XDSCenter.tsx
@@ -69,7 +69,7 @@ export interface XDSCenterProps extends Omit<
* Whether to make the container inline-flex (useful for text/icons).
* @default false
*/
- inline?: boolean;
+ isInline?: boolean;
/**
* Content to render inside the center container.
@@ -97,11 +97,19 @@ export interface XDSCenterProps extends Omit<
*/
export const XDSCenter = forwardRef<HTMLDivElement, XDSCenterProps>(
function XDSCenter(
- {axis = 'both', width, height, inline = false, children, xstyle, ...props},
+ {
+ axis = 'both',
+ width,
+ height,
+ isInline = false,
+ children,
+ xstyle,
+ ...props
+ },
ref,
) {
const stylexProps = stylex.props(
- inline ? styles.inline : styles.base,
+ isInline ? styles.inline : styles.base,
(axis === 'both' || axis === 'vertical') && styles.alignItemsCenter,
(axis === 'both' || axis === 'horizontal') && styles.justifyContentCenter,
dynamicStyles.sizing(width ?? null, height ?? null),
diff --git a/packages/core/src/Link/README.md b/packages/core/src/Link/README.md
index a1cff49a2e..cd02c4aff5 100644
--- a/packages/core/src/Link/README.md
+++ b/packages/core/src/Link/README.md
@@ -38,7 +38,7 @@ import { XDSLink } from '@xds/core/Link';
<XDSText>Read the <XDSLink label="docs" href="/docs">documentation</XDSLink> for more info.</XDSText>
// Standalone link
-<XDSLink label="Settings" href="/settings" standalone>Settings</XDSLink>
+<XDSLink label="Settings" href="/settings" isStandalone>Settings</XDSLink>
// Subtle variant
<XDSLink label="Privacy" href="/privacy" variant="subtle">Privacy Policy</XDSLink>
@@ -60,7 +60,7 @@ import { XDSLink } from '@xds/core/Link';
| `target` | `string` | — | Where to open linked document |
| `onClick` | `MouseEventHandler` | — | Click event handler |
| `tooltip` | `string` | — | Tooltip text displayed on hover |
-| `standalone` | `boolean` | `false` | Applies base font sizing |
+| `isStandalone` | `boolean` | `false` | Applies base font sizing |
| `children` | `ReactNode` | — | Link content (required) |
## Files
@@ -75,7 +75,7 @@ import { XDSLink } from '@xds/core/Link';
- `XDSLinkVariant` type is derived from the `variants` StyleX object using `keyof typeof variants`
- By default, links inherit font family, size, line-height, and weight from parent elements
-- Use `standalone` prop when the link is not inline within other text content
+- Use `isStandalone` prop when the link is not inline within other text content
- `isExternalLink` automatically sets `target="_blank"` and `rel="noopener noreferrer"` for security
- Disabled state uses `aria-disabled` and `pointer-events: none` for accessibility
- Tooltip wraps the link in `XDSTooltip` component when provided
diff --git a/packages/core/src/Link/XDSLink.test.tsx b/packages/core/src/Link/XDSLink.test.tsx
index 5dbef1df66..32b30fb4bc 100644
--- a/packages/core/src/Link/XDSLink.test.tsx
+++ b/packages/core/src/Link/XDSLink.test.tsx
@@ -148,7 +148,7 @@ describe('XDSLink', () => {
it('renders standalone link', () => {
render(
- <XDSLink label="Standalone Link" href="/standalone" standalone>
+ <XDSLink label="Standalone Link" href="/standalone" isStandalone>
Standalone Link
</XDSLink>,
);
diff --git a/packages/core/src/Link/XDSLink.tsx b/packages/core/src/Link/XDSLink.tsx
index e70e518987..b6e0f69c8d 100644
--- a/packages/core/src/Link/XDSLink.tsx
+++ b/packages/core/src/Link/XDSLink.tsx
@@ -127,7 +127,7 @@ export interface XDSLinkProps extends Omit<
* Applies base font sizing when true.
* @default false
*/
- standalone?: boolean;
+ isStandalone?: boolean;
/**
* Semantic text type for XDSText. Determines base typography.
* @default 'body'
@@ -194,7 +194,7 @@ export const XDSLink = forwardRef<HTMLAnchorElement, XDSLinkProps>(
target,
onClick,
tooltip,
- standalone = false,
+ isStandalone = false,
type = 'body',
size,
weight,
@@ -228,7 +228,7 @@ export const XDSLink = forwardRef<HTMLAnchorElement, XDSLinkProps>(
{...stylex.props(
styles.base,
hasUnderline && styles.hasUnderline,
- standalone && styles.standalone,
+ isStandalone && styles.standalone,
isDisabled && styles.disabled,
)}
{...props}>
diff --git a/packages/core/src/Table/README.md b/packages/core/src/Table/README.md
index 01065b41c2..af897b9aa4 100644
--- a/packages/core/src/Table/README.md
+++ b/packages/core/src/Table/README.md
@@ -6,13 +6,13 @@ Table components for the XDS design system.
## Components
-| File | Export | Purpose |
-| -------------------- | ----------------- | ------------------------------------------------------------ |
-| `XDSTable.tsx` | `XDSTable` | Styled, data-driven table with density, dividers, and hover |
-| `XDSBaseTable.tsx` | `XDSBaseTable` | Unstyled table with colgroup, plugin pipeline, children mode |
-| `XDSTableRow.tsx` | `XDSTableRow` | Thin `<tr>` wrapper for XDSTable children/streaming mode |
-| `XDSTableCell.tsx` | `XDSTableCell` | Thin `<td>` wrapper for XDSTable children/streaming mode |
-| `XDSTableContext.ts` | `XDSTableContext` | Context for passing styling props to row/cell components |
+| File | Export | Purpose |
+| -------------------- | ----------------- | -------------------------------------------------------------- |
+| `XDSTable.tsx` | `XDSTable` | Styled, data-driven table with density, dividers, and hasHover |
+| `XDSBaseTable.tsx` | `XDSBaseTable` | Unstyled table with colgroup, plugin pipeline, children mode |
+| `XDSTableRow.tsx` | `XDSTableRow` | Thin `<tr>` wrapper for XDSTable children/streaming mode |
+| `XDSTableCell.tsx` | `XDSTableCell` | Thin `<td>` wrapper for XDSTable children/streaming mode |
+| `XDSTableContext.ts` | `XDSTableContext` | Context for passing styling props to row/cell components |
## Utilities
@@ -46,7 +46,7 @@ Table components for the XDS design system.
]}
density="balanced"
dividers="rows"
- hover
+ hasHover
/>
```
@@ -54,13 +54,13 @@ Table components for the XDS design system.
```tsx
// Columns auto-generated from data keys with capitalized headers
-<XDSTable data={users} striped />
+<XDSTable data={users} isStriped />
```
### Children mode
```tsx
-<XDSTable density="balanced" dividers="rows" striped hover>
+<XDSTable density="balanced" dividers="rows" isStriped hasHover>
<XDSTableRow>
<XDSTableCell>Alice</XDSTableCell>
<XDSTableCell>30</XDSTableCell>
@@ -85,7 +85,7 @@ const highlightPlugin: TablePlugin<User> = {
## Architecture
-Two-layer design: **XDSBaseTable** provides unstyled structure and the plugin pipeline. **XDSTable** wraps it and injects a styling plugin built from appearance props (`density`, `dividers`, `striped`, `hover`). This validates the plugin API by dogfooding it.
+Two-layer design: **XDSBaseTable** provides unstyled structure and the plugin pipeline. **XDSTable** wraps it and injects a styling plugin built from appearance props (`density`, `dividers`, `isStriped`, `hasHover`). This validates the plugin API by dogfooding it.
## Related Files
diff --git a/packages/core/src/Table/XDSTable.test.tsx b/packages/core/src/Table/XDSTable.test.tsx
index 333aa46175..2f9e46446c 100644
--- a/packages/core/src/Table/XDSTable.test.tsx
+++ b/packages/core/src/Table/XDSTable.test.tsx
@@ -490,15 +490,15 @@ describe('XDSTable', () => {
});
describe('striped', () => {
- it('renders with striped rows', () => {
- render(<XDSTable data={users} columns={columns} striped />);
+ it('renders with isStriped rows', () => {
+ render(<XDSTable data={users} columns={columns} isStriped />);
expect(screen.getAllByRole('row')).toHaveLength(4);
});
});
describe('hover', () => {
- it('renders with hover enabled', () => {
- render(<XDSTable data={users} columns={columns} hover />);
+ it('renders with hasHover enabled', () => {
+ render(<XDSTable data={users} columns={columns} hasHover />);
expect(screen.getAllByRole('row')).toHaveLength(4);
});
});
@@ -510,8 +510,8 @@ describe('XDSTable', () => {
columns={columns}
density="compact"
dividers="grid"
- striped
- hover
+ isStriped
+ hasHover
/>,
);
expect(screen.getByRole('table')).toBeInTheDocument();
diff --git a/packages/core/src/Table/XDSTable.tsx b/packages/core/src/Table/XDSTable.tsx
index 1eff123eb8..565f4630ff 100644
--- a/packages/core/src/Table/XDSTable.tsx
+++ b/packages/core/src/Table/XDSTable.tsx
@@ -52,9 +52,9 @@ export interface XDSTableProps<
/** Divider style. @default 'rows' */
dividers?: XDSTableDividers;
/** Striped even rows. @default false */
- striped?: boolean;
+ isStriped?: boolean;
/** Hover highlight on rows. @default false */
- hover?: boolean;
+ hasHover?: boolean;
}
// =============================================================================
@@ -167,8 +167,8 @@ function XDSTableInner<T extends Record<string, unknown>>(
{
density = 'balanced',
dividers = 'rows',
- striped = false,
- hover = false,
+ isStriped = false,
+ hasHover = false,
plugins: userPlugins,
columns,
data,
@@ -192,8 +192,8 @@ function XDSTableInner<T extends Record<string, unknown>>(
);
const contextValue = useMemo(
- () => ({density, dividers, striped, hover}),
- [density, dividers, striped, hover],
+ () => ({density, dividers, isStriped, hasHover}),
+ [density, dividers, isStriped, hasHover],
);
return (
@@ -225,8 +225,8 @@ function XDSTableInner<T extends Record<string, unknown>>(
* ]}
* density="compact"
* dividers="grid"
- * striped
- * hover
+ * isStriped
+ * hasHover
* />
* ```
*/
diff --git a/packages/core/src/Table/XDSTableContext.ts b/packages/core/src/Table/XDSTableContext.ts
index 931a8ff2dc..22b2dbdf3f 100644
--- a/packages/core/src/Table/XDSTableContext.ts
+++ b/packages/core/src/Table/XDSTableContext.ts
@@ -16,8 +16,8 @@ import {createContext} from 'react';
export interface XDSTableContextValue {
density: 'compact' | 'balanced' | 'spacious';
dividers: 'rows' | 'columns' | 'grid' | 'none';
- striped: boolean;
- hover: boolean;
+ isStriped: boolean;
+ hasHover: boolean;
}
export const XDSTableContext = createContext<XDSTableContextValue | null>(null);
diff --git a/packages/core/src/Table/XDSTableRow.tsx b/packages/core/src/Table/XDSTableRow.tsx
index 6b53691633..95d90dddc2 100644
--- a/packages/core/src/Table/XDSTableRow.tsx
+++ b/packages/core/src/Table/XDSTableRow.tsx
@@ -97,11 +97,11 @@ export const XDSTableRow = forwardRef<HTMLTableRowElement, XDSTableRowProps>(
const rowStyles: StyleXStyles[] = [];
// Handle striped + hover combination to avoid backgroundColor conflicts
- if (ctx.striped && ctx.hover) {
+ if (ctx.isStriped && ctx.hasHover) {
rowStyles.push(stripedHoverRowStyles.row);
- } else if (ctx.striped) {
+ } else if (ctx.isStriped) {
rowStyles.push(stripedRowStyles.row);
- } else if (ctx.hover) {
+ } else if (ctx.hasHover) {
rowStyles.push(hoverRowStyles.row);
}
diff --git a/vitest.config.ts b/vitest.config.ts
index 40488e6cb1..a47a8d7784 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -7,7 +7,7 @@
* SYNC: When modified, update this header and root README.md
*/
-import { defineConfig } from 'vitest/config';
+import {defineConfig} from 'vitest/config';
import react from '@vitejs/plugin-react';
export default defineConfig({
@@ -35,16 +35,15 @@ export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
- include: ['packages/**/src/**/*.test.{ts,tsx,mjs}'],
+ include: [
+ 'packages/**/src/**/*.test.{ts,tsx,mjs}',
+ 'internal/**/*.test.{ts,tsx,mjs}',
+ ],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
include: ['packages/**/src/**/*.{ts,tsx}'],
- exclude: [
- '**/*.test.{ts,tsx}',
- '**/*.stories.{ts,tsx}',
- '**/index.ts',
- ],
+ exclude: ['**/*.test.{ts,tsx}', '**/*.stories.{ts,tsx}', '**/index.ts'],
},
setupFiles: ['./internal/test-utils/src/setup.ts'],
},