Skip to content

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

TypeScript

fix(sandbox): restore StyleX babel config and globals.css (#602)

Cindy Zhang376f6fadefce
diff --git a/apps/sandbox/babel.config.js b/apps/sandbox/babel.config.js
index 6e08df0bbb..148027555d 100644
--- a/apps/sandbox/babel.config.js
+++ b/apps/sandbox/babel.config.js
@@ -1,9 +1,23 @@
-/* global module */
+/* global module, process, __dirname */
+const path = require('path');
+
+const rootDir = path.resolve(__dirname, '../..');
-/**
- * Sandbox uses pre-compiled dist — no StyleX plugin needed.
- * Component styles come from @xds/core/dist/xds.css.
- */
module.exports = {
presets: ['next/babel'],
+ plugins: [
+ [
+ '@stylexjs/babel-plugin',
+ {
+ dev: process.env.NODE_ENV === 'development',
+ runtimeInjection: false,
+ genConditionalClasses: true,
+ treeshakeCompensation: true,
+ unstable_moduleResolution: {
+ type: 'commonJS',
+ rootDir,
+ },
+ },
+ ],
+ ],
};
diff --git a/apps/sandbox/src/app/globals.css b/apps/sandbox/src/app/globals.css
index 953d4f0c15..867d14b250 100644
--- a/apps/sandbox/src/app/globals.css
+++ b/apps/sandbox/src/app/globals.css
@@ -1 +1 @@
-/* Sandbox global styles */
+@stylex;
diff --git a/apps/sandbox/src/app/pages/example/page.tsx b/apps/sandbox/src/app/pages/example/page.tsx
index 1812680c21..51bf42d082 100644
--- a/apps/sandbox/src/app/pages/example/page.tsx
+++ b/apps/sandbox/src/app/pages/example/page.tsx
@@ -9,12 +9,13 @@ import {XDSTextInput} from '@xds/core/TextInput';
import {XDSCheckboxInput} from '@xds/core/CheckboxInput';
import {XDSBadge} from '@xds/core/Badge';
import {XDSDivider} from '@xds/core';
+import * as stylex from '@stylexjs/stylex';
-const styles = {
+const styles = stylex.create({
container: {
maxWidth: 640,
},
-};
+});
/**
* Example sandbox page.
@@ -30,7 +31,7 @@ export default function ExamplePage() {
const [updates, setUpdates] = useState(false);
return (
- <div style={styles.container}>
+ <div {...stylex.props(styles.container)}>
<XDSVStack gap={6}>
<XDSVStack gap={2}>
<XDSHeading level={1}>Example Page</XDSHeading>
diff --git a/apps/sandbox/src/app/pages/mega-menu/page.tsx b/apps/sandbox/src/app/pages/mega-menu/page.tsx
index 1594ee29c0..b1003e245d 100644
--- a/apps/sandbox/src/app/pages/mega-menu/page.tsx
+++ b/apps/sandbox/src/app/pages/mega-menu/page.tsx
@@ -1,6 +1,7 @@
'use client';
import {useState} from 'react';
+import * as stylex from '@stylexjs/stylex';
import {XDSVStack} from '@xds/core/Layout';
import {XDSText, XDSHeading} from '@xds/core/Text';
@@ -13,7 +14,7 @@ import {
} from '@xds/core/TopNav';
import {XDSNavIcon} from '@xds/core/NavIcon';
-const styles = {
+const styles = stylex.create({
container: {
maxWidth: 960,
},
@@ -37,7 +38,7 @@ const styles = {
boxShadow:
'0 -1px 3px rgba(0, 0, 0, 0.06), -1px 0 3px rgba(0, 0, 0, 0.04), 1px 0 3px rgba(0, 0, 0, 0.04)',
},
-};
+});
// =============================================================================
// Icons
@@ -234,7 +235,7 @@ export default function MegaMenuPage() {
const isAnyOpen1 = menuOpen1 || menuOpen2;
return (
- <div style={styles.container}>
+ <div {...stylex.props(styles.container)}>
<XDSVStack gap={6}>
<XDSVStack gap={2}>
<XDSHeading level={1}>Mega Menu</XDSHeading>
@@ -248,7 +249,7 @@ export default function MegaMenuPage() {
{/* Full mega menu with featured content */}
<XDSVStack gap={3}>
<XDSHeading level={2}>With Featured Content</XDSHeading>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<XDSTopNav
label="Marketing navigation"
heading={
@@ -303,7 +304,7 @@ export default function MegaMenuPage() {
{/* Without featured content */}
<XDSVStack gap={3}>
<XDSHeading level={2}>Without Featured Content</XDSHeading>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<XDSTopNav
label="Simple navigation"
heading={<XDSTopNavHeading heading="App" href="#" />}
diff --git a/apps/sandbox/src/app/pages/navigation/page.tsx b/apps/sandbox/src/app/pages/navigation/page.tsx
index 92efc39b3d..ca510c67d2 100644
--- a/apps/sandbox/src/app/pages/navigation/page.tsx
+++ b/apps/sandbox/src/app/pages/navigation/page.tsx
@@ -7,8 +7,9 @@ import {XDSText, XDSHeading} from '@xds/core/Text';
import {XDSButton} from '@xds/core/Button';
import {XDSDivider} from '@xds/core';
import {XDSTopNav, XDSTopNavHeading, XDSTopNavItem} from '@xds/core/TopNav';
+import * as stylex from '@stylexjs/stylex';
-const styles = {
+const styles = stylex.create({
container: {
maxWidth: 960,
},
@@ -17,7 +18,7 @@ const styles = {
borderRadius: 8,
overflow: 'hidden',
},
-};
+});
type Alignment = 'start' | 'center' | 'end';
@@ -31,7 +32,7 @@ export default function NavigationPage() {
const [alignment, setAlignment] = useState<Alignment>('start');
return (
- <div style={styles.container}>
+ <div {...stylex.props(styles.container)}>
<XDSVStack gap={6}>
<XDSVStack gap={2}>
<XDSHeading level={1}>Navigation Alignment</XDSHeading>
@@ -71,7 +72,7 @@ export default function NavigationPage() {
{/* Live preview */}
<XDSVStack gap={3}>
<XDSHeading level={2}>Preview</XDSHeading>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<NavPreview alignment={alignment} />
</div>
</XDSVStack>
@@ -86,7 +87,7 @@ export default function NavigationPage() {
<XDSText type="supporting" weight="bold">
Left-aligned (startContent)
</XDSText>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<NavPreview alignment="start" />
</div>
</XDSVStack>
@@ -95,7 +96,7 @@ export default function NavigationPage() {
<XDSText type="supporting" weight="bold">
Center-aligned (centerContent)
</XDSText>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<NavPreview alignment="center" />
</div>
</XDSVStack>
@@ -104,7 +105,7 @@ export default function NavigationPage() {
<XDSText type="supporting" weight="bold">
Right-aligned (endContent)
</XDSText>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<NavPreview alignment="end" />
</div>
</XDSVStack>
diff --git a/apps/sandbox/src/app/pages/polymorphic-link/page.tsx b/apps/sandbox/src/app/pages/polymorphic-link/page.tsx
index 65f66fbde3..c15b24fff4 100644
--- a/apps/sandbox/src/app/pages/polymorphic-link/page.tsx
+++ b/apps/sandbox/src/app/pages/polymorphic-link/page.tsx
@@ -15,12 +15,13 @@ import {XDSSideNav, XDSSideNavItem} from '@xds/core/SideNav';
import {XDSBreadcrumbs, XDSBreadcrumbItem} from '@xds/core/Breadcrumbs';
import {XDSTabList, XDSTab} from '@xds/core/TabList';
import {XDSLink, XDSLinkProvider} from '@xds/core/Link';
+import * as stylex from '@stylexjs/stylex';
// =============================================================================
// Simulated framework link components
// =============================================================================
-const styles = {
+const styles = stylex.create({
container: {
maxWidth: 960,
},
@@ -49,7 +50,7 @@ const styles = {
borderRadius: 8,
overflow: 'hidden',
},
-};
+});
/**
* Simulated Next.js-like Link for demo purposes.
@@ -70,7 +71,7 @@ const SimulatedNextLink = forwardRef<
console.log(`[SimulatedNextLink] Client-side navigate to: ${href}`);
onClick?.(e);
}}
- style={styles.customLinkIndicator}
+ {...stylex.props(styles.customLinkIndicator)}
{...props}>
{children}
</a>
@@ -110,7 +111,7 @@ export default function PolymorphicLinkPage() {
const [tab, setTab] = useState('overview');
return (
- <div style={styles.container}>
+ <div {...stylex.props(styles.container)}>
<XDSVStack gap={6}>
<XDSVStack gap={2}>
<XDSHeading level={1}>Polymorphic Link</XDSHeading>
@@ -148,7 +149,7 @@ export default function PolymorphicLinkPage() {
<XDSText type="supporting" weight="bold">
XDSTopNav
</XDSText>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<XDSTopNav
label="Provider demo navigation"
heading={<XDSTopNavHeading heading="My App" />}
@@ -194,7 +195,7 @@ export default function PolymorphicLinkPage() {
<XDSText type="supporting" weight="bold">
XDSSideNav
</XDSText>
- <div style={styles.sidenavWrapper}>
+ <div {...stylex.props(styles.sidenavWrapper)}>
<XDSSideNav aria-label="Provider sidenav">
<XDSSideNavItem
label="Dashboard"
@@ -242,7 +243,7 @@ export default function PolymorphicLinkPage() {
</XDSText>
<XDSLinkProvider component={SimulatedNextLink}>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<XDSTopNav
label="Override demo navigation"
heading={<XDSTopNavHeading heading="Override Demo" />}
@@ -277,7 +278,7 @@ export default function PolymorphicLinkPage() {
prop, components render native {'<a>'} elements as usual.
</XDSText>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<XDSTopNav
label="Default navigation"
heading={<XDSTopNavHeading heading="Default" />}
diff --git a/apps/sandbox/src/app/pages/shell-lab/page.tsx b/apps/sandbox/src/app/pages/shell-lab/page.tsx
index 9d30ffe17a..efcbbfce53 100644
--- a/apps/sandbox/src/app/pages/shell-lab/page.tsx
+++ b/apps/sandbox/src/app/pages/shell-lab/page.tsx
@@ -1,6 +1,7 @@
'use client';
import {useState, useCallback} from 'react';
+import * as stylex from '@stylexjs/stylex';
import {XDSAppShell} from '@xds/core/AppShell';
import {
@@ -33,9 +34,9 @@ import {XDSBanner} from '@xds/core/Banner';
// =============================================================================
interface ShellConfig {
- background: 'wash' | 'surface';
+ variant: 'wash' | 'surface' | 'section' | 'elevated';
height: 'fill' | 'auto';
- sideNavBreakpoint: 'sm' | 'md' | 'lg' | 'xl';
+ sideNavBreakpoint: 'sm' | 'md' | 'lg' | 'none';
sideNavWidth: number;
showSideNav: boolean;
showTopNav: boolean;
@@ -55,7 +56,7 @@ interface ShellConfig {
}
const DEFAULT_CONFIG: ShellConfig = {
- background: 'wash',
+ variant: 'section',
height: 'fill',
sideNavBreakpoint: 'md',
sideNavWidth: 260,
@@ -89,7 +90,7 @@ function ConfigPanel({
}) {
return (
<XDSCard>
- <XDSVStack gap={5} padding={4}>
+ <XDSVStack gap={5} xstyle={styles.padding4}>
<XDSHeading level={3}>Shell Configuration</XDSHeading>
{/* AppShell */}
@@ -98,9 +99,9 @@ function ConfigPanel({
AppShell
</XDSText>
<SelectorRow
- label="Background"
- value={config.background}
- onChange={v => onChange({background: v as 'wash' | 'surface'})}
+ label="Variant"
+ value={config.variant}
+ onChange={v => onChange({variant: v as 'wash' | 'surface' | 'section' | 'elevated'})}
options={[
{value: 'wash', label: 'Wash'},
{value: 'surface', label: 'Surface'},
@@ -119,13 +120,13 @@ function ConfigPanel({
label="Breakpoint"
value={config.sideNavBreakpoint}
onChange={v =>
- onChange({sideNavBreakpoint: v as 'sm' | 'md' | 'lg' | 'xl'})
+ onChange({sideNavBreakpoint: v as 'sm' | 'md' | 'lg' | 'none'})
}
options={[
{value: 'sm', label: 'sm'},
{value: 'md', label: 'md'},
{value: 'lg', label: 'lg'},
- {value: 'xl', label: 'xl'},
+ {value: 'none', label: 'none'},
]}
/>
</XDSVStack>
@@ -393,7 +394,7 @@ function SampleSideNav({config}: {config: ShellConfig}) {
</>
) : undefined
}>
- <XDSSideNavSection heading="Navigation">
+ <XDSSideNavSection title="Navigation">
<XDSSideNavItem label="Dashboard" isSelected href="#" />
<XDSSideNavItem
label="Projects"
@@ -409,7 +410,7 @@ function SampleSideNav({config}: {config: ShellConfig}) {
</XDSSideNavItem>
)}
</XDSSideNavSection>
- <XDSSideNavSection heading="Resources">
+ <XDSSideNavSection title="Resources">
<XDSSideNavItem label="Documentation" href="#" />
<XDSSideNavItem label="API Reference" href="#" />
<XDSSideNavItem label="Support" href="#" />
@@ -532,15 +533,14 @@ function SampleTopNav({config}: {config: ShellConfig}) {
// Main Page
// =============================================================================
-// Inline styles (sandbox uses dist, no StyleX build)
-const pageStyles = {
+const styles = stylex.create({
configOverlay: {
- position: 'fixed' as const,
+ position: 'fixed',
top: 16,
right: 16,
width: 360,
maxHeight: 'calc(100vh - 32px)',
- overflowY: 'auto' as const,
+ overflowY: 'auto',
zIndex: 1000,
},
content: {
@@ -548,12 +548,15 @@ const pageStyles = {
maxWidth: 800,
},
toggleButton: {
- position: 'fixed' as const,
+ position: 'fixed',
bottom: 16,
right: 16,
zIndex: 1001,
},
-};
+ padding4: {
+ padding: 16,
+ },
+});
export default function ShellLabPage() {
const [config, setConfig] = useState<ShellConfig>(DEFAULT_CONFIG);
@@ -579,7 +582,7 @@ export default function ShellLabPage() {
onOpenChange={setIsMobileNavOpen}
title="Navigation"
side={config.mobileNavSide}>
- <XDSSideNavSection heading="Navigation">
+ <XDSSideNavSection title="Navigation">
<XDSSideNavItem label="Dashboard" isSelected href="#" />
<XDSSideNavItem label="Projects" href="#" />
<XDSSideNavItem label="Messages" href="#" />
@@ -592,7 +595,7 @@ export default function ShellLabPage() {
return (
<>
<XDSAppShell
- background={config.background}
+ variant={config.variant}
height={config.height}
sideNavBreakpoint={config.sideNavBreakpoint}
sideNavWidth={config.sideNavWidth}
@@ -614,7 +617,7 @@ export default function ShellLabPage() {
) : undefined
}
{...collapseProps}>
- <div style={pageStyles.content}>
+ <div {...stylex.props(styles.content)}>
<XDSVStack gap={6}>
<XDSVStack gap={2}>
<XDSHeading level={1}>Shell Lab</XDSHeading>
@@ -626,7 +629,7 @@ export default function ShellLabPage() {
</XDSVStack>
<XDSCard>
- <XDSVStack gap={3} padding={4}>
+ <XDSVStack gap={3} xstyle={styles.padding4}>
<XDSHeading level={3}>Active Config</XDSHeading>
<pre
style={{
@@ -643,7 +646,7 @@ export default function ShellLabPage() {
{Array.from({length: 10}, (_, i) => (
<XDSCard key={i}>
- <XDSVStack gap={2} padding={4}>
+ <XDSVStack gap={2} xstyle={styles.padding4}>
<XDSHeading level={4}>Content Block {i + 1}</XDSHeading>
<XDSText type="body" color="secondary">
Sample content to test scroll behavior in fill vs auto
@@ -659,13 +662,13 @@ export default function ShellLabPage() {
{/* Floating config panel */}
{showConfig && (
- <div style={pageStyles.configOverlay}>
+ <div {...stylex.props(styles.configOverlay)}>
<ConfigPanel config={config} onChange={handleConfigChange} />
</div>
)}
{/* Toggle config visibility */}
- <div style={pageStyles.toggleButton}>
+ <div {...stylex.props(styles.toggleButton)}>
<button
onClick={() => setShowConfig(v => !v)}
style={{
diff --git a/apps/sandbox/src/app/pages/table-overview/page.tsx b/apps/sandbox/src/app/pages/table-overview/page.tsx
index 0f0b37f3b9..f60584df09 100644
--- a/apps/sandbox/src/app/pages/table-overview/page.tsx
+++ b/apps/sandbox/src/app/pages/table-overview/page.tsx
@@ -18,6 +18,7 @@ import {XDSBadge} from '@xds/core/Badge';
import type {XDSBadgeVariant} from '@xds/core/Badge';
import {XDSStatusDot} from '@xds/core/StatusDot';
import {XDSCollapsible} from '@xds/core/Collapsible';
+import * as stylex from '@stylexjs/stylex';
// =============================================================================
// Types
@@ -209,7 +210,7 @@ function StatCard({
}) {
return (
<XDSCard>
- <div style={styles.statCard}>
+ <div {...stylex.props(styles.statCard)}>
<XDSText type="supporting" color="secondary">
{emoji ? `${emoji} ` : ''}
{label}
@@ -238,10 +239,10 @@ const columns: XDSTableColumn<ReviewRow>[] = [
name={item.authorName}
size="small"
/>
- <div style={styles.authorInfo}>
+ <div {...stylex.props(styles.authorInfo)}>
<XDSVStack gap={1}>
- <span style={styles.titleLink}>{item.title}</span>
- <span style={styles.supportingLine}>
+ <span {...stylex.props(styles.titleLink)}>{item.title}</span>
+ <span {...stylex.props(styles.supportingLine)}>
<XDSText type="supporting" color="secondary">
{item.diffId} · {item.lines} lines {item.reviewTime}
</XDSText>
@@ -256,11 +257,11 @@ const columns: XDSTableColumn<ReviewRow>[] = [
header: 'Reviewers',
width: pixel(120),
renderCell: (item: ReviewRow) => (
- <div style={styles.avatarGroup}>
+ <div {...stylex.props(styles.avatarGroup)}>
{item.reviewerAvatars.map((src: string, i: number) => (
<div
key={i}
- style={styles.avatarOverlap}
+ {...stylex.props(styles.avatarOverlap)}
style={{
marginLeft: i > 0 ? -8 : 0,
zIndex: item.reviewerAvatars.length - i,
@@ -313,7 +314,7 @@ const columns: XDSTableColumn<ReviewRow>[] = [
// Styles
// =============================================================================
-const styles = {
+const styles = stylex.create({
container: {
maxWidth: 1100,
width: '100%',
@@ -356,7 +357,7 @@ const styles = {
position: 'relative',
display: 'inline-flex',
},
-};
+});
// =============================================================================
// Section Table (table within a collapsible)
@@ -450,7 +451,7 @@ export default function TableOverviewPage() {
const filteredAccepted = filterRows(acceptedAndReady);
return (
- <div style={styles.container}>
+ <div {...stylex.props(styles.container)}>
<XDSVStack gap={6}>
<XDSVStack gap={2}>
<XDSHeading level={1}>Table Overview</XDSHeading>
@@ -470,7 +471,7 @@ export default function TableOverviewPage() {
/>
{/* Stats Row */}
- <div style={styles.statsRow}>
+ <div {...stylex.props(styles.statsRow)}>
<StatCard emoji="🔥" label="Review streak" value="4 days" />
<StatCard label="Reviews today" value={6} />
<StatCard label="Diff reviews" value={28} />
diff --git a/apps/sandbox/src/app/pages/topnav-menu/page.tsx b/apps/sandbox/src/app/pages/topnav-menu/page.tsx
index f3d499b42c..c23c775cde 100644
--- a/apps/sandbox/src/app/pages/topnav-menu/page.tsx
+++ b/apps/sandbox/src/app/pages/topnav-menu/page.tsx
@@ -10,8 +10,9 @@ import {
XDSTopNavMenu,
} from '@xds/core/TopNav';
import {XDSNavIcon} from '@xds/core/NavIcon';
+import * as stylex from '@stylexjs/stylex';
-const styles = {
+const styles = stylex.create({
container: {
maxWidth: 960,
},
@@ -20,7 +21,7 @@ const styles = {
overflow: 'hidden',
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.08)',
},
-};
+});
const LogoIcon = () => (
<svg
@@ -97,7 +98,7 @@ const scienceItems = [
*/
export default function TopNavMenuPage() {
return (
- <div style={styles.container}>
+ <div {...stylex.props(styles.container)}>
<XDSVStack gap={6}>
<XDSVStack gap={2}>
<XDSHeading level={1}>TopNav Menu</XDSHeading>
@@ -110,7 +111,7 @@ export default function TopNavMenuPage() {
{/* Marketing-style nav with overflow menus */}
<XDSVStack gap={3}>
<XDSHeading level={2}>Marketing Nav</XDSHeading>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<XDSTopNav
label="Marketing navigation"
heading={
@@ -140,7 +141,7 @@ export default function TopNavMenuPage() {
{/* Simple nav with one overflow menu */}
<XDSVStack gap={3}>
<XDSHeading level={2}>Simple Nav</XDSHeading>
- <div style={styles.navWrapper}>
+ <div {...stylex.props(styles.navWrapper)}>
<XDSTopNav
label="Simple navigation"
heading={<XDSTopNavHeading heading="App" href="#" />}