Skip to content

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

TypeScript

feat(docsite): Added "theme-showcase" template for Themes page and Playground (#2649)

Kenton Quatmanf861fa7f64ab
diff --git a/apps/docsite/src/app/playground/PlaygroundClient.tsx b/apps/docsite/src/app/playground/PlaygroundClient.tsx
index d1cba07785..371c7cec64 100644
--- a/apps/docsite/src/app/playground/PlaygroundClient.tsx
+++ b/apps/docsite/src/app/playground/PlaygroundClient.tsx
@@ -40,6 +40,7 @@ import {
XDSSegmentedControl,
XDSSegmentedControlItem,
} from '@xds/core/SegmentedControl';
+import {XDSDropdownMenu} from '@xds/core/DropdownMenu';
import {useXDSResizable, XDSResizeHandle} from '@xds/core/Resizable';
import {XDSToggleButton, XDSToggleButtonGroup} from '@xds/core/ToggleButton';
import {
@@ -57,7 +58,12 @@ import {
import githubLight from './themes/github-light.json';
import githubDark from './themes/github-dark.json';
import {useThemeMode} from '../providers';
-import {DEFAULT_PLAYGROUND_THEME, themeByValue} from './playgroundThemes';
+import {
+ DEFAULT_PLAYGROUND_THEME,
+ PLAYGROUND_THEME_OPTIONS,
+ themeByValue,
+} from './playgroundThemes';
+import {templates} from '../../generated/templateRegistry';
import {PreviewStage, type Viewport} from './PreviewStage';
import {BRAND_ICON} from '../../components/XDSWordmark';
import {PropertyPanel} from './PropertyPanel';
@@ -354,10 +360,14 @@ export function PlaygroundClient() {
const themeParam =
rawThemeParam && rawThemeParam in themeByValue ? rawThemeParam : null;
const theme = themeParam ?? DEFAULT_PLAYGROUND_THEME;
- // The theme object the editor is seeded from — the ?theme= theme when present,
- // otherwise the playground default (neutral). Always defined so the always-
+ // The theme whose values seed the Theme editor: the ?theme= theme on first
+ // load, then whichever theme the user picks from the "Apply Theme" dropdown.
+ // Changing it remounts the editor (via key) so it re-populates from that theme.
+ const [selectedTheme, setSelectedTheme] = useState(theme);
+ // The theme object the editor is seeded from. Always defined so the always-
// mounted Theme editor reflects the active theme and stays the source of truth.
- const editorInitialTheme = themeByValue[theme];
+ const editorInitialTheme =
+ themeByValue[selectedTheme] ?? themeByValue[DEFAULT_PLAYGROUND_THEME];
const [activeView, setActiveView] = useState<LeftView>('code');
const [viewport, setViewport] = useState<Viewport>('desktop');
const [isFullscreen, setIsFullscreen] = useState(false);
@@ -691,6 +701,47 @@ export function PlaygroundClient() {
});
}, []);
+ // Dropdown items for "Apply Theme" — derived from the registered playground
+ // themes (PLAYGROUND_THEME_OPTIONS) so any installed @xds/theme-* package
+ // shows up automatically. Selecting one re-seeds the Theme editor (and thus
+ // the preview) with that theme's values.
+ const themeMenuItems = useMemo(
+ () =>
+ PLAYGROUND_THEME_OPTIONS.map(option => ({
+ label: option.label,
+ onClick: () => setSelectedTheme(option.value),
+ })),
+ [],
+ );
+
+ // Dropdown items for "Templates" — the published, ready templates from the
+ // generated registry (the same source the /templates gallery renders), so any
+ // new template shows up automatically. Selecting one loads its source into the
+ // editor (setCode drives Monaco, the preview, and the URL hash).
+ const templateMenuItems = useMemo(
+ () =>
+ templates
+ .filter(t => !t.isHiddenFromOverview && t.isReady && t.source)
+ .map(t => {
+ const dash = t.category.indexOf(' - ');
+ const group = dash === -1 ? t.category : t.category.slice(0, dash);
+ const label =
+ t.name.toLowerCase() === group.toLowerCase()
+ ? t.name
+ : `${group} · ${t.name}`;
+ return {label, source: t.source};
+ })
+ .sort((a, b) => a.label.localeCompare(b.label))
+ .map(({label, source}) => ({
+ label,
+ onClick: () => {
+ setCode(source);
+ requestAnimationFrame(() => editorRef.current?.focus());
+ },
+ })),
+ [],
+ );
+
const editorOptions = useMemo(
() => ({
minimap: {enabled: false},
@@ -772,10 +823,32 @@ export function PlaygroundClient() {
xstyle={s.leftPanelHeader}>
<XDSHeading level={3}>Playground</XDSHeading>
{activeView === 'code' && (
- <XDSButton variant="secondary" size="sm" label="Copy Code" />
+ <XDSHStack gap={2} align="center">
+ <XDSDropdownMenu
+ button={{
+ label: 'Templates',
+ variant: 'secondary',
+ size: 'sm',
+ }}
+ hasChevron
+ items={templateMenuItems}
+ />
+ <XDSButton variant="secondary" size="sm" label="Copy Code" />
+ </XDSHStack>
)}
{activeView === 'theme' && (
- <XDSButton variant="secondary" size="sm" label="Export Theme" />
+ <XDSHStack gap={2} align="center">
+ <XDSDropdownMenu
+ button={{
+ label: 'Apply Theme',
+ variant: 'secondary',
+ size: 'sm',
+ }}
+ hasChevron
+ items={themeMenuItems}
+ />
+ <XDSButton variant="secondary" size="sm" label="Export Theme" />
+ </XDSHStack>
)}
</XDSHStack>
<div {...stylex.props(s.tabBody)}>
@@ -823,6 +896,7 @@ export function PlaygroundClient() {
activeView !== 'theme' && s.hidden,
)}>
<PlaygroundThemeEditor
+ key={selectedTheme}
mode={mode}
initialTheme={editorInitialTheme}
onThemeChange={postCustomTheme}
diff --git a/apps/docsite/src/app/playground/defaultCode.ts b/apps/docsite/src/app/playground/defaultCode.ts
index 1d52ea02fb..68f4b6c14e 100644
--- a/apps/docsite/src/app/playground/defaultCode.ts
+++ b/apps/docsite/src/app/playground/defaultCode.ts
@@ -5,1213 +5,47 @@
* @output The default TSX source shown in the playground's Monaco editor.
* @position Playground — the initial example users see and edit.
*
- * A self-contained, no-prop adaptation of ThemeCardShowcase so it runs in the
- * preview sandbox (see (preview)/playground-preview/scope.ts). Kept as a string
- * because the playground edits/compiles it as user code rather than importing it.
- *
- * The sandbox mocks @stylexjs/stylex: `stylex.props()` returns no styles, so raw
- * elements (div/img/span) must apply `styles.X` via the `style` prop. `xstyle`
- * on XDS components still works because the real stylex runtime inside @xds/core
- * treats the plain style objects as inline styles.
+ * A minimal, self-contained XDSCard example (header, body text, footer button)
+ * that runs in the preview sandbox (see (preview)/playground-preview/runner.ts).
+ * Kept as a string because the playground edits/compiles it as user code rather
+ * than importing it.
*/
-export const DEFAULT_CODE = `import {type ReactNode} from 'react';
-import * as stylex from '@stylexjs/stylex';
+export const DEFAULT_CODE = `import {XDSCard} from '@xds/core/Card';
import {
- Plus,
- Search,
- Tag,
- Folder,
- MapPin,
- List,
- LayoutGrid,
- ShoppingBag,
- Banknote,
- Mic,
- CreditCard,
- Lock,
- X,
- Download,
- Smartphone,
- Wallet,
- User,
-} from 'lucide-react';
+ XDSLayout,
+ XDSLayoutHeader,
+ XDSLayoutContent,
+ XDSLayoutFooter,
+ XDSHStack,
+} from '@xds/core/Layout';
import {XDSText, XDSHeading} from '@xds/core/Text';
-import {XDSVStack, XDSHStack} from '@xds/core/Layout';
-import {XDSGrid, XDSGridSpan} from '@xds/core/Grid';
-import {XDSCard} from '@xds/core/Card';
import {XDSButton} from '@xds/core/Button';
-import {XDSLink} from '@xds/core/Link';
-import {XDSBadge} from '@xds/core/Badge';
-import {XDSBanner} from '@xds/core/Banner';
-import {XDSDivider} from '@xds/core/Divider';
-import {XDSCheckboxInput} from '@xds/core/CheckboxInput';
-import {XDSItem} from '@xds/core/Item';
-import {XDSTable, proportional, pixel} from '@xds/core/Table';
-import {XDSTextInput} from '@xds/core/TextInput';
-import {XDSSelector} from '@xds/core/Selector';
-import {XDSRadioList, XDSRadioListItem} from '@xds/core/RadioList';
-import {XDSSelectableCard} from '@xds/core/SelectableCard';
-import {XDSMoreMenu} from '@xds/core/MoreMenu';
-import {XDSCenter} from '@xds/core/Center';
-import {XDSSection} from '@xds/core/Section';
-import {XDSAspectRatio} from '@xds/core/AspectRatio';
-import {XDSNumberInput} from '@xds/core/NumberInput';
-import {XDSTopNav, XDSTopNavHeading, XDSTopNavItem} from '@xds/core/TopNav';
-import {
- XDSChatComposer,
- XDSChatMessage,
- XDSChatMessageBubble,
- XDSChatMessageList,
- XDSChatSystemMessage,
-} from '@xds/core/Chat';
-
-const styles = stylex.create({
- card: {
- backgroundColor: 'var(--color-background-body)',
- color: 'var(--color-text-primary)',
- minWidth: 0,
- borderColor: 'transparent',
- },
- checkoutStack: {
- minWidth: 0,
- width: '100%',
- },
- paymentCardContent: {
- minWidth: 0,
- width: '100%',
- textAlign: 'center',
- wordBreak: 'break-word',
- },
- fullSpanAtNarrow: {
- gridColumn: {
- default: null,
- '@media (max-width: 1024px)': '1 / -1',
- },
- },
- inventoryCard: {
- backgroundColor: 'var(--color-background-surface)',
- color: 'var(--color-text-primary)',
- overflow: 'hidden',
- },
- inventoryHeader: {
- paddingBlock: 'var(--spacing-6)',
- paddingInline: 'var(--spacing-6)',
- },
- inventoryFilterRow: {
- paddingBlock: 'var(--spacing-4)',
- paddingInline: 'var(--spacing-6)',
- width: '100%',
- },
- inventoryBannerWrap: {
- paddingInline: 'var(--spacing-6)',
- paddingBottom: 'var(--spacing-4)',
- },
- searchInput: {
- flex: 1,
- minWidth: 0,
- maxWidth: 240,
- },
- thumbnail: {
- width: 32,
- height: 32,
- borderRadius: 'var(--radius-element)',
- objectFit: 'cover' as const,
- display: 'block',
- flexShrink: 0,
- },
- thumbnailFallback: {
- width: 32,
- height: 32,
- borderRadius: 'var(--radius-element)',
- backgroundColor: 'var(--color-background-muted)',
- color: 'var(--color-text-secondary)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- fontSize: 'var(--font-size-sm)',
- fontWeight: 600,
- flexShrink: 0,
- },
- activityCard: {
- backgroundColor: 'var(--color-background-surface)',
- color: 'var(--color-text-primary)',
- minWidth: 0,
- height: '100%',
- },
- sparkline: {
- display: 'flex',
- alignItems: 'flex-end',
- justifyContent: 'space-around',
- height: 120,
- width: '100%',
- gap: 8,
- },
- sparkBar: {
- flex: 1,
- minWidth: 0,
- borderRadius: 'var(--radius-element)',
- backgroundColor: 'var(--color-background-green)',
- },
- sparkLabels: {
- display: 'flex',
- justifyContent: 'space-around',
- width: '100%',
- color: 'var(--color-text-secondary)',
- fontSize: 'var(--font-size-xs)',
- },
- kpiValue: {
- fontSize: 24,
- fontWeight: 700,
- lineHeight: 1.1,
- color: 'var(--color-text-primary)',
- fontFamily: 'var(--font-family-heading)',
- letterSpacing: '-0.01em',
- },
- chatCard: {
- backgroundColor: 'var(--color-background-surface)',
- color: 'var(--color-text-primary)',
- minWidth: 0,
- overflow: 'hidden',
- display: 'flex',
- flexDirection: 'column' as const,
- },
- chatHeader: {
- paddingBlock: 'var(--spacing-4)',
- paddingInline: 'var(--spacing-4)',
- },
- chatBody: {
- flex: 1,
- minHeight: 0,
- overflow: 'hidden',
- },
- chatSuggestions: {
- paddingInline: 'var(--spacing-4)',
- paddingBottom: 'var(--spacing-2)',
- },
- chatComposer: {
- paddingInline: 'var(--spacing-4)',
- paddingBottom: 'var(--spacing-4)',
- },
- activityIcon: {
- width: 32,
- height: 32,
- borderRadius: 'var(--radius-full)',
- backgroundColor: 'var(--color-background-muted)',
- color: 'var(--color-text-secondary)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- flexShrink: 0,
- },
- activityCardStack: {
- height: '100%',
- },
- activityListFade: {
- flex: 1,
- minHeight: 0,
- overflow: 'hidden',
- maskImage:
- 'linear-gradient(to bottom, black calc(100% - 48px), transparent)',
- WebkitMaskImage:
- 'linear-gradient(to bottom, black calc(100% - 48px), transparent)',
- marginInline: 'calc(var(--spacing-2) * -1)',
- },
- content: {
- maxWidth: 960,
- marginInline: 'auto',
- },
- contentFluid: {
- maxWidth: 880,
- },
- heroText: {
- textAlign: 'center' as const,
- maxWidth: 560,
- },
- centerText: {
- textAlign: 'center',
- },
- productImage: {
- width: '100%',
- height: '100%',
- objectFit: 'cover' as const,
- },
- cardStack: {
- height: '100%',
- },
- cardBody: {
- padding: 'var(--spacing-4)',
- flex: 1,
- display: 'flex',
- flexDirection: 'column' as const,
- },
- cardDescription: {
- flex: 1,
- },
- quantityInput: {
- width: 40,
- flexShrink: 0,
- },
- cartButton: {
- flex: 1,
- },
-});
-
-const PRODUCT_IMAGE_KEYS = ['watch', 'headphones', 'backpack'];
-
-const PRODUCTS = [
- {
- name: 'Minimalist Watch',
- description: 'Clean design meets everyday durability.',
- badge: 'New',
- badgeVariant: 'blue' as const,
- },
- {
- name: 'Wireless Headphones',
- description: 'Immersive sound, all-day comfort.',
- badge: 'Popular',
- badgeVariant: 'green' as const,
- },
- {
- name: 'Canvas Backpack',
- description: 'Water-resistant canvas with a quiet, modern profile.',
- badge: 'Limited',
- badgeVariant: 'yellow' as const,
- },
-];
-
-const PREVIEW_IMAGES: Record<string, string> = {
- watch: '/neutral/preview-watch.png',
- headphones: '/neutral/preview-headphones.png',
- backpack: '/neutral/preview-backpack.png',
- wallet: '/neutral/preview-wallet.png',
- mug: '/neutral/preview-mug.png',
- throw_: '/neutral/preview-throw.png',
-};
-
-export default function ThemeShowcase() {
- const images: Record<string, string> = PREVIEW_IMAGES;
- return (
- <div
- style={{
- minHeight: '100%',
- backgroundColor: 'var(--color-background-body)',
- }}>
- <StorePreview images={images} />
- <div
- style={{
- padding: 'var(--spacing-6)',
- backgroundColor: 'var(--color-background-surface)',
- }}>
- <CardShowcase images={images} />
- </div>
- </div>
- );
-}
-
-function CardShowcase({images}: {images: Record<string, string>}) {
- return (
- <XDSVStack gap={8}>
- <XDSGrid columns={{minWidth: 200, repeat: 'fit'}} gap={4}>
- <XDSGridSpan columns={1} xstyle={styles.fullSpanAtNarrow}>
- <CheckoutCard />
- </XDSGridSpan>
- <XDSGridSpan columns={2} xstyle={styles.fullSpanAtNarrow}>
- <ChatCard />
- </XDSGridSpan>
- </XDSGrid>
- <XDSGrid columns={{minWidth: 200, repeat: 'fit'}} gap={4}>
- <XDSGridSpan columns={3} xstyle={styles.fullSpanAtNarrow}>
- <InventoryCard images={images} />
- </XDSGridSpan>
- <XDSGridSpan columns={1} xstyle={styles.fullSpanAtNarrow}>
- <LatestActivityCard />
- </XDSGridSpan>
- </XDSGrid>
- </XDSVStack>
- );
-}
-
-function StorePreview({images}: {images: Record<string, string>}) {
- return (
- <div data-theme-preview="true">
- <XDSVStack gap={0}>
- <XDSTopNav
- label="Theme preview navigation"
- heading={<XDSTopNavHeading heading="Studio" />}
- centerContent={
- <>
- <XDSTopNavItem label="Shop" href="#" isSelected />
- <XDSTopNavItem label="New In" href="#" />
- <XDSTopNavItem label="Stories" href="#" />
- <XDSTopNavItem label="Help" href="#" />
- </>
- }
- endContent={
- <XDSHStack gap={2} vAlign="center">
- <XDSHStack gap={0.5}>
- <XDSButton
- label="Search"
- tooltip="Search"
- variant="ghost"
- isIconOnly
- icon={<Search size={20} />}
- href="#"
- />
- <XDSButton
- label="Account"
- tooltip="Account"
- variant="ghost"
- isIconOnly
- icon={<User size={20} />}
- href="#"
- />
- <XDSButton
- label="Cart"
- tooltip="Cart"
- variant="ghost"
- isIconOnly
- icon={<ShoppingBag size={20} />}
- href="#"
- />
- </XDSHStack>
- <XDSButton label="Sign in" variant="primary" href="#" />
- </XDSHStack>
- }
- />
-
- <XDSSection padding={8} variant="transparent">
- <XDSVStack gap={10} xstyle={[styles.content, styles.contentFluid]}>
- <XDSCenter>
- <XDSVStack gap={4} hAlign="center" xstyle={styles.heroText}>
- <XDSText type="display-3">
- Little joys,
- <br />
- everywhere you go
- </XDSText>
- <XDSText type="body" color="secondary">
- We believe the smallest details are the ones that matter most.
- Turn an ordinary day into something worth remembering.
- </XDSText>
- </XDSVStack>
- </XDSCenter>
-
- <XDSGrid columns={{minWidth: 240}} gap={4}>
- {PRODUCTS.map((p, i) => (
- <XDSCard key={p.name} padding={0} height="100%">
- <XDSVStack gap={0} xstyle={styles.cardStack}>
- <XDSAspectRatio ratio={1}>
- <img
- src={images[PRODUCT_IMAGE_KEYS[i]]}
- alt={p.name}
- style={styles.productImage}
- />
- </XDSAspectRatio>
- <div style={styles.cardBody}>
- <XDSVStack
- gap={2}
- hAlign="center"
- xstyle={styles.cardStack}>
- <XDSHStack>
- <XDSBadge label={p.badge} variant={p.badgeVariant} />
- </XDSHStack>
- <XDSHeading level={2} xstyle={styles.centerText}>
- {p.name}
- </XDSHeading>
- <XDSText
- type="supporting"
- color="secondary"
- xstyle={[styles.cardDescription, styles.centerText]}>
- {p.description}
- </XDSText>
- <XDSHStack gap={2} vAlign="center" hAlign="center">
- <XDSNumberInput
- label="Quantity"
- isLabelHidden
- value={1}
- onChange={() => {}}
- min={1}
- max={99}
- size="sm"
- xstyle={styles.quantityInput}
- />
- <XDSButton
- label="Add to cart"
- variant="secondary"
- href="#"
- xstyle={styles.cartButton}
- />
- </XDSHStack>
- </XDSVStack>
- </div>
- </XDSVStack>
- </XDSCard>
- ))}
- </XDSGrid>
- </XDSVStack>
- </XDSSection>
- </XDSVStack>
- </div>
- );
-}
-
-function CheckoutCard() {
- return (
- <XDSCard padding={5} xstyle={styles.card}>
- <XDSVStack gap={4} xstyle={styles.checkoutStack}>
- <XDSHeading level={2}>Checkout</XDSHeading>
-
- <XDSVStack gap={3} xstyle={styles.checkoutStack}>
- <XDSTextInput
- label="Email"
- placeholder="[email protected]"
- value=""
- onChange={() => {}}
- size="lg"
- />
- <XDSRadioList
- label="Shipping method"
- description="Delivery time may vary based on location and availability."
- value="economy"
- onChange={() => {}}>
- <XDSRadioListItem
- value="economy"
- label="Economy Shipping"
- description="Delivered in 5–7 business days"
- endContent={
- <XDSText type="body" weight="bold">
- $12.00
- </XDSText>
- }
- />
- <XDSRadioListItem
- value="standard"
- label="Standard Shipping"
- description="Delivered in 3–5 business days"
- endContent={
- <XDSText type="body" weight="bold">
- $16.00
- </XDSText>
- }
- />
- <XDSRadioListItem
- value="express"
- label="Express Shipping"
- description="Delivered in 1–2 business days"
- endContent={
- <XDSText type="body" weight="bold">
- $24.00
- </XDSText>
- }
- />
- </XDSRadioList>
-
- <XDSVStack gap={2} xstyle={styles.checkoutStack}>
- <XDSText type="supporting" weight="bold">
- Payment method
+export default function Example() {
+ return (
+ <XDSCard width={400} padding={4}>
+ <XDSLayout
+ header={
+ <XDSLayoutHeader hasDivider>
+ <XDSHeading level={2}>Welcome</XDSHeading>
+ </XDSLayoutHeader>
+ }
+ content={
+ <XDSLayoutContent>
+ <XDSText type="body" color="secondary">
+ Try out components in the code editor, open a ready-made templates,
+ and build your own theme in the theme editor — all in one place.
</XDSText>
- <XDSGrid columns={{minWidth: 70, max: 3}} gap={2}>
- <XDSSelectableCard
- label="Pay with card"
- isSelected={true}
- onChange={() => {}}
- padding={3}>
- <XDSVStack
- gap={1}
- hAlign="center"
- xstyle={styles.paymentCardContent}>
- <CreditCard size={20} />
- <XDSText type="supporting" weight="bold">
- Card
- </XDSText>
- </XDSVStack>
- </XDSSelectableCard>
- <XDSSelectableCard
- label="Pay with Apple Pay"
- isSelected={false}
- onChange={() => {}}
- padding={3}>
- <XDSVStack
- gap={1}
- hAlign="center"
- xstyle={styles.paymentCardContent}>
- <Smartphone size={20} />
- <XDSText type="supporting" weight="bold">
- Apple Pay
- </XDSText>
- </XDSVStack>
- </XDSSelectableCard>
- <XDSSelectableCard
- label="Pay with Google Pay"
- isSelected={false}
- onChange={() => {}}
- padding={3}>
- <XDSVStack
- gap={1}
- hAlign="center"
- xstyle={styles.paymentCardContent}>
- <Wallet size={20} />
- <XDSText type="supporting" weight="bold">
- Google Pay
- </XDSText>
- </XDSVStack>
- </XDSSelectableCard>
- </XDSGrid>
- </XDSVStack>
-
- <XDSTextInput
- label="Card number"
- placeholder="1234 1234 1234 1234"
- value=""
- onChange={() => {}}
- startIcon={<CreditCard size={16} />}
- size="lg"
- />
-
- <XDSGrid columns={{minWidth: 90, max: 2}} gap={2}>
- <XDSTextInput
- label="Expiry"
- placeholder="MM / YY"
- value=""
- onChange={() => {}}
- size="lg"
- />
- <XDSTextInput
- label="CVC"
- placeholder="123"
- value=""
- onChange={() => {}}
- size="lg"
- />
- </XDSGrid>
-
- <XDSSelector
- label="Country"
- value="us"
- onChange={() => {}}
- size="lg"
- options={[
- {value: 'us', label: 'United States'},
- {value: 'ca', label: 'Canada'},
- {value: 'uk', label: 'United Kingdom'},
- {value: 'de', label: 'Germany'},
- {value: 'jp', label: 'Japan'},
- {value: 'au', label: 'Australia'},
- ]}
- />
- </XDSVStack>
-
- <XDSCheckboxInput
- label="Securely save my information for 1-click checkout"
- description="Pay faster on Studio and everywhere Link is accepted."
- value={true}
- onChange={() => {}}
- />
-
- <XDSButton
- variant="primary"
- size="lg"
- label="Pay now"
- icon={<Lock size={16} />}
- />
- </XDSVStack>
- </XDSCard>
- );
-}
-
-const SUGGESTED_QUESTIONS = [
- 'Reschedule delivery',
- 'Update shipping address',
- 'Start a return',
-];
-
-function ChatCard() {
- return (
- <XDSCard padding={0} xstyle={styles.chatCard}>
- <XDSHStack
- hAlign="between"
- vAlign="center"
- gap={3}
- xstyle={styles.chatHeader}>
- <XDSHeading level={2}>Studio AI</XDSHeading>
-
- <XDSHStack gap={1} vAlign="center">
- <XDSButton
- variant="ghost"
- size="sm"
- isIconOnly
- label="Export conversation"
- tooltip="Export conversation"
- icon={<Download size={16} />}
- />
- <XDSButton
- variant="ghost"
- size="sm"
- isIconOnly
- label="Close chat"
- tooltip="Close chat"
- icon={<X size={16} />}
- />
- </XDSHStack>
- </XDSHStack>
-
- <XDSDivider variant="subtle" />
-
- <div style={styles.chatBody}>
- <XDSChatMessageList>
- <XDSChatSystemMessage>Today</XDSChatSystemMessage>
-
- <XDSChatMessage sender="user">
- <XDSChatMessageBubble variant="filled">
- Where’s my order?
- </XDSChatMessageBubble>
- </XDSChatMessage>
-
- <XDSChatMessage sender="assistant">
- <XDSVStack gap={3}>
- <XDSText type="body">
- Your order #1043 — the Minimalist Watch and Linen Throw —
- shipped this morning from the Aisle 3 warehouse and is currently
- in transit with UPS. It’s on track to arrive at your address by
- end of day tomorrow.
- </XDSText>
- <XDSText type="body">
- Let me know if you’d like to reschedule the delivery, redirect
- it to a pickup point, or start a return once it arrives.
- </XDSText>
- </XDSVStack>
- </XDSChatMessage>
-
- <XDSChatMessage sender="user">
- <XDSChatMessageBubble variant="filled">
- Can you show me the full details?
- </XDSChatMessageBubble>
- </XDSChatMessage>
-
- <XDSChatMessage sender="assistant">
- <XDSVStack gap={3}>
- <XDSText type="body">
- Here’s everything I have on order #1043:
- </XDSText>
- <XDSCard padding={3}>
- <XDSVStack gap={1}>
- <XDSItem
- label="Items"
- description="Minimalist Watch · Linen Throw"
- trailing={
- <XDSText type="body" weight="bold">
- $248
- </XDSText>
- }
- />
- <XDSItem
- label="Shipping"
- description="UPS Ground"
- trailing={
- <XDSText type="body" weight="bold">
- $12
- </XDSText>
- }
- />
- <XDSItem
- label="Estimated arrival"
- description="Tomorrow by 8pm"
- trailing={<XDSBadge variant="green" label="On time" />}
- />
- <XDSItem
- label="Tracking"
- description="UPS 1Z 999 AA1 0123 4567 84"
- trailing={<XDSLink href="#">Track →</XDSLink>}
- />
- </XDSVStack>
- </XDSCard>
- </XDSVStack>
- </XDSChatMessage>
- </XDSChatMessageList>
- </div>
-
- <div style={styles.chatSuggestions}>
- <XDSHStack gap={1} hAlign="center" wrap="wrap">
- {SUGGESTED_QUESTIONS.map(question => (
- <XDSButton
- key={question}
- variant="secondary"
- size="sm"
- label={question}
- />
- ))}
- </XDSHStack>
- </div>
-
- <div style={styles.chatComposer}>
- <XDSChatComposer
- value=""
- onChange={() => {}}
- onSubmit={() => {}}
- placeholder="Ask Studio AI…"
- footerActions={
- <XDSButton
- variant="ghost"
- size="md"
- isIconOnly
- label="Attach"
- tooltip="Attach"
- icon={<Plus size={16} />}
- />
- }
- sendActions={
- <XDSButton
- variant="ghost"
- size="md"
- isIconOnly
- label="Voice input"
- tooltip="Voice input"
- icon={<Mic size={16} />}
- />
- }
- />
- </div>
- </XDSCard>
- );
-}
-
-const SPARKLINE_DATA = [55, 70, 92, 78, 60];
-const SPARKLINE_LABELS = ['Jan', 'Feb', 'Mar', 'Apr', 'May'];
-
-interface ActivityRow {
- id: string;
- icon: ReactNode;
- label: string;
- detail: string;
- time: string;
- amount: number;
-}
-
-const ACTIVITY: ActivityRow[] = [
- {
- id: '1',
- icon: <ShoppingBag size={16} />,
- label: 'Order #1043',
- detail: 'Placed · 1:59 pm',
- time: '1:59 pm',
- amount: 248,
- },
- {
- id: '2',
- icon: <Banknote size={16} />,
- label: 'Order #1041',
- detail: 'Refunded · 12:40 pm',
- time: '12:40 pm',
- amount: -89,
- },
- {
- id: '3',
- icon: <ShoppingBag size={16} />,
- label: 'Order #1040',
- detail: 'Placed · 10:30 am',
- time: '10:30 am',
- amount: 156,
- },
- {
- id: '4',
- icon: <ShoppingBag size={16} />,
- label: 'Order #1038',
- detail: 'Placed · 9:11 am',
- time: '9:11 am',
- amount: 412,
- },
- {
- id: '5',
- icon: <ShoppingBag size={16} />,
- label: 'Order #1037',
- detail: 'Placed · 8:42 am',
- time: '8:42 am',
- amount: 95,
- },
-];
-
-function formatAmount(amount: number): string {
- const sign = amount < 0 ? '−' : '+';
- return sign + '$' + Math.abs(amount).toLocaleString();
-}
-
-function LatestActivityCard() {
- return (
- <XDSCard padding={5} xstyle={styles.activityCard}>
- <XDSVStack gap={4} xstyle={styles.activityCardStack}>
- <XDSHeading level={2}>Revenue</XDSHeading>
-
- <XDSVStack gap={2}>
- <div style={styles.sparkline} aria-hidden="true">
- {SPARKLINE_DATA.map((value, i) => (
- <div
- key={i}
- style={{...styles.sparkBar, height: value + '%'}}
- />
- ))}
- </div>
- <div style={styles.sparkLabels} aria-hidden="true">
- {SPARKLINE_LABELS.map(label => (
- <span key={label}>{label}</span>
- ))}
- </div>
- </XDSVStack>
-
- <XDSGrid columns={2} gap={3}>
- <XDSVStack gap={0}>
- <span style={styles.kpiValue}>18K</span>
- <XDSText type="supporting" color="secondary">
- Monthly revenue
- </XDSText>
- </XDSVStack>
- <XDSVStack gap={0}>
- <span style={styles.kpiValue}>+12%</span>
- <XDSText type="supporting" color="secondary">
- Order growth
- </XDSText>
- </XDSVStack>
- </XDSGrid>
-
- <XDSDivider variant="subtle" />
-
- <XDSHStack hAlign="between" vAlign="center">
- <XDSHeading level={3}>Activity</XDSHeading>
- <XDSLink href="#">See all</XDSLink>
- </XDSHStack>
-
- <XDSVStack gap={1} xstyle={styles.activityListFade}>
- {ACTIVITY.map(item => (
- <XDSItem
- key={item.id}
- media={
- <div style={styles.activityIcon} aria-hidden="true">
- {item.icon}
- </div>
- }
- label={item.label}
- description={item.detail}
- trailing={
- <XDSText
- type="body"
- weight="bold"
- color={item.amount < 0 ? 'secondary' : 'primary'}>
- {formatAmount(item.amount)}
- </XDSText>
- }
- href="#"
- />
- ))}
- </XDSVStack>
- </XDSVStack>
- </XDSCard>
- );
-}
-
-type TagSpec = {label: string; variant: 'blue' | 'green' | 'orange' | 'yellow'};
-
-interface InventoryRow extends Record<string, unknown> {
- id: string;
- name: string;
- meta: string;
- available: number;
- location: string;
- tags: TagSpec[];
- imageKey?: string;
- thumbnailFallback: string;
- selected: boolean;
-}
-
-const INVENTORY: InventoryRow[] = [
- {
- id: 'a',
- name: 'Minimalist Watch',
- meta: 'Stainless steel, sapphire crystal',
- available: 42,
- location: 'Aisle 3',
- tags: [{label: 'New', variant: 'blue'}],
- imageKey: 'watch',
- thumbnailFallback: 'M',
- selected: false,
- },
- {
- id: 'b',
- name: 'Wireless Headphones',
- meta: 'ANC, 30hr battery',
- available: 128,
- location: 'Aisle 1',
- tags: [{label: 'Popular', variant: 'green'}],
- imageKey: 'headphones',
- thumbnailFallback: 'W',
- selected: true,
- },
- {
- id: 'c',
- name: 'Canvas Backpack',
- meta: 'Water-resistant, 25L',
- available: 63,
- location: 'Aisle 2',
- tags: [{label: 'Limited', variant: 'yellow'}],
- imageKey: 'backpack',
- thumbnailFallback: 'C',
- selected: false,
- },
- {
- id: 'd',
- name: 'Leather Wallet',
- meta: 'Full-grain, RFID blocking',
- available: 15,
- location: 'Aisle 4',
- tags: [{label: 'Leather', variant: 'yellow'}],
- imageKey: 'wallet',
- thumbnailFallback: 'L',
- selected: true,
- },
- {
- id: 'e',
- name: 'Travel Mug',
- meta: 'Vacuum insulated, 16oz',
- available: 87,
- location: 'Aisle 5',
- tags: [{label: 'Drinkware', variant: 'green'}],
- imageKey: 'mug',
- thumbnailFallback: 'T',
- selected: false,
- },
- {
- id: 'f',
- name: 'Linen Throw',
- meta: 'Heavyweight, oat',
- available: 24,
- location: 'Aisle 6',
- tags: [{label: 'Home', variant: 'orange'}],
- imageKey: 'throw_',
- thumbnailFallback: 'L',
- selected: true,
- },
-];
-
-const LOW_STOCK_THRESHOLD = 25;
-const LOW_STOCK_COUNT = INVENTORY.filter(
- row => row.available < LOW_STOCK_THRESHOLD,
-).length;
-
-function SelectCell({row}: {row: InventoryRow}) {
- return (
- <XDSCheckboxInput
- label={'Select ' + row.name}
- isLabelHidden
- value={row.selected}
- onChange={() => {}}
- />
- );
-}
-
-function ItemCell({
- row,
- images,
-}: {
- row: InventoryRow;
- images: Record<string, string>;
-}) {
- const thumbnailSrc = row.imageKey ? images[row.imageKey] : undefined;
- return (
- <XDSHStack gap={3} vAlign="center">
- {thumbnailSrc ? (
- <img src={thumbnailSrc} alt="" style={styles.thumbnail} />
- ) : (
- <div style={styles.thumbnailFallback} aria-hidden="true">
- {row.thumbnailFallback}
- </div>
- )}
- <XDSVStack gap={0} style={{minWidth: 0}}>
- <XDSText type="body" weight="bold">
- {row.name}
- </XDSText>
- <XDSText type="supporting" color="secondary">
- {row.meta}
- </XDSText>
- </XDSVStack>
- </XDSHStack>
- );
-}
-
-function TagsCell({row}: {row: InventoryRow}) {
- return (
- <XDSHStack gap={1} wrap="wrap" hAlign="end">
- {row.tags.map(tag => (
- <XDSBadge key={tag.label} label={tag.label} variant={tag.variant} />
- ))}
- </XDSHStack>
- );
-}
-
-function ActionsCell() {
- return (
- <XDSMoreMenu
- label="Row actions"
- items={[
- {label: 'Edit'},
- {label: 'Duplicate'},
- {label: 'Move to…'},
- {type: 'divider'},
- {label: 'Delete'},
- ]}
- />
- );
-}
-
-function InventoryCard({images}: {images: Record<string, string>}) {
- return (
- <XDSCard padding={0} xstyle={styles.inventoryCard}>
- <XDSHStack
- hAlign="between"
- vAlign="center"
- xstyle={styles.inventoryHeader}>
- <XDSHeading level={2}>Inventory</XDSHeading>
- <XDSButton
- label="Add item"
- variant="primary"
- size="sm"
- icon={<Plus size={16} />}
- />
- </XDSHStack>
-
- <XDSDivider variant="subtle" />
-
- <XDSHStack
- gap={3}
- vAlign="center"
- hAlign="between"
- xstyle={styles.inventoryFilterRow}>
- <XDSHStack gap={2} vAlign="center" style={{flex: 1, minWidth: 0}}>
- <XDSTextInput
- label="Search inventory"
- isLabelHidden
- placeholder="Type and hit enter…"
- value=""
- onChange={() => {}}
- startIcon={<Search size={16} />}
- xstyle={styles.searchInput}
- />
- <XDSSelector
- label="Categories"
- isLabelHidden
- placeholder="Categories"
- size="sm"
- startIcon={<Folder size={16} />}
- value={undefined}
- onChange={() => {}}
- options={['Wearables', 'Audio', 'Bags', 'Drinkware', 'Home']}
- />
- <XDSSelector
- label="Locations"
- isLabelHidden
- placeholder="Locations"
- size="sm"
- startIcon={<MapPin size={16} />}
- value={undefined}
- onChange={() => {}}
- options={[
- 'Aisle 1',
- 'Aisle 2',
- 'Aisle 3',
- 'Aisle 4',
- 'Aisle 5',
- 'Aisle 6',
- ]}
- />
- <XDSSelector
- label="Tags"
- isLabelHidden
- placeholder="Tags"
- size="sm"
- startIcon={<Tag size={16} />}
- value={undefined}
- onChange={() => {}}
- options={[
- 'New',
- 'Popular',
- 'Limited',
- 'Leather',
- 'Drinkware',
- 'Home',
- ]}
- />
- </XDSHStack>
- <XDSHStack gap={1} vAlign="center">
- <XDSButton
- variant="ghost"
- size="sm"
- isIconOnly
- label="List view"
- tooltip="List view"
- icon={<List size={18} />}
- />
- <XDSButton
- variant="ghost"
- size="sm"
- isIconOnly
- label="Grid view"
- tooltip="Grid view"
- icon={<LayoutGrid size={18} />}
- />
- </XDSHStack>
- </XDSHStack>
-
- {LOW_STOCK_COUNT > 0 && (
- <div style={styles.inventoryBannerWrap}>
- <XDSBanner
- status="warning"
- title={LOW_STOCK_COUNT + ' items are running low'}
- />
- </div>
- )}
-
- <XDSTable<InventoryRow>
- data={INVENTORY}
- columns={[
- {
- key: 'select',
- header: '',
- width: pixel(48),
- renderCell: row => <SelectCell row={row} />,
- },
- {
- key: 'item',
- header: 'Item',
- width: proportional(3),
- renderCell: row => <ItemCell row={row} images={images} />,
- },
- {
- key: 'available',
- header: 'Available',
- width: pixel(100),
- renderCell: row => <XDSText type="body">{row.available}</XDSText>,
- },
- {
- key: 'location',
- header: 'Location',
- width: pixel(100),
- renderCell: row => <XDSText type="body">{row.location}</XDSText>,
- },
- {
- key: 'tags',
- header: 'Tags',
- width: proportional(2),
- align: 'end',
- renderCell: row => <TagsCell row={row} />,
- },
- {
- key: 'actions',
- header: '',
- width: pixel(48),
- renderCell: () => <ActionsCell />,
- },
- ]}
- density="spacious"
- dividers="rows"
- hasHover
+ </XDSLayoutContent>
+ }
+ footer={
+ <XDSLayoutFooter hasDivider>
+ <XDSHStack hAlign="end">
+ <XDSButton label="Get started" variant="primary" />
+ </XDSHStack>
+ </XDSLayoutFooter>
+ }
/>
</XDSCard>
);
diff --git a/apps/docsite/src/components/ThemePackagePage.tsx b/apps/docsite/src/components/ThemePackagePage.tsx
index 1369a344ad..47400c71c5 100644
--- a/apps/docsite/src/components/ThemePackagePage.tsx
+++ b/apps/docsite/src/components/ThemePackagePage.tsx
@@ -7,7 +7,6 @@ import * as stylex from '@stylexjs/stylex';
import type {StyleXStyles} from '@stylexjs/stylex';
import {usePathname, useRouter} from 'next/navigation';
import {Sun, Moon} from 'lucide-react';
-import {durationVars, easeVars} from '@xds/core/theme/tokens.stylex';
import {XDSHStack, XDSVStack} from '@xds/core/Layout';
import {XDSHeading, XDSText} from '@xds/core/Text';
import {XDSCard} from '@xds/core/Card';
@@ -18,12 +17,18 @@ import {XDSLink} from '@xds/core/Link';
import {XDSSelectableCard} from '@xds/core/SelectableCard';
import {XDSSelector} from '@xds/core/Selector';
import {XDSDivider} from '@xds/core/Divider';
-import {ThemeShowcasePreview} from './ThemeShowcasePreview';
-import {ThemeCardShowcase} from './ThemeCardShowcase';
-import {getThemeImages} from './themeImages';
+import ThemeShowcase from '../../../../packages/cli/templates/pages/theme-showcase/page';
+import {buildPlaygroundHref} from './playgroundLink';
import {packages} from '../generated/packageRegistry';
import {themeObjects} from '../generated/themeRegistry';
-import {trackClickCta, trackToggle} from '../lib/analytics';
+import {templates} from '../generated/templateRegistry';
+import {trackOpenPlayground, trackToggle} from '../lib/analytics';
+
+// Raw source of the theme-showcase page template (embedded as a string in
+// the generated template registry). Used to prepopulate the playground's
+// code editor when the user clicks "Open in Playground" from a theme.
+const THEME_SHOWCASE_SOURCE =
+ templates.find(t => t.slug === 'theme-showcase')?.source ?? '';
// Gallery order — themes are listed in the same canonical visual-
// closeness order used elsewhere (most restrained → most expressive).
@@ -85,19 +90,6 @@ const SIDEBAR_WIDTH = 260;
const SIDEBAR_STICKY_TOP =
'calc(var(--appshell-header-height, 64px) + var(--spacing-4))';
-// Sidebar-leave animation — slides the sidebar off the left edge
-// and fades it out. Triggered when the user clicks Customize: the
-// keyframe runs for one --duration-medium tick, then the click
-// handler navigates to the playground. The right preview stays
-// visually anchored during the leave, so the transition reads as
-// "swap the left panel for the editor" rather than a generic page
-// change — the playground page renders its own editor controls in
-// roughly the same column when it mounts.
-const sidebarLeaveKeyframes = stylex.keyframes({
- from: {transform: 'translateX(0)', opacity: 1},
- to: {transform: 'translateX(-100%)', opacity: 0},
-});
-
const styles = stylex.create({
// Outer two-column container. Sidebar (fixed width) sits left,
// right pane (flex:1) holds the existing preview + showcase. The
@@ -113,24 +105,6 @@ const styles = stylex.create({
flexDirection: 'column' as const,
},
},
- // Applied to the sidebar while the leave animation is playing.
- // Slides the sidebar off the left edge + fades it out so the
- // right preview stays put visually until the playground replaces
- // it. Forward fill-mode holds the end state so there's no flash
- // of the sidebar reverting before the navigation swaps the route.
- // Honors prefers-reduced-motion by collapsing to a zero-duration
- // animation so the leave is instant for users who'd find the
- // slide motion distracting.
- sidebarLeaving: {
- animationName: sidebarLeaveKeyframes,
- animationDuration: durationVars['--duration-medium'],
- animationTimingFunction: easeVars['--ease-standard'],
- animationFillMode: 'forwards',
- pointerEvents: 'none' as const,
- '@media (prefers-reduced-motion: reduce)': {
- animationDuration: '0s',
- },
- },
// Sticky sidebar wrapper. position:sticky keeps the panel in view
// while the right pane scrolls past; top offset clears the docsite
// top nav so the sidebar doesn't disappear behind it. flex:0 0 auto
@@ -184,7 +158,7 @@ const styles = stylex.create({
flexDirection: 'column' as const,
gap: 'var(--spacing-2)',
},
- // Make every action button (hero CTAs, mode toggle, Customize)
+ // Make every action button (hero CTAs, mode toggle, Open in Playground)
// stretch to the sidebar width and left-align its label
// (XDSButton's default is centered, which looks off in a vertical
// nav-style list).
@@ -411,25 +385,16 @@ const styles = stylex.create({
mobileSelector: {
minWidth: 160,
},
- // Preview card — unchanged from the floating-toolbar version.
- // Matches the "wide content" max-width used across the site
- // (home page showcases, docs index). Keeps the showcase from
- // running viewport-edge to viewport-edge on very wide screens
- // while staying noticeably wider than the 800px prose column
- // above it so the showcase grid still has room to breathe.
- previewCard: {
+ // Showcase card — clips the theme-showcase template's own
+ // backgrounds (top nav, sections) to the card's rounded corners.
+ // The card's default variant supplies the border + radius; the
+ // template paints its own themed body background inside.
+ showcaseCard: {
overflow: 'hidden',
- maxWidth: 1200,
- width: '100%',
- marginInline: 'auto',
- // Use the theme's body background (not the card/muted surface)
- // so the preview reads as a real themed app — the surrounding
- // chrome (top nav, hero, etc.) sits on the theme's true body
- // color, which is what users would see in their own app.
- backgroundColor: 'var(--color-background-body)',
},
- // Matches the preview card's 1200px max-width so the card
- // showcase visually aligns with the preview above it.
+ // Caps the showcase at the site's "wide content" max-width (1200px,
+ // matching home-page showcases / docs index) and centers it so it
+ // doesn't run viewport-edge to viewport-edge on very wide screens.
showcaseBlock: {
width: '100%',
maxWidth: 1200,
@@ -551,9 +516,6 @@ export function ThemePackagePage({packageName, theme}: ThemePackagePageProps) {
// list — but the guard keeps the page from crashing if the
// registry drifts).
const selectedTheme = themeObjects[selectedPkgName] ?? theme;
- // Resolve the product image set for the selected theme (falls back
- // to neutral if the theme doesn't have its own set yet).
- const images = getThemeImages(selectedTheme.name);
// Mobile dropdown options — mirror the sidebar list. Value is the
// full @xds/theme-<slug> package name (matches state), label is
@@ -577,59 +539,26 @@ export function ThemePackagePage({packageName, theme}: ThemePackagePageProps) {
const modeToggleIcon =
mode === 'light' ? <Moon size={20} /> : <Sun size={20} />;
- // Plays a slide-left + fade-out animation on the whole page when
- // the user clicks Customize, then navigates to the playground
- // after the animation duration. Reads as 'launching into the
- // playground' rather than an abrupt route change.
- //
- // CSS-only; the animation uses XDS motion tokens
- // (--duration-medium + --ease-standard) so it stays in sync with
- // the rest of the app's motion. Modifier-clicks (cmd/middle)
- // skip the animation and open in a new tab normally.
- const [isLeaving, setIsLeaving] = useState(false);
- const customizeHref = `/themes/playground/${selectedTheme.name}`;
- const handleCustomizeClick = useCallback(
- (event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => {
- if (
- event.metaKey ||
- event.ctrlKey ||
- event.shiftKey ||
- event.altKey ||
- event.button !== 0
- ) {
- return;
- }
- event.preventDefault();
- trackClickCta({
- page: 'themes',
- target: 'customize',
- item: selectedPkgName,
- });
- setIsLeaving(true);
- // Wait for the leave animation to play, then navigate. Length
- // matches --duration-medium (~410ms); we use a slight buffer
- // so the navigation kicks in just as the animation ends. The
- // destination playground page handles its own entry animation
- // declaratively via CSS @starting-style (no cross-page state
- // signaling needed — first paint of the editor + preview
- // panels animates in unconditionally).
- window.setTimeout(() => {
- router.push(customizeHref);
- }, 420);
- },
- [router, customizeHref],
+ // Open in Playground destination: the main /playground seeded with
+ // the theme-showcase template in the code editor (#code) and the
+ // selected theme in the theme editor (?theme=<slug>). The button's
+ // href does a plain full-page navigation, which the playground needs
+ // to read the seeded code from window.location.hash reliably at
+ // mount (App Router soft navigation doesn't reliably commit the hash
+ // before that read, so the code could fall back to DEFAULT_CODE).
+ const customizeHref = buildPlaygroundHref(
+ THEME_SHOWCASE_SOURCE,
+ packageNameToSlug(selectedPkgName),
);
return (
<div {...stylex.props(styles.twoColumn)}>
{/* Sidebar — sticky on desktop, hidden on narrow viewports
(the mobile bar in the right column takes over). Holds:
- hero block (heading + description + Customize CTA + mode
+ hero block (heading + description + Open in Playground CTA + mode
toggle), divider, and the theme picker (one card per
theme). */}
- <aside
- {...stylex.props(styles.sidebar, isLeaving && styles.sidebarLeaving)}
- aria-label="Theme picker">
+ <aside {...stylex.props(styles.sidebar)} aria-label="Theme picker">
<XDSCard variant="default" padding={0} xstyle={styles.sidebarCard}>
<XDSVStack gap={4}>
{/* Hero block — page-level heading + description + CTAs.
@@ -663,10 +592,16 @@ export function ThemePackagePage({packageName, theme}: ThemePackagePageProps) {
<XDSButton
variant="primary"
size="lg"
- label="Customize"
+ label="Open in Playground"
href={customizeHref}
- onClick={handleCustomizeClick}
xstyle={styles.heroPrimaryButton}
+ onClick={() => {
+ trackOpenPlayground({
+ page: 'themes',
+ item: selectedPkgName,
+ source: 'theme-showcase',
+ });
+ }}
/>
<XDSButton
variant="ghost"
@@ -796,26 +731,17 @@ export function ThemePackagePage({packageName, theme}: ThemePackagePageProps) {
/>
</div>
- <XDSTheme theme={selectedTheme} mode={mode}>
- <XDSCard
- padding={0}
- variant="transparent"
- xstyle={styles.previewCard}>
- <ThemeShowcasePreview images={images} />
- </XDSCard>
- </XDSTheme>
-
- {/* Real-world card showcase — sits OUTSIDE the live preview
- card so it renders on the docsite's own astryx chrome
- rather than nested inside the theme's body color.
- Inventory + Checkout + Top customers cards flip light/
- dark in sync with the preview above via the mode prop. */}
+ {/* Themed preview — the theme-showcase template rendered with
+ the selected theme, wrapped in a bordered, rounded card so
+ it reads as a contained app surface against the docsite
+ chrome. overflow:hidden (showcaseCard) clips the template's
+ own backgrounds (top nav, sections) to the card's radius. */}
<div {...stylex.props(styles.showcaseBlock)}>
- <ThemeCardShowcase
- theme={selectedTheme}
- images={images}
- mode={mode}
- />
+ <XDSCard padding={0} xstyle={styles.showcaseCard}>
+ <XDSTheme theme={selectedTheme} mode={mode}>
+ <ThemeShowcase />
+ </XDSTheme>
+ </XDSCard>
</div>
</div>
</div>
diff --git a/apps/docsite/src/components/playgroundLink.ts b/apps/docsite/src/components/playgroundLink.ts
index ae947c8986..2daf8e77c6 100644
--- a/apps/docsite/src/components/playgroundLink.ts
+++ b/apps/docsite/src/components/playgroundLink.ts
@@ -3,9 +3,13 @@
import {compressToEncodedURIComponent} from 'lz-string';
/**
- * Build a playground URL with prepopulated source code.
+ * Build a playground URL with prepopulated source code, and optionally a
+ * seeded theme. When `theme` is given (a short theme slug like "neutral"),
+ * it's added as a `?theme=` query param so the playground opens with that
+ * theme applied + its Theme editor populated; the code rides in the hash.
*/
-export function buildPlaygroundHref(source: string): string {
+export function buildPlaygroundHref(source: string, theme?: string): string {
const compressed = compressToEncodedURIComponent(source);
- return `/playground#code=${compressed}`;
+ const query = theme ? `?theme=${encodeURIComponent(theme)}` : '';
+ return `/playground${query}#code=${compressed}`;
}
diff --git a/apps/docsite/src/lib/analytics.ts b/apps/docsite/src/lib/analytics.ts
index f660658259..d2fd3c50e0 100644
--- a/apps/docsite/src/lib/analytics.ts
+++ b/apps/docsite/src/lib/analytics.ts
@@ -29,7 +29,12 @@ type CopyTarget =
| 'share_url'
| 'install_command';
-type CtaTarget = 'install' | 'get_started' | 'github' | 'community' | 'customize';
+type CtaTarget =
+ | 'install'
+ | 'get_started'
+ | 'github'
+ | 'community'
+ | 'customize';
type NavigateTarget = 'prev_next' | 'tab' | 'view';
diff --git a/packages/cli/templates/pages/theme-showcase/page.tsx b/packages/cli/templates/pages/theme-showcase/page.tsx
new file mode 100644
index 0000000000..7fd50e92f8
--- /dev/null
+++ b/packages/cli/templates/pages/theme-showcase/page.tsx
@@ -0,0 +1,1218 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+import {type CSSProperties, type ReactNode} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {
+ Plus,
+ Search,
+ Tag,
+ Folder,
+ MapPin,
+ List,
+ LayoutGrid,
+ ShoppingBag,
+ Banknote,
+ Mic,
+ CreditCard,
+ Lock,
+ X,
+ Download,
+ Smartphone,
+ Wallet,
+ User,
+} from 'lucide-react';
+import {XDSText, XDSHeading} from '@xds/core/Text';
+import {XDSVStack, XDSHStack} from '@xds/core/Layout';
+import {XDSGrid, XDSGridSpan} from '@xds/core/Grid';
+import {XDSCard} from '@xds/core/Card';
+import {XDSButton} from '@xds/core/Button';
+import {XDSLink} from '@xds/core/Link';
+import {XDSBadge} from '@xds/core/Badge';
+import {XDSBanner} from '@xds/core/Banner';
+import {XDSDivider} from '@xds/core/Divider';
+import {XDSCheckboxInput} from '@xds/core/CheckboxInput';
+import {XDSItem} from '@xds/core/Item';
+import {XDSTable, proportional, pixel} from '@xds/core/Table';
+import {XDSTextInput} from '@xds/core/TextInput';
+import {XDSSelector} from '@xds/core/Selector';
+import {XDSRadioList, XDSRadioListItem} from '@xds/core/RadioList';
+import {XDSSelectableCard} from '@xds/core/SelectableCard';
+import {XDSMoreMenu} from '@xds/core/MoreMenu';
+import {XDSCenter} from '@xds/core/Center';
+import {XDSSection} from '@xds/core/Section';
+import {XDSAspectRatio} from '@xds/core/AspectRatio';
+import {XDSNumberInput} from '@xds/core/NumberInput';
+import {XDSTopNav, XDSTopNavHeading, XDSTopNavItem} from '@xds/core/TopNav';
+import {
+ XDSChatComposer,
+ XDSChatMessage,
+ XDSChatMessageBubble,
+ XDSChatMessageList,
+ XDSChatSystemMessage,
+} from '@xds/core/Chat';
+
+// Styles passed to XDS components via their `xstyle` prop. These are
+// applied by the components themselves, so they work in compiled builds
+// and in the live playground preview alike.
+const styles = stylex.create({
+ card: {
+ backgroundColor: 'var(--color-background-body)',
+ color: 'var(--color-text-primary)',
+ minWidth: 0,
+ borderColor: 'transparent',
+ },
+ checkoutStack: {
+ minWidth: 0,
+ width: '100%',
+ },
+ paymentCardContent: {
+ minWidth: 0,
+ width: '100%',
+ textAlign: 'center',
+ wordBreak: 'break-word',
+ },
+ fullSpanAtNarrow: {
+ gridColumn: {
+ default: null,
+ '@media (max-width: 1024px)': '1 / -1',
+ },
+ },
+ inventoryCard: {
+ backgroundColor: 'var(--color-background-surface)',
+ color: 'var(--color-text-primary)',
+ overflow: 'hidden',
+ },
+ inventoryHeader: {
+ paddingBlock: 'var(--spacing-6)',
+ paddingInline: 'var(--spacing-6)',
+ },
+ inventoryFilterRow: {
+ paddingBlock: 'var(--spacing-4)',
+ paddingInline: 'var(--spacing-6)',
+ width: '100%',
+ },
+ searchInput: {
+ flex: 1,
+ minWidth: 0,
+ maxWidth: 240,
+ },
+ activityCard: {
+ backgroundColor: 'var(--color-background-surface)',
+ color: 'var(--color-text-primary)',
+ minWidth: 0,
+ height: '100%',
+ },
+ chatCard: {
+ backgroundColor: 'var(--color-background-surface)',
+ color: 'var(--color-text-primary)',
+ minWidth: 0,
+ overflow: 'hidden',
+ display: 'flex',
+ flexDirection: 'column' as const,
+ },
+ chatHeader: {
+ paddingBlock: 'var(--spacing-4)',
+ paddingInline: 'var(--spacing-4)',
+ },
+ activityCardStack: {
+ height: '100%',
+ },
+ activityListFade: {
+ flex: 1,
+ minHeight: 0,
+ overflow: 'hidden',
+ maskImage:
+ 'linear-gradient(to bottom, black calc(100% - 48px), transparent)',
+ WebkitMaskImage:
+ 'linear-gradient(to bottom, black calc(100% - 48px), transparent)',
+ marginInline: 'calc(var(--spacing-2) * -1)',
+ },
+ content: {
+ maxWidth: 960,
+ marginInline: 'auto',
+ },
+ contentFluid: {
+ maxWidth: 880,
+ },
+ heroText: {
+ textAlign: 'center' as const,
+ maxWidth: 560,
+ },
+ centerText: {
+ textAlign: 'center',
+ },
+ cardStack: {
+ height: '100%',
+ },
+ cardDescription: {
+ flex: 1,
+ },
+ quantityInput: {
+ width: 40,
+ flexShrink: 0,
+ },
+ cartButton: {
+ flex: 1,
+ },
+});
+
+// Styles applied directly to plain DOM elements via the `style` prop.
+// Kept as inline styles (rather than stylex.create) so they render in the
+// playground preview, which can't compile StyleX — `stylex.props()` is a
+// no-op there, so raw `{...stylex.props(...)}` on a <div>/<img> would lose
+// these declarations. All are static (no media/pseudo variants), so inline
+// styles reproduce them exactly.
+const inlineStyles: Record<string, CSSProperties> = {
+ inventoryBannerWrap: {
+ paddingInline: 'var(--spacing-6)',
+ paddingBottom: 'var(--spacing-4)',
+ },
+ thumbnail: {
+ width: 32,
+ height: 32,
+ borderRadius: 'var(--radius-element)',
+ objectFit: 'cover',
+ display: 'block',
+ flexShrink: 0,
+ },
+ thumbnailFallback: {
+ width: 32,
+ height: 32,
+ borderRadius: 'var(--radius-element)',
+ backgroundColor: 'var(--color-background-muted)',
+ color: 'var(--color-text-secondary)',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ fontSize: 'var(--font-size-sm)',
+ fontWeight: 600,
+ flexShrink: 0,
+ },
+ sparkline: {
+ display: 'flex',
+ alignItems: 'flex-end',
+ justifyContent: 'space-around',
+ height: 120,
+ width: '100%',
+ gap: 8,
+ },
+ sparkLabels: {
+ display: 'flex',
+ justifyContent: 'space-around',
+ width: '100%',
+ color: 'var(--color-text-secondary)',
+ fontSize: 'var(--font-size-xs)',
+ },
+ kpiValue: {
+ fontSize: 24,
+ fontWeight: 700,
+ lineHeight: 1.1,
+ color: 'var(--color-text-primary)',
+ fontFamily: 'var(--font-family-heading)',
+ letterSpacing: '-0.01em',
+ },
+ chatBody: {
+ flex: 1,
+ minHeight: 0,
+ overflow: 'hidden',
+ },
+ chatSuggestions: {
+ paddingInline: 'var(--spacing-4)',
+ paddingBottom: 'var(--spacing-2)',
+ },
+ chatComposer: {
+ paddingInline: 'var(--spacing-4)',
+ paddingBottom: 'var(--spacing-4)',
+ },
+ activityIcon: {
+ width: 32,
+ height: 32,
+ borderRadius: 'var(--radius-full)',
+ backgroundColor: 'var(--color-background-muted)',
+ color: 'var(--color-text-secondary)',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ flexShrink: 0,
+ },
+ productImage: {
+ width: '100%',
+ height: '100%',
+ objectFit: 'cover',
+ },
+ cardBody: {
+ padding: 'var(--spacing-4)',
+ flex: 1,
+ display: 'flex',
+ flexDirection: 'column',
+ },
+};
+
+// Sparkline bar — height is data-driven, so it's a function returning an
+// inline style object (same reasoning as inlineStyles above).
+const sparkBarStyle = (height: string): CSSProperties => ({
+ flex: 1,
+ minWidth: 0,
+ borderRadius: 'var(--radius-element)',
+ backgroundColor: 'var(--color-background-green)',
+ height,
+});
+
+const PRODUCT_IMAGE_KEYS = ['watch', 'headphones', 'backpack'];
+
+const PRODUCTS = [
+ {
+ name: 'Minimalist Watch',
+ description: 'Clean design meets everyday durability.',
+ badge: 'New',
+ badgeVariant: 'blue' as const,
+ },
+ {
+ name: 'Wireless Headphones',
+ description: 'Immersive sound, all-day comfort.',
+ badge: 'Popular',
+ badgeVariant: 'green' as const,
+ },
+ {
+ name: 'Canvas Backpack',
+ description: 'Water-resistant canvas with a quiet, modern profile.',
+ badge: 'Limited',
+ badgeVariant: 'yellow' as const,
+ },
+];
+
+const PREVIEW_IMAGES: Record<string, string> = {
+ watch: '/neutral/preview-watch.png',
+ headphones: '/neutral/preview-headphones.png',
+ backpack: '/neutral/preview-backpack.png',
+ wallet: '/neutral/preview-wallet.png',
+ mug: '/neutral/preview-mug.png',
+ throw_: '/neutral/preview-throw.png',
+};
+
+export default function ThemeShowcase() {
+ const images: Record<string, string> = PREVIEW_IMAGES;
+ return (
+ <div
+ style={{
+ minHeight: '100%',
+ backgroundColor: 'var(--color-background-body)',
+ }}>
+ <StorePreview images={images} />
+ <div
+ style={{
+ padding: 'var(--spacing-6)',
+ backgroundColor: 'var(--color-background-surface)',
+ }}>
+ <CardShowcase images={images} />
+ </div>
+ </div>
+ );
+}
+
+function CardShowcase({images}: {images: Record<string, string>}) {
+ return (
+ <XDSVStack gap={8}>
+ <XDSGrid columns={{minWidth: 200, repeat: 'fit'}} gap={4}>
+ <XDSGridSpan columns={1} xstyle={styles.fullSpanAtNarrow}>
+ <CheckoutCard />
+ </XDSGridSpan>
+ <XDSGridSpan columns={2} xstyle={styles.fullSpanAtNarrow}>
+ <ChatCard />
+ </XDSGridSpan>
+ </XDSGrid>
+ <XDSGrid columns={{minWidth: 200, repeat: 'fit'}} gap={4}>
+ <XDSGridSpan columns={3} xstyle={styles.fullSpanAtNarrow}>
+ <InventoryCard images={images} />
+ </XDSGridSpan>
+ <XDSGridSpan columns={1} xstyle={styles.fullSpanAtNarrow}>
+ <LatestActivityCard />
+ </XDSGridSpan>
+ </XDSGrid>
+ </XDSVStack>
+ );
+}
+
+function StorePreview({images}: {images: Record<string, string>}) {
+ return (
+ <div data-theme-preview="true">
+ <XDSVStack gap={0}>
+ <XDSTopNav
+ label="Theme preview navigation"
+ heading={<XDSTopNavHeading heading="Studio" />}
+ centerContent={
+ <>
+ <XDSTopNavItem label="Shop" href="#" isSelected />
+ <XDSTopNavItem label="New In" href="#" />
+ <XDSTopNavItem label="Stories" href="#" />
+ <XDSTopNavItem label="Help" href="#" />
+ </>
+ }
+ endContent={
+ <XDSHStack gap={2} vAlign="center">
+ <XDSHStack gap={0.5}>
+ <XDSButton
+ label="Search"
+ tooltip="Search"
+ variant="ghost"
+ isIconOnly
+ icon={<Search size={20} />}
+ href="#"
+ />
+ <XDSButton
+ label="Account"
+ tooltip="Account"
+ variant="ghost"
+ isIconOnly
+ icon={<User size={20} />}
+ href="#"
+ />
+ <XDSButton
+ label="Cart"
+ tooltip="Cart"
+ variant="ghost"
+ isIconOnly
+ icon={<ShoppingBag size={20} />}
+ href="#"
+ />
+ </XDSHStack>
+ <XDSButton label="Sign in" variant="primary" href="#" />
+ </XDSHStack>
+ }
+ />
+
+ <XDSSection padding={8} variant="transparent">
+ <XDSVStack gap={10} xstyle={[styles.content, styles.contentFluid]}>
+ <XDSCenter>
+ <XDSVStack gap={4} hAlign="center" xstyle={styles.heroText}>
+ <XDSText type="display-3">
+ Little joys,
+ <br />
+ everywhere you go
+ </XDSText>
+ <XDSText type="body" color="secondary">
+ We believe the smallest details are the ones that matter most.
+ Turn an ordinary day into something worth remembering.
+ </XDSText>
+ </XDSVStack>
+ </XDSCenter>
+
+ <XDSGrid columns={{minWidth: 240}} gap={4}>
+ {PRODUCTS.map((p, i) => (
+ <XDSCard key={p.name} padding={0} height="100%">
+ <XDSVStack gap={0} xstyle={styles.cardStack}>
+ <XDSAspectRatio ratio={1}>
+ <img
+ src={images[PRODUCT_IMAGE_KEYS[i]]}
+ alt={p.name}
+ style={inlineStyles.productImage}
+ />
+ </XDSAspectRatio>
+ <div style={inlineStyles.cardBody}>
+ <XDSVStack
+ gap={2}
+ hAlign="center"
+ xstyle={styles.cardStack}>
+ <XDSHStack>
+ <XDSBadge label={p.badge} variant={p.badgeVariant} />
+ </XDSHStack>
+ <XDSHeading level={2} xstyle={styles.centerText}>
+ {p.name}
+ </XDSHeading>
+ <XDSText
+ type="supporting"
+ color="secondary"
+ xstyle={[styles.cardDescription, styles.centerText]}>
+ {p.description}
+ </XDSText>
+ <XDSHStack gap={2} vAlign="center" hAlign="center">
+ <XDSNumberInput
+ label="Quantity"
+ isLabelHidden
+ value={1}
+ onChange={() => {}}
+ min={1}
+ max={99}
+ size="sm"
+ xstyle={styles.quantityInput}
+ />
+ <XDSButton
+ label="Add to cart"
+ variant="secondary"
+ href="#"
+ xstyle={styles.cartButton}
+ />
+ </XDSHStack>
+ </XDSVStack>
+ </div>
+ </XDSVStack>
+ </XDSCard>
+ ))}
+ </XDSGrid>
+ </XDSVStack>
+ </XDSSection>
+ </XDSVStack>
+ </div>
+ );
+}
+
+function CheckoutCard() {
+ return (
+ <XDSCard padding={5} xstyle={styles.card}>
+ <XDSVStack gap={4} xstyle={styles.checkoutStack}>
+ <XDSHeading level={2}>Checkout</XDSHeading>
+
+ <XDSVStack gap={3} xstyle={styles.checkoutStack}>
+ <XDSTextInput
+ label="Email"
+ placeholder="[email protected]"
+ value=""
+ onChange={() => {}}
+ size="lg"
+ />
+
+ <XDSRadioList
+ label="Shipping method"
+ description="Delivery time may vary based on location and availability."
+ value="economy"
+ onChange={() => {}}>
+ <XDSRadioListItem
+ value="economy"
+ label="Economy Shipping"
+ description="Delivered in 5–7 business days"
+ endContent={
+ <XDSText type="body" weight="bold">
+ $12.00
+ </XDSText>
+ }
+ />
+ <XDSRadioListItem
+ value="standard"
+ label="Standard Shipping"
+ description="Delivered in 3–5 business days"
+ endContent={
+ <XDSText type="body" weight="bold">
+ $16.00
+ </XDSText>
+ }
+ />
+ <XDSRadioListItem
+ value="express"
+ label="Express Shipping"
+ description="Delivered in 1–2 business days"
+ endContent={
+ <XDSText type="body" weight="bold">
+ $24.00
+ </XDSText>
+ }
+ />
+ </XDSRadioList>
+
+ <XDSVStack gap={2} xstyle={styles.checkoutStack}>
+ <XDSText type="supporting" weight="bold">
+ Payment method
+ </XDSText>
+ <XDSGrid columns={{minWidth: 70, max: 3}} gap={2}>
+ <XDSSelectableCard
+ label="Pay with card"
+ isSelected={true}
+ onChange={() => {}}
+ padding={3}>
+ <XDSVStack
+ gap={1}
+ hAlign="center"
+ xstyle={styles.paymentCardContent}>
+ <CreditCard size={20} />
+ <XDSText type="supporting" weight="bold">
+ Card
+ </XDSText>
+ </XDSVStack>
+ </XDSSelectableCard>
+ <XDSSelectableCard
+ label="Pay with Apple Pay"
+ isSelected={false}
+ onChange={() => {}}
+ padding={3}>
+ <XDSVStack
+ gap={1}
+ hAlign="center"
+ xstyle={styles.paymentCardContent}>
+ <Smartphone size={20} />
+ <XDSText type="supporting" weight="bold">
+ Apple Pay
+ </XDSText>
+ </XDSVStack>
+ </XDSSelectableCard>
+ <XDSSelectableCard
+ label="Pay with Google Pay"
+ isSelected={false}
+ onChange={() => {}}
+ padding={3}>
+ <XDSVStack
+ gap={1}
+ hAlign="center"
+ xstyle={styles.paymentCardContent}>
+ <Wallet size={20} />
+ <XDSText type="supporting" weight="bold">
+ Google Pay
+ </XDSText>
+ </XDSVStack>
+ </XDSSelectableCard>
+ </XDSGrid>
+ </XDSVStack>
+
+ <XDSTextInput
+ label="Card number"
+ placeholder="1234 1234 1234 1234"
+ value=""
+ onChange={() => {}}
+ startIcon={<CreditCard size={16} />}
+ size="lg"
+ />
+
+ <XDSGrid columns={{minWidth: 90, max: 2}} gap={2}>
+ <XDSTextInput
+ label="Expiry"
+ placeholder="MM / YY"
+ value=""
+ onChange={() => {}}
+ size="lg"
+ />
+ <XDSTextInput
+ label="CVC"
+ placeholder="123"
+ value=""
+ onChange={() => {}}
+ size="lg"
+ />
+ </XDSGrid>
+
+ <XDSSelector
+ label="Country"
+ value="us"
+ onChange={() => {}}
+ size="lg"
+ options={[
+ {value: 'us', label: 'United States'},
+ {value: 'ca', label: 'Canada'},
+ {value: 'uk', label: 'United Kingdom'},
+ {value: 'de', label: 'Germany'},
+ {value: 'jp', label: 'Japan'},
+ {value: 'au', label: 'Australia'},
+ ]}
+ />
+ </XDSVStack>
+
+ <XDSCheckboxInput
+ label="Securely save my information for 1-click checkout"
+ description="Pay faster on Studio and everywhere Link is accepted."
+ value={true}
+ onChange={() => {}}
+ />
+
+ <XDSButton
+ variant="primary"
+ size="lg"
+ label="Pay now"
+ icon={<Lock size={16} />}
+ />
+ </XDSVStack>
+ </XDSCard>
+ );
+}
+
+const SUGGESTED_QUESTIONS = [
+ 'Reschedule delivery',
+ 'Update shipping address',
+ 'Start a return',
+];
+
+function ChatCard() {
+ return (
+ <XDSCard padding={0} xstyle={styles.chatCard}>
+ <XDSHStack
+ hAlign="between"
+ vAlign="center"
+ gap={3}
+ xstyle={styles.chatHeader}>
+ <XDSHeading level={2}>Studio AI</XDSHeading>
+
+ <XDSHStack gap={1} vAlign="center">
+ <XDSButton
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ label="Export conversation"
+ tooltip="Export conversation"
+ icon={<Download size={16} />}
+ />
+ <XDSButton
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ label="Close chat"
+ tooltip="Close chat"
+ icon={<X size={16} />}
+ />
+ </XDSHStack>
+ </XDSHStack>
+
+ <XDSDivider variant="subtle" />
+
+ <div style={inlineStyles.chatBody}>
+ <XDSChatMessageList>
+ <XDSChatSystemMessage>Today</XDSChatSystemMessage>
+
+ <XDSChatMessage sender="user">
+ <XDSChatMessageBubble variant="filled">
+ Where’s my order?
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+
+ <XDSChatMessage sender="assistant">
+ <XDSVStack gap={3}>
+ <XDSText type="body">
+ Your order #1043 — the Minimalist Watch and Linen Throw —
+ shipped this morning from the Aisle 3 warehouse and is currently
+ in transit with UPS. It’s on track to arrive at your address by
+ end of day tomorrow.
+ </XDSText>
+ <XDSText type="body">
+ Let me know if you’d like to reschedule the delivery, redirect
+ it to a pickup point, or start a return once it arrives.
+ </XDSText>
+ </XDSVStack>
+ </XDSChatMessage>
+
+ <XDSChatMessage sender="user">
+ <XDSChatMessageBubble variant="filled">
+ Can you show me the full details?
+ </XDSChatMessageBubble>
+ </XDSChatMessage>
+
+ <XDSChatMessage sender="assistant">
+ <XDSVStack gap={3}>
+ <XDSText type="body">
+ Here’s everything I have on order #1043:
+ </XDSText>
+ <XDSCard padding={3}>
+ <XDSVStack gap={1}>
+ <XDSItem
+ label="Items"
+ description="Minimalist Watch · Linen Throw"
+ trailing={
+ <XDSText type="body" weight="bold">
+ $248
+ </XDSText>
+ }
+ />
+ <XDSItem
+ label="Shipping"
+ description="UPS Ground"
+ trailing={
+ <XDSText type="body" weight="bold">
+ $12
+ </XDSText>
+ }
+ />
+ <XDSItem
+ label="Estimated arrival"
+ description="Tomorrow by 8pm"
+ trailing={<XDSBadge variant="green" label="On time" />}
+ />
+ <XDSItem
+ label="Tracking"
+ description="UPS 1Z 999 AA1 0123 4567 84"
+ trailing={<XDSLink href="#">Track →</XDSLink>}
+ />
+ </XDSVStack>
+ </XDSCard>
+ </XDSVStack>
+ </XDSChatMessage>
+ </XDSChatMessageList>
+ </div>
+
+ <div style={inlineStyles.chatSuggestions}>
+ <XDSHStack gap={1} hAlign="center" wrap="wrap">
+ {SUGGESTED_QUESTIONS.map(question => (
+ <XDSButton
+ key={question}
+ variant="secondary"
+ size="sm"
+ label={question}
+ />
+ ))}
+ </XDSHStack>
+ </div>
+
+ <div style={inlineStyles.chatComposer}>
+ <XDSChatComposer
+ value=""
+ onChange={() => {}}
+ onSubmit={() => {}}
+ placeholder="Ask Studio AI…"
+ footerActions={
+ <XDSButton
+ variant="ghost"
+ size="md"
+ isIconOnly
+ label="Attach"
+ tooltip="Attach"
+ icon={<Plus size={16} />}
+ />
+ }
+ sendActions={
+ <XDSButton
+ variant="ghost"
+ size="md"
+ isIconOnly
+ label="Voice input"
+ tooltip="Voice input"
+ icon={<Mic size={16} />}
+ />
+ }
+ />
+ </div>
+ </XDSCard>
+ );
+}
+
+const SPARKLINE_DATA = [55, 70, 92, 78, 60];
+const SPARKLINE_LABELS = ['Jan', 'Feb', 'Mar', 'Apr', 'May'];
+
+interface ActivityRow {
+ id: string;
+ icon: ReactNode;
+ label: string;
+ detail: string;
+ time: string;
+ amount: number;
+}
+
+const ACTIVITY: ActivityRow[] = [
+ {
+ id: '1',
+ icon: <ShoppingBag size={16} />,
+ label: 'Order #1043',
+ detail: 'Placed · 1:59 pm',
+ time: '1:59 pm',
+ amount: 248,
+ },
+ {
+ id: '2',
+ icon: <Banknote size={16} />,
+ label: 'Order #1041',
+ detail: 'Refunded · 12:40 pm',
+ time: '12:40 pm',
+ amount: -89,
+ },
+ {
+ id: '3',
+ icon: <ShoppingBag size={16} />,
+ label: 'Order #1040',
+ detail: 'Placed · 10:30 am',
+ time: '10:30 am',
+ amount: 156,
+ },
+ {
+ id: '4',
+ icon: <ShoppingBag size={16} />,
+ label: 'Order #1038',
+ detail: 'Placed · 9:11 am',
+ time: '9:11 am',
+ amount: 412,
+ },
+ {
+ id: '5',
+ icon: <ShoppingBag size={16} />,
+ label: 'Order #1037',
+ detail: 'Placed · 8:42 am',
+ time: '8:42 am',
+ amount: 95,
+ },
+];
+
+function formatAmount(amount: number): string {
+ const sign = amount < 0 ? '−' : '+';
+ return sign + '$' + Math.abs(amount).toLocaleString();
+}
+
+function LatestActivityCard() {
+ return (
+ <XDSCard padding={5} xstyle={styles.activityCard}>
+ <XDSVStack gap={4} xstyle={styles.activityCardStack}>
+ <XDSHeading level={2}>Revenue</XDSHeading>
+
+ <XDSVStack gap={2}>
+ <div style={inlineStyles.sparkline} aria-hidden="true">
+ {SPARKLINE_DATA.map((value, i) => (
+ <div key={i} style={sparkBarStyle(value + '%')} />
+ ))}
+ </div>
+ <div style={inlineStyles.sparkLabels} aria-hidden="true">
+ {SPARKLINE_LABELS.map(label => (
+ <span key={label}>{label}</span>
+ ))}
+ </div>
+ </XDSVStack>
+
+ <XDSGrid columns={2} gap={3}>
+ <XDSVStack gap={0}>
+ <span style={inlineStyles.kpiValue}>18K</span>
+ <XDSText type="supporting" color="secondary">
+ Monthly revenue
+ </XDSText>
+ </XDSVStack>
+ <XDSVStack gap={0}>
+ <span style={inlineStyles.kpiValue}>+12%</span>
+ <XDSText type="supporting" color="secondary">
+ Order growth
+ </XDSText>
+ </XDSVStack>
+ </XDSGrid>
+
+ <XDSDivider variant="subtle" />
+
+ <XDSHStack hAlign="between" vAlign="center">
+ <XDSHeading level={3}>Activity</XDSHeading>
+ <XDSLink href="#">See all</XDSLink>
+ </XDSHStack>
+
+ <XDSVStack gap={1} xstyle={styles.activityListFade}>
+ {ACTIVITY.map(item => (
+ <XDSItem
+ key={item.id}
+ media={
+ <div style={inlineStyles.activityIcon} aria-hidden="true">
+ {item.icon}
+ </div>
+ }
+ label={item.label}
+ description={item.detail}
+ trailing={
+ <XDSText
+ type="body"
+ weight="bold"
+ color={item.amount < 0 ? 'secondary' : 'primary'}>
+ {formatAmount(item.amount)}
+ </XDSText>
+ }
+ href="#"
+ />
+ ))}
+ </XDSVStack>
+ </XDSVStack>
+ </XDSCard>
+ );
+}
+
+type TagSpec = {label: string; variant: 'blue' | 'green' | 'orange' | 'yellow'};
+
+interface InventoryRow extends Record<string, unknown> {
+ id: string;
+ name: string;
+ meta: string;
+ available: number;
+ location: string;
+ tags: TagSpec[];
+ imageKey?: string;
+ thumbnailFallback: string;
+ selected: boolean;
+}
+
+const INVENTORY: InventoryRow[] = [
+ {
+ id: 'a',
+ name: 'Minimalist Watch',
+ meta: 'Stainless steel, sapphire crystal',
+ available: 42,
+ location: 'Aisle 3',
+ tags: [{label: 'New', variant: 'blue'}],
+ imageKey: 'watch',
+ thumbnailFallback: 'M',
+ selected: false,
+ },
+ {
+ id: 'b',
+ name: 'Wireless Headphones',
+ meta: 'ANC, 30hr battery',
+ available: 128,
+ location: 'Aisle 1',
+ tags: [{label: 'Popular', variant: 'green'}],
+ imageKey: 'headphones',
+ thumbnailFallback: 'W',
+ selected: true,
+ },
+ {
+ id: 'c',
+ name: 'Canvas Backpack',
+ meta: 'Water-resistant, 25L',
+ available: 63,
+ location: 'Aisle 2',
+ tags: [{label: 'Limited', variant: 'yellow'}],
+ imageKey: 'backpack',
+ thumbnailFallback: 'C',
+ selected: false,
+ },
+ {
+ id: 'd',
+ name: 'Leather Wallet',
+ meta: 'Full-grain, RFID blocking',
+ available: 15,
+ location: 'Aisle 4',
+ tags: [{label: 'Leather', variant: 'yellow'}],
+ imageKey: 'wallet',
+ thumbnailFallback: 'L',
+ selected: true,
+ },
+ {
+ id: 'e',
+ name: 'Travel Mug',
+ meta: 'Vacuum insulated, 16oz',
+ available: 87,
+ location: 'Aisle 5',
+ tags: [{label: 'Drinkware', variant: 'green'}],
+ imageKey: 'mug',
+ thumbnailFallback: 'T',
+ selected: false,
+ },
+ {
+ id: 'f',
+ name: 'Linen Throw',
+ meta: 'Heavyweight, oat',
+ available: 24,
+ location: 'Aisle 6',
+ tags: [{label: 'Home', variant: 'orange'}],
+ imageKey: 'throw_',
+ thumbnailFallback: 'L',
+ selected: true,
+ },
+];
+
+const LOW_STOCK_THRESHOLD = 25;
+const LOW_STOCK_COUNT = INVENTORY.filter(
+ row => row.available < LOW_STOCK_THRESHOLD,
+).length;
+
+function SelectCell({row}: {row: InventoryRow}) {
+ return (
+ <XDSCheckboxInput
+ label={'Select ' + row.name}
+ isLabelHidden
+ value={row.selected}
+ onChange={() => {}}
+ />
+ );
+}
+
+function ItemCell({
+ row,
+ images,
+}: {
+ row: InventoryRow;
+ images: Record<string, string>;
+}) {
+ const thumbnailSrc = row.imageKey ? images[row.imageKey] : undefined;
+ return (
+ <XDSHStack gap={3} vAlign="center">
+ {thumbnailSrc ? (
+ <img src={thumbnailSrc} alt="" style={inlineStyles.thumbnail} />
+ ) : (
+ <div style={inlineStyles.thumbnailFallback} aria-hidden="true">
+ {row.thumbnailFallback}
+ </div>
+ )}
+ <XDSVStack gap={0} style={{minWidth: 0}}>
+ <XDSText type="body" weight="bold">
+ {row.name}
+ </XDSText>
+ <XDSText type="supporting" color="secondary">
+ {row.meta}
+ </XDSText>
+ </XDSVStack>
+ </XDSHStack>
+ );
+}
+
+function TagsCell({row}: {row: InventoryRow}) {
+ return (
+ <XDSHStack gap={1} wrap="wrap" hAlign="end">
+ {row.tags.map(tag => (
+ <XDSBadge key={tag.label} label={tag.label} variant={tag.variant} />
+ ))}
+ </XDSHStack>
+ );
+}
+
+function ActionsCell() {
+ return (
+ <XDSMoreMenu
+ label="Row actions"
+ items={[
+ {label: 'Edit'},
+ {label: 'Duplicate'},
+ {label: 'Move to…'},
+ {type: 'divider'},
+ {label: 'Delete'},
+ ]}
+ />
+ );
+}
+
+function InventoryCard({images}: {images: Record<string, string>}) {
+ return (
+ <XDSCard padding={0} xstyle={styles.inventoryCard}>
+ <XDSHStack
+ hAlign="between"
+ vAlign="center"
+ xstyle={styles.inventoryHeader}>
+ <XDSHeading level={2}>Inventory</XDSHeading>
+ <XDSButton
+ label="Add item"
+ variant="primary"
+ size="sm"
+ icon={<Plus size={16} />}
+ />
+ </XDSHStack>
+
+ <XDSDivider variant="subtle" />
+
+ <XDSHStack
+ gap={3}
+ vAlign="center"
+ hAlign="between"
+ xstyle={styles.inventoryFilterRow}>
+ <XDSHStack gap={2} vAlign="center" style={{flex: 1, minWidth: 0}}>
+ <XDSTextInput
+ label="Search inventory"
+ isLabelHidden
+ placeholder="Type and hit enter…"
+ value=""
+ onChange={() => {}}
+ startIcon={<Search size={16} />}
+ xstyle={styles.searchInput}
+ />
+ <XDSSelector
+ label="Categories"
+ isLabelHidden
+ placeholder="Categories"
+ size="sm"
+ startIcon={<Folder size={16} />}
+ value={undefined}
+ onChange={() => {}}
+ options={['Wearables', 'Audio', 'Bags', 'Drinkware', 'Home']}
+ />
+ <XDSSelector
+ label="Locations"
+ isLabelHidden
+ placeholder="Locations"
+ size="sm"
+ startIcon={<MapPin size={16} />}
+ value={undefined}
+ onChange={() => {}}
+ options={[
+ 'Aisle 1',
+ 'Aisle 2',
+ 'Aisle 3',
+ 'Aisle 4',
+ 'Aisle 5',
+ 'Aisle 6',
+ ]}
+ />
+ <XDSSelector
+ label="Tags"
+ isLabelHidden
+ placeholder="Tags"
+ size="sm"
+ startIcon={<Tag size={16} />}
+ value={undefined}
+ onChange={() => {}}
+ options={[
+ 'New',
+ 'Popular',
+ 'Limited',
+ 'Leather',
+ 'Drinkware',
+ 'Home',
+ ]}
+ />
+ </XDSHStack>
+ <XDSHStack gap={1} vAlign="center">
+ <XDSButton
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ label="List view"
+ tooltip="List view"
+ icon={<List size={18} />}
+ />
+ <XDSButton
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ label="Grid view"
+ tooltip="Grid view"
+ icon={<LayoutGrid size={18} />}
+ />
+ </XDSHStack>
+ </XDSHStack>
+
+ {LOW_STOCK_COUNT > 0 && (
+ <div style={inlineStyles.inventoryBannerWrap}>
+ <XDSBanner
+ status="warning"
+ title={LOW_STOCK_COUNT + ' items are running low'}
+ />
+ </div>
+ )}
+
+ <XDSTable<InventoryRow>
+ data={INVENTORY}
+ columns={[
+ {
+ key: 'select',
+ header: '',
+ width: pixel(48),
+ renderCell: row => <SelectCell row={row} />,
+ },
+ {
+ key: 'item',
+ header: 'Item',
+ width: proportional(3),
+ renderCell: row => <ItemCell row={row} images={images} />,
+ },
+ {
+ key: 'available',
+ header: 'Available',
+ width: pixel(100),
+ renderCell: row => <XDSText type="body">{row.available}</XDSText>,
+ },
+ {
+ key: 'location',
+ header: 'Location',
+ width: pixel(100),
+ renderCell: row => <XDSText type="body">{row.location}</XDSText>,
+ },
+ {
+ key: 'tags',
+ header: 'Tags',
+ width: proportional(2),
+ align: 'end',
+ renderCell: row => <TagsCell row={row} />,
+ },
+ {
+ key: 'actions',
+ header: '',
+ width: pixel(48),
+ renderCell: () => <ActionsCell />,
+ },
+ ]}
+ density="spacious"
+ dividers="rows"
+ hasHover
+ />
+ </XDSCard>
+ );
+}
diff --git a/packages/cli/templates/pages/theme-showcase/template.doc.mjs b/packages/cli/templates/pages/theme-showcase/template.doc.mjs
new file mode 100644
index 0000000000..1c3bdf997d
--- /dev/null
+++ b/packages/cli/templates/pages/theme-showcase/template.doc.mjs
@@ -0,0 +1,16 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/** @type {import('../../../../core/src/docs-types').TemplateDoc} */
+export const doc = {
+ type: 'page',
+ name: 'Theme Showcase',
+ displayName: 'Theme Showcase',
+ description:
+ 'Real-world product surfaces (store, checkout, chat, inventory) used to preview a theme in the playground',
+ isReady: true,
+ // Surfaced via the Themes page "Open in Playground" action, not the
+ // Templates gallery, so keep it out of the overview + playground menu.
+ // No `category` — it's hidden from the overview gallery (the only consumer
+ // of `category`), and 'Showcase' isn't part of the TemplateCategory taxonomy.
+ isHiddenFromOverview: true,
+};