Skip to content

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

TypeScript

Layers, Tooltip, HoverCard (#14)

Cindy Zhang8c479d5d5ed8
diff --git a/.context/explorations/layer-components.md b/.context/explorations/layer-components.md
new file mode 100644
index 0000000000..e3b270fa73
--- /dev/null
+++ b/.context/explorations/layer-components.md
@@ -0,0 +1,65 @@
+# Layer Components
+
+Status tracking for layer component implementation.
+
+## Completed ✓
+
+| Component | Hook | Status |
+|-----------|------|--------|
+| useXDSLayer | — | ✓ Core hook with context/fixed modes |
+| XDSHoverCard | useXDSHoverCard | ✓ Interactive hover content |
+| XDSTooltip | useXDSTooltip | ✓ Inverted colors, non-interactive |
+
+All completed components are themeable via `ComponentStyles`.
+
+See `/packages/core/src/Layer/README.md` for full API documentation.
+
+## Planned
+
+### Anchored Layers (useXDSLayer)
+
+Position relative to trigger element via CSS anchor positioning.
+
+| Component | Trigger | Notes |
+|-----------|---------|-------|
+| Popover | Click | Light-dismiss with `popover="auto"` |
+| Menu | Click | Keyboard navigation, selection |
+
+### Modal Layers (`<dialog>`)
+
+Use `<dialog>` element with `showModal()` for focus trap, backdrop, Escape handling.
+
+| Component | Behavior | Notes |
+|-----------|----------|-------|
+| Dialog | Centered | Scale/fade animation |
+| Sheet | Edge-anchored | Slides from edge |
+
+### Viewport Layers (popover + fixed)
+
+Position relative to viewport, not an anchor element.
+
+| Component | Position | Notes |
+|-----------|----------|-------|
+| Toast | Corner (e.g., top-right) | Stacks multiple, auto-dismiss |
+
+Toast uses `popover="manual"` for top-layer + `position: fixed` for viewport positioning.
+
+## XDSLayerProvider
+
+Unified provider for all imperative layers (Dialog, Sheet, Toast).
+
+```tsx
+<XDSLayerProvider toastInset={{ bottom: 60 }}> {/* Clear footer */}
+ <App />
+</XDSLayerProvider>
+```
+
+Responsibilities:
+- Stacking order enforcement (Toast > Dialog > Sheet)
+- Toast positioning configuration (`toastInset`, `toastPosition`)
+- Imperative API via hooks (`useDialog`, `useSheet`, `useToast`)
+
+## References
+
+- [CSS Anchor Positioning](https://drafts.csswg.org/css-anchor-position-1/)
+- [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
diff --git a/apps/storybook/stories/HoverCard.stories.tsx b/apps/storybook/stories/HoverCard.stories.tsx
new file mode 100644
index 0000000000..24d91a38b4
--- /dev/null
+++ b/apps/storybook/stories/HoverCard.stories.tsx
@@ -0,0 +1,203 @@
+import type { Meta, StoryObj } from '@storybook/react';
+import { XDSHoverCard, useXDSHoverCard } from '@xds/core/Layer';
+import { XDSButton } from '@xds/core/Button';
+import { XDSVStack, XDSHStack } from '@xds/core/Layout';
+
+const meta: Meta<typeof XDSHoverCard> = {
+ title: 'Core/XDSHoverCard',
+ component: XDSHoverCard,
+ tags: ['autodocs'],
+ argTypes: {
+ placement: {
+ control: 'select',
+ options: ['above', 'below', 'start', 'end'],
+ description: 'Position relative to trigger',
+ },
+ alignment: {
+ control: 'select',
+ options: ['start', 'center', 'end'],
+ description: 'Alignment on placement axis',
+ },
+ delay: {
+ control: 'number',
+ description: 'Show delay in ms',
+ },
+ hideDelay: {
+ control: 'number',
+ description: 'Hide delay in ms',
+ },
+ isEnabled: {
+ control: 'boolean',
+ description: 'Enable/disable the hover card',
+ },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof XDSHoverCard>;
+
+// Sample content for hover cards
+function ProfileCard() {
+ return (
+ <div style={{ width: 200 }}>
+ <XDSVStack gap="space2">
+ <div style={{ fontWeight: 600 }}>Jane Doe</div>
+ <div style={{ fontSize: 14, opacity: 0.7 }}>Software Engineer</div>
+ <div style={{ fontSize: 13 }}>
+ Building great products with great people.
+ </div>
+ </XDSVStack>
+ </div>
+ );
+}
+
+export const Default: Story = {
+ args: {
+ placement: 'above',
+ content: <ProfileCard />,
+ children: <XDSButton>Hover me</XDSButton>,
+ },
+};
+
+export const Below: Story = {
+ args: {
+ placement: 'below',
+ content: <ProfileCard />,
+ children: <XDSButton>Hover me</XDSButton>,
+ },
+};
+
+export const Start: Story = {
+ args: {
+ placement: 'start',
+ content: <ProfileCard />,
+ children: <XDSButton>Hover me</XDSButton>,
+ },
+};
+
+export const End: Story = {
+ args: {
+ placement: 'end',
+ content: <ProfileCard />,
+ children: <XDSButton>Hover me</XDSButton>,
+ },
+};
+
+export const CustomDelay: Story = {
+ args: {
+ placement: 'above',
+ delay: 500,
+ hideDelay: 300,
+ content: <ProfileCard />,
+ children: <XDSButton>Slow hover (500ms)</XDSButton>,
+ },
+};
+
+export const Disabled: Story = {
+ args: {
+ placement: 'above',
+ isEnabled: false,
+ content: <ProfileCard />,
+ children: <XDSButton>Hover disabled</XDSButton>,
+ },
+};
+
+export const AllPlacements: Story = {
+ render: () => (
+ <div style={{ padding: 100, display: 'flex', gap: 24, flexWrap: 'wrap' }}>
+ <XDSHoverCard content={<ProfileCard />} placement="above">
+ <XDSButton>Above</XDSButton>
+ </XDSHoverCard>
+ <XDSHoverCard content={<ProfileCard />} placement="below">
+ <XDSButton>Below</XDSButton>
+ </XDSHoverCard>
+ <XDSHoverCard content={<ProfileCard />} placement="start">
+ <XDSButton>Start</XDSButton>
+ </XDSHoverCard>
+ <XDSHoverCard content={<ProfileCard />} placement="end">
+ <XDSButton>End</XDSButton>
+ </XDSHoverCard>
+ </div>
+ ),
+};
+
+export const WithHook: Story = {
+ render: function HookExample() {
+ const hoverCard = useXDSHoverCard({
+ placement: 'above',
+ delay: 200,
+ });
+
+ return (
+ <div style={{ padding: 100 }}>
+ <XDSButton ref={hoverCard.ref} aria-describedby={hoverCard.describedBy}>
+ Using hook directly
+ </XDSButton>
+ {hoverCard.renderHoverCard(<ProfileCard />)}
+ </div>
+ );
+ },
+};
+
+export const InteractiveContent: Story = {
+ render: () => (
+ <div style={{ padding: 100 }}>
+ <XDSHoverCard
+ placement="below"
+ content={
+ <XDSVStack gap="space2">
+ <div>Interactive hover card content</div>
+ <XDSHStack gap="space2">
+ <XDSButton variant="primary">Follow</XDSButton>
+ <XDSButton>Message</XDSButton>
+ </XDSHStack>
+ </XDSVStack>
+ }
+ >
+ <XDSButton>Hover for interactive content</XDSButton>
+ </XDSHoverCard>
+ </div>
+ ),
+};
+
+export const TextNode: Story = {
+ render: () => (
+ <div style={{ padding: 100 }}>
+ <p>
+ This feature was created by{' '}
+ <XDSHoverCard content={<ProfileCard />} placement="above">
+ Jane Doe
+ </XDSHoverCard>{' '}
+ and shipped last week.
+ </p>
+ </div>
+ ),
+};
+
+export const TextNodeMultiple: Story = {
+ render: () => (
+ <div style={{ padding: 100 }}>
+ <p>
+ The project is maintained by{' '}
+ <XDSHoverCard content={<ProfileCard />} placement="above">
+ Jane Doe
+ </XDSHoverCard>
+ ,{' '}
+ <XDSHoverCard
+ content={
+ <div style={{ width: 200 }}>
+ <XDSVStack gap="space2">
+ <div style={{ fontWeight: 600 }}>John Smith</div>
+ <div style={{ fontSize: 14, opacity: 0.7 }}>Product Manager</div>
+ </XDSVStack>
+ </div>
+ }
+ placement="above"
+ >
+ John Smith
+ </XDSHoverCard>
+ , and others.
+ </p>
+ </div>
+ ),
+};
diff --git a/apps/storybook/stories/Tooltip.stories.tsx b/apps/storybook/stories/Tooltip.stories.tsx
new file mode 100644
index 0000000000..0970944624
--- /dev/null
+++ b/apps/storybook/stories/Tooltip.stories.tsx
@@ -0,0 +1,182 @@
+import type { Meta, StoryObj } from '@storybook/react';
+import { XDSTooltip, useXDSTooltip } from '@xds/core/Layer';
+import { XDSButton } from '@xds/core/Button';
+import { XDSHStack } from '@xds/core/Layout';
+
+const meta: Meta<typeof XDSTooltip> = {
+ title: 'Core/XDSTooltip',
+ component: XDSTooltip,
+ tags: ['autodocs'],
+ argTypes: {
+ placement: {
+ control: 'select',
+ options: ['above', 'below', 'start', 'end'],
+ description: 'Position relative to trigger',
+ },
+ alignment: {
+ control: 'select',
+ options: ['start', 'center', 'end'],
+ description: 'Alignment on placement axis',
+ },
+ delay: {
+ control: 'number',
+ description: 'Show delay in ms',
+ },
+ hideDelay: {
+ control: 'number',
+ description: 'Hide delay in ms',
+ },
+ isEnabled: {
+ control: 'boolean',
+ description: 'Enable/disable the tooltip',
+ },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof XDSTooltip>;
+
+export const Default: Story = {
+ args: {
+ placement: 'above',
+ content: 'This is a helpful tooltip',
+ children: <XDSButton>Hover me</XDSButton>,
+ },
+};
+
+export const Below: Story = {
+ args: {
+ placement: 'below',
+ content: 'Tooltip appears below',
+ children: <XDSButton>Hover me</XDSButton>,
+ },
+};
+
+export const Start: Story = {
+ args: {
+ placement: 'start',
+ content: 'Tooltip on start',
+ children: <XDSButton>Hover me</XDSButton>,
+ },
+};
+
+export const End: Story = {
+ args: {
+ placement: 'end',
+ content: 'Tooltip on end',
+ children: <XDSButton>Hover me</XDSButton>,
+ },
+};
+
+export const CustomDelay: Story = {
+ args: {
+ placement: 'above',
+ delay: 500,
+ content: 'Slower tooltip (500ms delay)',
+ children: <XDSButton>Slow tooltip</XDSButton>,
+ },
+};
+
+export const Disabled: Story = {
+ args: {
+ placement: 'above',
+ isEnabled: false,
+ content: 'You should not see this',
+ children: <XDSButton>Tooltip disabled</XDSButton>,
+ },
+};
+
+export const AllPlacements: Story = {
+ render: () => (
+ <div style={{ padding: 100, display: 'flex', gap: 24, flexWrap: 'wrap' }}>
+ <XDSTooltip content="Above" placement="above">
+ <XDSButton>Above</XDSButton>
+ </XDSTooltip>
+ <XDSTooltip content="Below" placement="below">
+ <XDSButton>Below</XDSButton>
+ </XDSTooltip>
+ <XDSTooltip content="Start" placement="start">
+ <XDSButton>Start</XDSButton>
+ </XDSTooltip>
+ <XDSTooltip content="End" placement="end">
+ <XDSButton>End</XDSButton>
+ </XDSTooltip>
+ </div>
+ ),
+};
+
+export const WithHook: Story = {
+ render: function HookExample() {
+ const tooltip = useXDSTooltip({
+ placement: 'above',
+ delay: 100,
+ });
+
+ return (
+ <div style={{ padding: 100 }}>
+ <XDSButton ref={tooltip.ref} aria-describedby={tooltip.describedBy}>
+ Using hook directly
+ </XDSButton>
+ {tooltip.renderTooltip('Tooltip via hook')}
+ </div>
+ );
+ },
+};
+
+export const LongContent: Story = {
+ args: {
+ placement: 'above',
+ content: 'This is a longer tooltip that contains more detailed information about the element.',
+ children: <XDSButton>Hover for more info</XDSButton>,
+ },
+};
+
+export const MultipleTooltips: Story = {
+ render: () => (
+ <div style={{ padding: 100 }}>
+ <XDSHStack gap="space4">
+ <XDSTooltip content="Save your changes" placement="above">
+ <XDSButton>Save</XDSButton>
+ </XDSTooltip>
+ <XDSTooltip content="Discard changes" placement="above">
+ <XDSButton>Cancel</XDSButton>
+ </XDSTooltip>
+ <XDSTooltip content="Delete permanently" placement="above">
+ <XDSButton variant="destructive">Delete</XDSButton>
+ </XDSTooltip>
+ </XDSHStack>
+ </div>
+ ),
+};
+
+export const TextNode: Story = {
+ render: () => (
+ <div style={{ padding: 100 }}>
+ <p>
+ This paragraph contains a{' '}
+ <XDSTooltip content="Tooltip on inline text!" placement="above">
+ hover-able term
+ </XDSTooltip>{' '}
+ that explains what something means.
+ </p>
+ </div>
+ ),
+};
+
+export const TextNodeInline: Story = {
+ render: () => (
+ <div style={{ padding: 100 }}>
+ <p>
+ Learn more about our{' '}
+ <XDSTooltip content="Your data is encrypted and never shared" placement="above">
+ privacy policy
+ </XDSTooltip>{' '}
+ and{' '}
+ <XDSTooltip content="Standard 30-day agreement" placement="above">
+ terms of service
+ </XDSTooltip>
+ .
+ </p>
+ </div>
+ ),
+};
diff --git a/packages/core/CLAUDE.md b/packages/core/CLAUDE.md
deleted file mode 100644
index ada28fbf0e..0000000000
--- a/packages/core/CLAUDE.md
+++ /dev/null
@@ -1,385 +0,0 @@
-# @xds/core - AI Context
-
-A React component library for building internal tools, powered by StyleX.
-
-## Quick Start
-
-```tsx
-import {
- Theme,
- defaultTheme,
- XDSSection,
- XDSLayout,
- XDSLayoutHeader,
- XDSLayoutContent,
- XDSLayoutPanel,
- XDSButton,
-} from '@xds/core';
-
-function App() {
- return (
- <Theme theme={defaultTheme} mode="system">
- <XDSSection>
- <XDSLayout
- header={<XDSLayoutHeader hasDivider>Dashboard</XDSLayoutHeader>}
- start={
- <XDSLayoutPanel hasDivider role="navigation">
- <Navigation />
- </XDSLayoutPanel>
- }
- content={
- <XDSLayoutContent role="main">
- <MainContent />
- </XDSLayoutContent>
- }
- />
- </XDSSection>
- </Theme>
- );
-}
-```
-
-Use `XDSLayout` with named slots (`header`, `content`, `footer`, `start`, `end`) wrapped in a container component (`XDSSection` or `XDSCard`).
-
-## Components
-
-### XDSButton
-
-Interactive button with variants and loading state.
-
-```tsx
-import { XDSButton } from '@xds/core';
-
-<XDSButton variant="primary">Click me</XDSButton>
-<XDSButton variant="secondary">Secondary</XDSButton>
-<XDSButton variant="ghost">Ghost</XDSButton>
-<XDSButton variant="destructive" onClick={handleDelete}>Delete</XDSButton>
-<XDSButton loading>Saving...</XDSButton>
-```
-
-| Prop | Type | Default | Description |
-|------|------|---------|-------------|
-| `variant` | `'primary' \| 'secondary' \| 'ghost' \| 'destructive'` | `'primary'` | Visual style |
-| `loading` | `boolean` | `false` | Shows spinner, disables button |
-| `disabled` | `boolean` | `false` | Disables interaction |
-| `...rest` | `ButtonHTMLAttributes` | — | All standard button props |
-
-### Layout Components
-
-Flexbox-based layout primitives with theme-aware spacing.
-
-#### XDSLayout (Page/Section Layout)
-
-Slot-based layout for pages and cards. Must be wrapped in `XDSSection` or `XDSCard`.
-
-```
-┌─────────────────────────────────────────┐
-│ header │
-├──────┬─────────────────────────┬────────┤
-│ │ │ │
-│start │ content │ end │
-│ │ │ │
-├──────┴─────────────────────────┴────────┤
-│ footer │
-└─────────────────────────────────────────┘
-```
-
-```tsx
-import {
- XDSCard,
- XDSLayout,
- XDSLayoutHeader,
- XDSLayoutContent,
- XDSLayoutFooter,
- XDSLayoutPanel,
-} from '@xds/core';
-
-<XDSCard>
- <XDSLayout
- header={<XDSLayoutHeader hasDivider>Title</XDSLayoutHeader>}
- start={<XDSLayoutPanel hasDivider role="navigation"><Nav /></XDSLayoutPanel>}
- content={<XDSLayoutContent role="main">Body</XDSLayoutContent>}
- footer={<XDSLayoutFooter hasDivider>Actions</XDSLayoutFooter>}
- />
-</XDSCard>
-```
-
-| Prop | Type | Default | Description |
-|------|------|---------|-------------|
-| `header` | `ReactNode` | — | Header slot |
-| `footer` | `ReactNode` | — | Footer slot |
-| `content` | `ReactNode` | — | Main content slot |
-| `start` | `ReactNode` | — | Start panel (left in LTR) |
-| `end` | `ReactNode` | — | End panel (right in LTR) |
-| `height` | `'fill' \| 'auto'` | `'fill'` | `fill`: content scrolls. `auto`: page scrolls |
-| `isFullBleed` | `boolean` | `false` | Remove outer padding |
-
-**Content area props** (`XDSLayoutHeader`, `XDSLayoutFooter`, `XDSLayoutContent`, `XDSLayoutPanel`):
-
-| Prop | Type | Description |
-|------|------|-------------|
-| `hasDivider` | `boolean` | Add themed border between areas |
-| `isFullBleed` | `boolean` | Remove internal padding (for tables, images) |
-| `role` | `AriaRole` | ARIA landmark (`'main'`, `'navigation'`, `'banner'`) |
-| `label` | `string` | Accessible label for landmark |
-
-#### Containers
-
-```tsx
-// Card - bordered container with background
-<XDSCard>
- <XDSLayout content={...} />
-</XDSCard>
-
-// Section - full-width with optional background variant
-<XDSSection variant="wash">
- <XDSLayout content={...} />
-</XDSSection>
-```
-
-#### XDSHStack / XDSVStack (Stack Primitives)
-
-Lower-level flexbox primitives for custom layouts within content areas.
-
-```tsx
-import { XDSHStack, XDSVStack, XDSStackItem } from '@xds/core';
-
-<XDSHStack gap="space2" vAlign="center">
- <XDSStackItem size="static"><Logo /></XDSStackItem>
- <XDSStackItem size="fill"><Navigation /></XDSStackItem>
-</XDSHStack>
-
-<XDSVStack gap="space4" hAlign="center">
- <Heading />
- <Description />
-</XDSVStack>
-```
-
-| Prop | Type | Default | Description |
-|------|------|---------|-------------|
-| `gap` | `SpacingScale` | — | Space between items |
-| `vAlign` / `hAlign` | `'start' \| 'center' \| 'end' \| 'stretch'` | `'stretch'` | Cross-axis alignment |
-| `wrap` | `'nowrap' \| 'wrap' \| 'wrap-reverse'` | `'nowrap'` | Flex wrap |
-| `element` | `ElementType` | `'div'` | Render as different element |
-| `xstyle` | `StyleXStyles` | — | Additional StyleX styles |
-
-**XDSStackItem props:**
-
-| Prop | Type | Default | Description |
-|------|------|---------|-------------|
-| `size` | `'static' \| 'fill'` | `'static'` | `fill` grows to take remaining space |
-| `crossAlignSelf` | `'start' \| 'center' \| 'end' \| 'stretch'` | — | Override parent alignment |
-
-### Spacing Scale
-
-Available values for `gap` prop:
-
-- `space0` - No gap
-- `space0.5` - Extra small (4px)
-- `space1` - Small (8px)
-- `space2` - Medium-small (12px)
-- `space3` - Medium (16px)
-- `space4` - Medium-large (20px)
-- `space5` - Large (24px)
-- `space6` - Extra large (28px)
-- `space7` - Maximum (32px)
-
-## Theming
-
-### Theme Provider
-
-Wrap your app with the Theme provider:
-
-```tsx
-import { Theme, defaultTheme } from '@xds/core';
-
-<Theme theme={defaultTheme} mode="system">
- <App />
-</Theme>
-```
-
-| Prop | Type | Default | Description |
-|------|------|---------|-------------|
-| `theme` | `Theme` | Required | Theme object (`defaultTheme` or `neutralTheme`) |
-| `mode` | `'system' \| 'light' \| 'dark'` | `'system'` | Color mode |
-
-### Available Themes
-
-- `defaultTheme` - Full-featured with accent colors, light/dark support
-- `neutralTheme` - Grayscale theme
-
-### useTheme Hook
-
-```tsx
-import { useTheme } from '@xds/core';
-
-function MyComponent() {
- const { theme, mode } = useTheme();
- // mode is 'light' | 'dark'
-}
-```
-
-## StyleX Integration
-
-### Custom Styles via xstyle
-
-Components accept `xstyle` prop for additional StyleX styles:
-
-```tsx
-import * as stylex from '@stylexjs/stylex';
-import { XDSHStack } from '@xds/core';
-
-const styles = stylex.create({
- container: { padding: '1rem' },
-});
-
-<XDSHStack xstyle={styles.container}>
- {children}
-</XDSHStack>
-```
-
-### Using Theme Tokens
-
-Access design tokens in your StyleX styles:
-
-```tsx
-import * as stylex from '@stylexjs/stylex';
-import { colorTokens, spacingTokens } from '@xds/core';
-
-const styles = stylex.create({
- card: {
- backgroundColor: colorTokens.surface,
- padding: spacingTokens.space4,
- color: colorTokens.textPrimary,
- },
-});
-```
-
-### Utility Functions
-
-For direct StyleX usage without components:
-
-```tsx
-import { stack, stackItem } from '@xds/core';
-import * as stylex from '@stylexjs/stylex';
-
-<div {...stylex.props(...stack({ direction: 'horizontal', gap: 'space2' }))}>
- <div {...stylex.props(...stackItem({ size: 'fill' }))}>Fills space</div>
-</div>
-```
-
-## Common Patterns
-
-### Page Layout with Sidebar
-
-```tsx
-<XDSSection>
- <XDSLayout
- header={<XDSLayoutHeader hasDivider role="banner">App Title</XDSLayoutHeader>}
- start={
- <XDSLayoutPanel hasDivider role="navigation">
- <Navigation />
- </XDSLayoutPanel>
- }
- content={<XDSLayoutContent role="main"><MainContent /></XDSLayoutContent>}
- />
-</XDSSection>
-```
-
-### Card with Header and Footer
-
-```tsx
-<XDSCard>
- <XDSLayout
- header={<XDSLayoutHeader hasDivider>Edit User</XDSLayoutHeader>}
- content={<XDSLayoutContent><Form /></XDSLayoutContent>}
- footer={
- <XDSLayoutFooter hasDivider>
- <XDSHStack gap="space2">
- <XDSButton variant="secondary">Cancel</XDSButton>
- <XDSButton variant="primary">Save</XDSButton>
- </XDSHStack>
- </XDSLayoutFooter>
- }
- />
-</XDSCard>
-```
-
-### Full Bleed Table
-
-```tsx
-<XDSCard>
- <XDSLayout
- header={<XDSLayoutHeader hasDivider>Users</XDSLayoutHeader>}
- content={
- <XDSLayoutContent isFullBleed>
- <Table />
- </XDSLayoutContent>
- }
- />
-</XDSCard>
-```
-
-### Button Group
-
-```tsx
-<XDSHStack gap="space2">
- <XDSButton variant="secondary">Cancel</XDSButton>
- <XDSButton variant="primary">Save</XDSButton>
-</XDSHStack>
-```
-
-### Centered Content
-
-```tsx
-<XDSVStack hAlign="center" gap="space4">
- <Heading />
- <Description />
- <XDSButton>Get Started</XDSButton>
-</XDSVStack>
-```
-
-## Key Conventions
-
-1. **XDS Prefix** - All components use `XDS` prefix (e.g., `XDSButton`, `XDSLayout`)
-2. **Layout First** - Use `XDSLayout` with `XDSSection`/`XDSCard` for page structure
-3. **No className** - Use `xstyle` prop for custom styles on Stack components
-4. **Theme Required** - Wrap app in `<Theme>` provider for proper styling
-5. **ARIA Roles** - Use `role` prop on layout areas for accessibility (`role="main"`, `role="navigation"`)
-6. **Tree-shakeable** - Import from subpaths for smaller bundles: `@xds/core/Layout`
-
-## Exports
-
-```tsx
-// All-in-one
-import {
- XDSButton,
- XDSLayout,
- XDSLayoutHeader,
- XDSLayoutContent,
- XDSLayoutFooter,
- XDSLayoutPanel,
- XDSCard,
- XDSSection,
- XDSHStack,
- XDSVStack,
- XDSStackItem,
- Theme,
- defaultTheme,
-} from '@xds/core';
-
-// Tree-shaking friendly
-import { XDSButton } from '@xds/core/Button';
-import {
- XDSLayout,
- XDSLayoutHeader,
- XDSLayoutContent,
- XDSLayoutFooter,
- XDSLayoutPanel,
- XDSCard,
- XDSSection,
- XDSHStack,
- XDSVStack,
- XDSStackItem,
-} from '@xds/core/Layout';
-```
diff --git a/packages/core/package.json b/packages/core/package.json
index 62eb46ad66..88ec7c3a86 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -5,14 +5,11 @@
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
- "files": [
- "dist",
- "CLAUDE.md"
- ],
"sideEffects": [
"**/*.stylex.ts",
"**/*.stylex.js",
- "**/*.stylex.mjs"
+ "**/*.stylex.mjs",
+ "**/componentStyles.ts"
],
"exports": {
".": {
diff --git a/packages/core/src/Button/XDSButton.tsx b/packages/core/src/Button/XDSButton.tsx
index 7e7d4dcb0b..ea77fd4647 100644
--- a/packages/core/src/Button/XDSButton.tsx
+++ b/packages/core/src/Button/XDSButton.tsx
@@ -160,7 +160,7 @@ declare module '../theme/types' {
export interface XDSButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
/**
* The visual style variant of the button.
- * @default 'primary'
+ * @default 'secondary'
*/
variant?: XDSButtonVariant;
/**
@@ -221,13 +221,13 @@ const loadingStyles = stylex.create({
*
* @example
* ```tsx
- * <XDSButton variant="primary">Click me</XDSButton>
- * <XDSButton variant="secondary" loading>Saving...</XDSButton>
+ * <XDSButton>Click me</XDSButton>
+ * <XDSButton variant="primary">Primary action</XDSButton>
* <XDSButton variant="destructive">Delete</XDSButton>
* ```
*/
export const XDSButton = forwardRef<HTMLButtonElement, XDSButtonProps>(
- ({ variant = 'primary', loading = false, disabled, children, ...props }, ref) => {
+ ({ variant = 'secondary', loading = false, disabled, children, ...props }, ref) => {
const isDisabled = disabled || loading;
const useLightSpinner = variant === 'primary' || variant === 'destructive';
diff --git a/packages/core/src/Layer/README.md b/packages/core/src/Layer/README.md
new file mode 100644
index 0000000000..8c36e8e50e
--- /dev/null
+++ b/packages/core/src/Layer/README.md
@@ -0,0 +1,158 @@
+# /packages/core/src/Layer
+
+Layer components for overlay content using modern browser APIs.
+
+<!-- SYNC: When files in this directory change, update this document. -->
+
+## Overview
+
+The Layer system provides hooks and components for overlay content using:
+- **CSS Anchor Positioning** for automatic positioning relative to trigger elements
+- **Popover API** for top-layer rendering (no React portals needed)
+
+## Browser Support
+
+- **Chrome**: Full support
+- **Safari**: Full support
+- **Firefox**: Popover API works, anchor positioning not yet (acceptable degradation)
+
+## Import
+
+```tsx
+import {
+ useXDSLayer,
+ useXDSHoverCard,
+ XDSHoverCard,
+} from '@xds/core/Layer';
+```
+
+## Hooks
+
+### useXDSLayer
+
+Core layer hook with type-safe modes for different positioning strategies.
+
+```tsx
+// Context mode (anchor positioning)
+const layer = useXDSLayer({ mode: 'context' });
+
+<button ref={layer.ref}>Trigger</button>
+{layer.render(<Content />, { placement: 'above', alignment: 'center' })}
+
+// Fixed mode (manual coordinates)
+const layer = useXDSLayer({ mode: 'fixed' });
+
+layer.show();
+{layer.render(<Content />, { x: mouseX, y: mouseY })}
+```
+
+TypeScript enforces correct render props per mode:
+- **Context mode**: `render(children, { placement?, alignment? })`
+- **Fixed mode**: `render(children, { x, y })` (required)
+
+| Option | Type | Description |
+|--------|------|-------------|
+| `mode` | `'context' \| 'fixed'` | Positioning strategy |
+| `onShow` | `() => void` | Callback when shown |
+| `onHide` | `() => void` | Callback when hidden |
+
+### useXDSHoverCard
+
+Hook for hover/focus triggered layers with timing control.
+
+```tsx
+const hoverCard = useXDSHoverCard({ placement: 'above' });
+
+<XDSButton
+ ref={hoverCard.ref}
+ aria-describedby={hoverCard.describedBy}
+>
+ Hover me
+</XDSButton>
+
+{hoverCard.renderHoverCard(<ProfileCard user={user} />)}
+```
+
+| Option | Type | Default | Description |
+|--------|------|---------|-------------|
+| `placement` | `LayerPlacement` | `'above'` | Position relative to anchor |
+| `alignment` | `LayerAlignment` | `'start'` | Alignment on placement axis |
+| `delay` | `number` | `300` | Show delay in ms |
+| `hideDelay` | `number` | `200` | Hide delay in ms |
+| `focusTrigger` | `'auto' \| 'always' \| 'never'` | `'auto'` | Focus listener behavior |
+| `isEnabled` | `boolean` | `true` | Enable/disable triggers |
+| `onShow` | `() => void` | — | Callback when shown |
+| `onHide` | `() => void` | — | Callback when hidden |
+
+## Components
+
+### XDSHoverCard
+
+Component wrapper for simpler hover card usage.
+
+```tsx
+<XDSHoverCard
+ content={<ProfileCard user={user} />}
+ placement="above"
+>
+ <XDSButton>Hover me</XDSButton>
+</XDSHoverCard>
+```
+
+| Prop | Type | Default | Description |
+|------|------|---------|-------------|
+| `children` | `ReactElement` | Required | Trigger element (must accept ref) |
+| `content` | `ReactNode` | Required | Hover card content |
+| `placement` | `LayerPlacement` | `'above'` | Position relative to anchor |
+| `alignment` | `LayerAlignment` | `'start'` | Alignment on placement axis |
+| `delay` | `number` | `300` | Show delay in ms |
+| `hideDelay` | `number` | `200` | Hide delay in ms |
+| `focusTrigger` | `'auto' \| 'always' \| 'never'` | `'auto'` | Focus listener behavior |
+| `isEnabled` | `boolean` | `true` | Enable/disable triggers |
+
+## Position Values
+
+### LayerPlacement
+
+| Value | Description |
+|-------|-------------|
+| `above` | Above the anchor |
+| `below` | Below the anchor |
+| `start` | Start side (left in LTR) |
+| `end` | End side (right in LTR) |
+
+### LayerAlignment
+
+| Value | Description |
+|-------|-------------|
+| `start` | Align to start edge |
+| `center` | Center aligned |
+| `end` | Align to end edge |
+
+## ARIA Guidelines
+
+When using hooks directly, compose `aria-describedby` with your own IDs:
+
+```tsx
+const hoverCard = useXDSHoverCard();
+
+<XDSInput
+ ref={hoverCard.ref}
+ aria-describedby={mergeIds(fieldErrorId, hoverCard.describedBy)}
+/>
+
+// Utility function
+function mergeIds(...ids: (string | undefined)[]) {
+ return ids.filter(Boolean).join(' ') || undefined;
+}
+```
+
+## Files
+
+| File | Role | Purpose |
+|------|------|---------|
+| `index.ts` | Entry | Exports all layer utilities and components |
+| `useXDSLayer.ts` | Hook | Core popover and positioning logic |
+| `useXDSHoverCard.ts` | Hook | Hover/focus triggers for layers |
+| `XDSHoverCard.tsx` | Component | Wrapper component for hover cards |
+| `XDSHoverCard.test.tsx` | Test | HoverCard unit tests |
diff --git a/packages/core/src/Layer/XDSHoverCard.test.tsx b/packages/core/src/Layer/XDSHoverCard.test.tsx
new file mode 100644
index 0000000000..c0f490eaa2
--- /dev/null
+++ b/packages/core/src/Layer/XDSHoverCard.test.tsx
@@ -0,0 +1,271 @@
+/**
+ * @file XDSHoverCard.test.tsx
+ * @input Uses vitest, @testing-library/react, XDSHoverCard component
+ * @output Unit tests for XDSHoverCard component behavior
+ * @position Testing; validates XDSHoverCard.tsx implementation
+ *
+ * SYNC: When XDSHoverCard.tsx changes, update tests to match new behavior
+ */
+
+import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest';
+import { render, screen, fireEvent, waitFor } from '@testing-library/react';
+import { XDSHoverCard } from './XDSHoverCard';
+
+// Store original matches to restore later
+const originalMatches = HTMLElement.prototype.matches;
+
+// Track popover open state per element
+const popoverOpenState = new WeakMap<HTMLElement, boolean>();
+
+// Mock Popover API for jsdom
+beforeAll(() => {
+ HTMLElement.prototype.showPopover = vi.fn(function (this: HTMLElement) {
+ popoverOpenState.set(this, true);
+ });
+ HTMLElement.prototype.hidePopover = vi.fn(function (this: HTMLElement) {
+ popoverOpenState.set(this, false);
+ });
+
+ // Only intercept :popover-open, delegate everything else to original
+ HTMLElement.prototype.matches = function (selector: string) {
+ if (selector === ':popover-open') {
+ return popoverOpenState.get(this) ?? false;
+ }
+ return originalMatches.call(this, selector);
+ };
+});
+
+afterAll(() => {
+ HTMLElement.prototype.matches = originalMatches;
+});
+
+describe('XDSHoverCard', () => {
+ it('renders trigger element', () => {
+ render(
+ <XDSHoverCard content={<span>Card content</span>}>
+ <button>Trigger</button>
+ </XDSHoverCard>
+ );
+ expect(screen.getByRole('button', { name: 'Trigger' })).toBeInTheDocument();
+ });
+
+ it('does not show content initially', () => {
+ render(
+ <XDSHoverCard content={<span>Card content</span>}>
+ <button>Trigger</button>
+ </XDSHoverCard>
+ );
+ // Content is in DOM (popover not open but element exists)
+ const content = screen.queryByText('Card content');
+ expect(content).toBeInTheDocument();
+ });
+
+ it('injects aria-describedby on trigger', () => {
+ render(
+ <XDSHoverCard content={<span>Card content</span>}>
+ <button>Trigger</button>
+ </XDSHoverCard>
+ );
+ const trigger = screen.getByRole('button', { name: 'Trigger' });
+ expect(trigger).toHaveAttribute('aria-describedby');
+ });
+
+ it('merges existing aria-describedby', () => {
+ render(
+ <XDSHoverCard content={<span>Card content</span>}>
+ <button aria-describedby="existing-id">Trigger</button>
+ </XDSHoverCard>
+ );
+ const trigger = screen.getByRole('button', { name: 'Trigger' });
+ const describedBy = trigger.getAttribute('aria-describedby');
+ expect(describedBy).toContain('existing-id');
+ });
+
+ it('calls onShow callback when shown', async () => {
+ const onShow = vi.fn();
+ render(
+ <XDSHoverCard
+ content={<span>Card content</span>}
+ onShow={onShow}
+ delay={0}
+ >
+ <button>Trigger</button>
+ </XDSHoverCard>
+ );
+
+ const trigger = screen.getByRole('button', { name: 'Trigger' });
+ fireEvent.mouseEnter(trigger);
+
+ await waitFor(() => {
+ expect(onShow).toHaveBeenCalled();
+ });
+ });
+
+ it('respects isEnabled prop', async () => {
+ const onShow = vi.fn();
+ render(
+ <XDSHoverCard
+ content={<span>Card content</span>}
+ onShow={onShow}
+ isEnabled={false}
+ delay={0}
+ >
+ <button>Trigger</button>
+ </XDSHoverCard>
+ );
+
+ const trigger = screen.getByRole('button', { name: 'Trigger' });
+ fireEvent.mouseEnter(trigger);
+
+ // Wait a bit and verify onShow was not called
+ await new Promise((resolve) => setTimeout(resolve, 50));
+ expect(onShow).not.toHaveBeenCalled();
+ });
+
+ it('supports text-only children with inline wrapper', () => {
+ render(
+ <XDSHoverCard content={<span>Card content</span>}>
+ Just text, no element
+ </XDSHoverCard>
+ );
+ // Text should be rendered
+ expect(screen.getByText('Just text, no element')).toBeInTheDocument();
+ // Should have aria-describedby on the wrapper span
+ const wrapper = screen.getByText('Just text, no element');
+ expect(wrapper.tagName).toBe('SPAN');
+ expect(wrapper).toHaveAttribute('aria-describedby');
+ });
+
+ describe('Escape key behavior', () => {
+ it('hides hover card when Escape is pressed on trigger', async () => {
+ const onHide = vi.fn();
+ // Reset the mock before this test
+ vi.mocked(HTMLElement.prototype.hidePopover).mockClear();
+
+ render(
+ <XDSHoverCard
+ content={<span>Card content</span>}
+ onHide={onHide}
+ delay={0}
+ hideDelay={0}
+ >
+ <button>Trigger</button>
+ </XDSHoverCard>
+ );
+
+ const trigger = screen.getByRole('button', { name: 'Trigger' });
+
+ // Show the hover card
+ fireEvent.mouseEnter(trigger);
+ await waitFor(() => {
+ expect(HTMLElement.prototype.showPopover).toHaveBeenCalled();
+ });
+
+ // Press Escape on trigger
+ fireEvent.keyDown(trigger, { key: 'Escape' });
+
+ // hidePopover should be called
+ await waitFor(() => {
+ expect(HTMLElement.prototype.hidePopover).toHaveBeenCalled();
+ });
+ });
+
+ it('hides hover card when Escape is pressed inside content', async () => {
+ vi.mocked(HTMLElement.prototype.hidePopover).mockClear();
+
+ render(
+ <XDSHoverCard
+ content={<button>Interactive button</button>}
+ delay={0}
+ hideDelay={0}
+ >
+ <button>Trigger</button>
+ </XDSHoverCard>
+ );
+
+ const trigger = screen.getByRole('button', { name: 'Trigger' });
+
+ // Show the hover card
+ fireEvent.mouseEnter(trigger);
+ await waitFor(() => {
+ expect(HTMLElement.prototype.showPopover).toHaveBeenCalled();
+ });
+
+ // Find the interactive content using getByText (works inside popovers)
+ const contentButton = screen.getByText('Interactive button');
+ fireEvent.keyDown(contentButton, { key: 'Escape' });
+
+ // hidePopover should be called
+ await waitFor(() => {
+ expect(HTMLElement.prototype.hidePopover).toHaveBeenCalled();
+ });
+ });
+
+ it('refocuses trigger after Escape from content', async () => {
+ render(
+ <XDSHoverCard
+ content={<button>Interactive button</button>}
+ delay={0}
+ hideDelay={0}
+ >
+ <button>Trigger</button>
+ </XDSHoverCard>
+ );
+
+ const trigger = screen.getByRole('button', { name: 'Trigger' });
+
+ // Show the hover card via focus
+ fireEvent.focus(trigger);
+ await waitFor(() => {
+ expect(HTMLElement.prototype.showPopover).toHaveBeenCalled();
+ });
+
+ // Focus the content button
+ const contentButton = screen.getByText('Interactive button');
+ (contentButton as HTMLElement).focus();
+
+ // Press Escape - should refocus trigger
+ fireEvent.keyDown(contentButton, { key: 'Escape' });
+
+ await waitFor(() => {
+ expect(document.activeElement).toBe(trigger);
+ });
+ });
+
+ it('does not re-show hover card after Escape dismiss and refocus', async () => {
+ const onShow = vi.fn();
+ render(
+ <XDSHoverCard
+ content={<button>Interactive button</button>}
+ onShow={onShow}
+ delay={0}
+ hideDelay={0}
+ >
+ <button>Trigger</button>
+ </XDSHoverCard>
+ );
+
+ const trigger = screen.getByRole('button', { name: 'Trigger' });
+
+ // Show the hover card via focus
+ fireEvent.focus(trigger);
+ await waitFor(() => {
+ expect(onShow).toHaveBeenCalledTimes(1);
+ });
+
+ // Focus the content button
+ const contentButton = screen.getByText('Interactive button');
+ (contentButton as HTMLElement).focus();
+
+ // Clear the mock to track new calls
+ onShow.mockClear();
+
+ // Press Escape - this refocuses trigger but shouldn't re-show
+ fireEvent.keyDown(contentButton, { key: 'Escape' });
+
+ // Wait a bit and verify onShow was not called again
+ await new Promise((resolve) => setTimeout(resolve, 50));
+ expect(onShow).not.toHaveBeenCalled();
+ });
+ });
+});
diff --git a/packages/core/src/Layer/XDSHoverCard.tsx b/packages/core/src/Layer/XDSHoverCard.tsx
new file mode 100644
index 0000000000..cd5845ddfe
--- /dev/null
+++ b/packages/core/src/Layer/XDSHoverCard.tsx
@@ -0,0 +1,258 @@
+/**
+ * @file XDSHoverCard.tsx
+ * @input Uses React, useXDSHoverCard hook
+ * @output Exports XDSHoverCard component for hover/focus triggered layers
+ * @position Layer component; uses display:contents wrapper to avoid cloneElement
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/core/src/Layer/README.md
+ * - /packages/core/src/Layer/XDSHoverCard.test.tsx
+ * - /packages/core/src/Layer/index.ts
+ * - /apps/storybook/stories/HoverCard.stories.tsx
+ */
+
+import React, {
+ useContext,
+ useLayoutEffect,
+ useRef,
+ type ReactElement,
+ type ReactNode,
+} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import { ThemeContext } from '../theme/ThemeContext';
+import { useXDSHoverCard, type HoverCardFocusTrigger } from './useXDSHoverCard';
+import type { LayerAlignment, LayerPlacement } from './useXDSLayer';
+import { colorTokens } from '../theme/tokens.stylex';
+
+export type { HoverCardFocusTrigger } from './useXDSHoverCard';
+
+const styles = stylex.create({
+ wrapperContents: {
+ display: 'contents',
+ },
+ wrapperInline: {
+ display: 'inline',
+ },
+ hoverIndication: {
+ textDecorationLine: 'underline',
+ textDecorationStyle: 'dashed',
+ textDecorationColor: colorTokens.dividerEmphasized,
+ textUnderlineOffset: '2px',
+ },
+});
+
+export interface XDSHoverCardProps {
+ /**
+ * The trigger element(s). Children refs are preserved.
+ */
+ children: ReactNode;
+
+ /**
+ * Content to display in the hover card.
+ */
+ content: ReactNode;
+
+ /**
+ * Position placement relative to anchor
+ * @default 'above'
+ */
+ placement?: LayerPlacement;
+
+ /**
+ * Alignment along the placement axis
+ * @default 'center'
+ */
+ alignment?: LayerAlignment;
+
+ /**
+ * Delay before showing on hover (ms)
+ * @default 300
+ */
+ delay?: number;
+
+ /**
+ * Delay before hiding after mouse/focus leave (ms)
+ * @default 200
+ */
+ hideDelay?: number;
+
+ /**
+ * When to trigger on focus:
+ * - `auto`: Only if element is naturally focusable
+ * - `always`: Always attach focus listeners
+ * - `never`: Never attach focus listeners (for composite widgets)
+ *
+ * @default 'auto'
+ */
+ focusTrigger?: HoverCardFocusTrigger;
+
+ /**
+ * Whether the hover card is enabled.
+ * When false, hover/focus triggers are disabled.
+ *
+ * @default true
+ */
+ isEnabled?: boolean;
+
+ /**
+ * Callback fired when hover card is shown
+ */
+ onShow?: () => void;
+
+ /**
+ * Callback fired when hover card is hidden
+ */
+ onHide?: () => void;
+
+ /**
+ * Whether to show hover indication (dashed underline) on the trigger.
+ * - `'auto'`: Show for text-only children
+ * - `true`: Always show
+ * - `false`: Never show
+ *
+ * @default 'auto'
+ */
+ hasHoverIndication?: 'auto' | boolean;
+}
+
+/**
+ * Check if children are text-only (no React elements)
+ */
+function isTextOnly(children: ReactNode): boolean {
+ let hasElement = false;
+ React.Children.forEach(children, (child) => {
+ if (React.isValidElement(child)) {
+ hasElement = true;
+ }
+ });
+ return !hasElement;
+}
+
+/**
+ * Utility to merge ARIA ID strings
+ */
+function mergeIds(...ids: (string | undefined | null)[]): string | undefined {
+ const filtered = ids.filter(Boolean);
+ return filtered.length > 0 ? filtered.join(' ') : undefined;
+}
+
+/**
+ * HoverCard component for displaying interactive content on hover/focus.
+ *
+ * Uses a display:contents wrapper so children refs are preserved.
+ * Uses CSS anchor positioning and the Popover API for optimal performance.
+ *
+ * @example
+ * ```tsx
+ * <XDSHoverCard
+ * content={<ProfileCard user={user} />}
+ * placement="above"
+ * >
+ * <XDSButton>Hover me</XDSButton>
+ * </XDSHoverCard>
+ * ```
+ */
+export function XDSHoverCard({
+ children,
+ content,
+ placement = 'above',
+ alignment = 'center',
+ delay = 300,
+ hideDelay = 200,
+ focusTrigger = 'auto',
+ isEnabled = true,
+ onShow,
+ onHide,
+ hasHoverIndication = 'auto',
+}: XDSHoverCardProps): ReactElement {
+ const wrapperRef = useRef<HTMLElement>(null);
+ const textOnly = isTextOnly(children);
+
+ // Get theme context for hover indication override
+ const themeContext = useContext(ThemeContext);
+ const themeHoverIndicationOverride =
+ themeContext?.theme.components?.hoverCard?.hoverIndication;
+
+ // Determine if hover indication should be shown
+ const showHoverIndication =
+ hasHoverIndication === true ||
+ (hasHoverIndication === 'auto' && textOnly);
+
+ // Use the hook for all hover card behavior
+ const hoverCard = useXDSHoverCard({
+ placement,
+ alignment,
+ delay,
+ hideDelay,
+ focusTrigger,
+ isEnabled,
+ onShow,
+ onHide,
+ });
+
+ // For element children with display:contents, attach ref to first child
+ useLayoutEffect(() => {
+ if (textOnly) return; // Skip for text-only (ref is on wrapper)
+
+ const wrapper = wrapperRef.current;
+ if (!wrapper) return;
+
+ const firstChild = wrapper.firstElementChild as HTMLElement | null;
+ if (!firstChild) return;
+
+ // Use combined ref for position + interaction
+ hoverCard.ref(firstChild);
+
+ // Set aria-describedby, merging with existing
+ const existingDescribedBy = firstChild.getAttribute('aria-describedby');
+ firstChild.setAttribute(
+ 'aria-describedby',
+ mergeIds(existingDescribedBy, hoverCard.describedBy) ?? ''
+ );
+
+ return () => {
+ hoverCard.ref(null);
+ if (existingDescribedBy) {
+ firstChild.setAttribute('aria-describedby', existingDescribedBy);
+ } else {
+ firstChild.removeAttribute('aria-describedby');
+ }
+ };
+ }, [textOnly, hoverCard.ref, hoverCard.describedBy]);
+
+ // For text-only children: use inline span with ref on wrapper
+ if (textOnly) {
+ return (
+ <>
+ <span
+ ref={hoverCard.ref}
+ tabIndex={0}
+ aria-describedby={hoverCard.describedBy}
+ {...stylex.props(
+ styles.wrapperInline,
+ showHoverIndication && styles.hoverIndication,
+ showHoverIndication && themeHoverIndicationOverride
+ )}
+ >
+ {children}
+ </span>
+ {hoverCard.renderHoverCard(content)}
+ </>
+ );
+ }
+
+ // For element children: use display:contents, ref on first child
+ return (
+ <>
+ <div
+ ref={wrapperRef as React.RefObject<HTMLDivElement>}
+ {...stylex.props(styles.wrapperContents)}
+ >
+ {children}
+ </div>
+ {hoverCard.renderHoverCard(content)}
+ </>
+ );
+}
+
+XDSHoverCard.displayName = 'XDSHoverCard';
diff --git a/packages/core/src/Layer/XDSTooltip.tsx b/packages/core/src/Layer/XDSTooltip.tsx
new file mode 100644
index 0000000000..0487d2bb24
--- /dev/null
+++ b/packages/core/src/Layer/XDSTooltip.tsx
@@ -0,0 +1,257 @@
+/**
+ * @file XDSTooltip.tsx
+ * @input Uses React, useXDSTooltip hook
+ * @output Exports XDSTooltip component for hover/focus triggered tooltips
+ * @position Layer component; uses display:contents wrapper to avoid cloneElement
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/core/src/Layer/README.md
+ * - /packages/core/src/Layer/XDSTooltip.test.tsx
+ * - /packages/core/src/Layer/index.ts
+ * - /apps/storybook/stories/Tooltip.stories.tsx
+ */
+
+import React, {
+ useContext,
+ useLayoutEffect,
+ useRef,
+ type ReactElement,
+ type ReactNode,
+} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import { ThemeContext } from '../theme/ThemeContext';
+import { useXDSTooltip, type TooltipFocusTrigger } from './useXDSTooltip';
+import type { LayerAlignment, LayerPlacement } from './useXDSLayer';
+import { colorTokens } from '../theme/tokens.stylex';
+
+export type { TooltipFocusTrigger } from './useXDSTooltip';
+
+const styles = stylex.create({
+ wrapperContents: {
+ display: 'contents',
+ },
+ wrapperInline: {
+ display: 'inline',
+ },
+ hoverIndication: {
+ textDecorationLine: 'underline',
+ textDecorationStyle: 'dashed',
+ textDecorationColor: colorTokens.dividerEmphasized,
+ textUnderlineOffset: '2px',
+ },
+});
+
+export interface XDSTooltipProps {
+ /**
+ * The trigger element(s). Children refs are preserved.
+ */
+ children: ReactNode;
+
+ /**
+ * Content to display in the tooltip.
+ * Typically short, non-interactive text.
+ */
+ content: ReactNode;
+
+ /**
+ * Position placement relative to anchor
+ * @default 'above'
+ */
+ placement?: LayerPlacement;
+
+ /**
+ * Alignment along the placement axis
+ * @default 'center'
+ */
+ alignment?: LayerAlignment;
+
+ /**
+ * Delay before showing on hover (ms)
+ * @default 200
+ */
+ delay?: number;
+
+ /**
+ * Delay before hiding after mouse/focus leave (ms)
+ * @default 0
+ */
+ hideDelay?: number;
+
+ /**
+ * When to trigger on focus:
+ * - `auto`: Only if element is naturally focusable
+ * - `always`: Always attach focus listeners
+ * - `never`: Never attach focus listeners (for composite widgets)
+ *
+ * @default 'auto'
+ */
+ focusTrigger?: TooltipFocusTrigger;
+
+ /**
+ * Whether the tooltip is enabled.
+ * When false, hover/focus triggers are disabled.
+ *
+ * @default true
+ */
+ isEnabled?: boolean;
+
+ /**
+ * Callback fired when tooltip is shown
+ */
+ onShow?: () => void;
+
+ /**
+ * Callback fired when tooltip is hidden
+ */
+ onHide?: () => void;
+
+ /**
+ * Whether to show hover indication (dashed underline) on the trigger.
+ * - `'auto'`: Show for text-only children
+ * - `true`: Always show
+ * - `false`: Never show
+ *
+ * @default 'auto'
+ */
+ hasHoverIndication?: 'auto' | boolean;
+}
+
+/**
+ * Check if children are text-only (no React elements)
+ */
+function isTextOnly(children: ReactNode): boolean {
+ let hasElement = false;
+ React.Children.forEach(children, (child) => {
+ if (React.isValidElement(child)) {
+ hasElement = true;
+ }
+ });
+ return !hasElement;
+}
+
+/**
+ * Utility to merge ARIA ID strings
+ */
+function mergeIds(...ids: (string | undefined | null)[]): string | undefined {
+ const filtered = ids.filter(Boolean);
+ return filtered.length > 0 ? filtered.join(' ') : undefined;
+}
+
+/**
+ * Tooltip component for displaying informative text on hover/focus.
+ *
+ * Uses inverted colors (dark background, light text) for high contrast.
+ * Uses a display:contents wrapper so children refs are preserved.
+ * Uses CSS anchor positioning and the Popover API for optimal performance.
+ *
+ * @example
+ * ```tsx
+ * <XDSTooltip content="Helpful tooltip text" placement="above">
+ * <XDSButton>Hover me</XDSButton>
+ * </XDSTooltip>
+ * ```
+ */
+export function XDSTooltip({
+ children,
+ content,
+ placement = 'above',
+ alignment = 'center',
+ delay = 200,
+ hideDelay = 0,
+ focusTrigger = 'auto',
+ isEnabled = true,
+ onShow,
+ onHide,
+ hasHoverIndication = 'auto',
+}: XDSTooltipProps): ReactElement {
+ const wrapperRef = useRef<HTMLElement>(null);
+ const textOnly = isTextOnly(children);
+
+ // Get theme context for hover indication override
+ const themeContext = useContext(ThemeContext);
+ const themeHoverIndicationOverride =
+ themeContext?.theme.components?.tooltip?.hoverIndication;
+
+ // Determine if hover indication should be shown
+ const showHoverIndication =
+ hasHoverIndication === true ||
+ (hasHoverIndication === 'auto' && textOnly);
+
+ // Use the hook for all tooltip behavior
+ const tooltip = useXDSTooltip({
+ placement,
+ alignment,
+ delay,
+ hideDelay,
+ focusTrigger,
+ isEnabled,
+ onShow,
+ onHide,
+ });
+
+ // For element children with display:contents, attach ref to first child
+ useLayoutEffect(() => {
+ if (textOnly) return; // Skip for text-only (ref is on wrapper)
+
+ const wrapper = wrapperRef.current;
+ if (!wrapper) return;
+
+ const firstChild = wrapper.firstElementChild as HTMLElement | null;
+ if (!firstChild) return;
+
+ // Use combined ref for position + interaction
+ tooltip.ref(firstChild);
+
+ // Set aria-describedby, merging with existing
+ const existingDescribedBy = firstChild.getAttribute('aria-describedby');
+ firstChild.setAttribute(
+ 'aria-describedby',
+ mergeIds(existingDescribedBy, tooltip.describedBy) ?? ''
+ );
+
+ return () => {
+ tooltip.ref(null);
+ if (existingDescribedBy) {
+ firstChild.setAttribute('aria-describedby', existingDescribedBy);
+ } else {
+ firstChild.removeAttribute('aria-describedby');
+ }
+ };
+ }, [textOnly, tooltip.ref, tooltip.describedBy]);
+
+ // For text-only children: use inline span with ref on wrapper
+ if (textOnly) {
+ return (
+ <>
+ <span
+ ref={tooltip.ref}
+ tabIndex={0}
+ aria-describedby={tooltip.describedBy}
+ {...stylex.props(
+ styles.wrapperInline,
+ showHoverIndication && styles.hoverIndication,
+ showHoverIndication && themeHoverIndicationOverride
+ )}
+ >
+ {children}
+ </span>
+ {tooltip.renderTooltip(content)}
+ </>
+ );
+ }
+
+ // For element children: use display:contents, ref on first child
+ return (
+ <>
+ <div
+ ref={wrapperRef as React.RefObject<HTMLDivElement>}
+ {...stylex.props(styles.wrapperContents)}
+ >
+ {children}
+ </div>
+ {tooltip.renderTooltip(content)}
+ </>
+ );
+}
+
+XDSTooltip.displayName = 'XDSTooltip';
diff --git a/packages/core/src/Layer/componentStyles.ts b/packages/core/src/Layer/componentStyles.ts
new file mode 100644
index 0000000000..a1b249916c
--- /dev/null
+++ b/packages/core/src/Layer/componentStyles.ts
@@ -0,0 +1,32 @@
+/**
+ * @file componentStyles.ts
+ * @input Uses StyleXStyles from theme/types
+ * @output Module augmentation for Layer component styles
+ * @position Central type definitions for Layer component theming
+ *
+ * SYNC: When adding new Layer components, add their style types here.
+ */
+
+import type { StyleXStyles } from '../theme/types';
+
+// =============================================================================
+// Module Augmentation - Register Layer component styles with ComponentStyles
+// =============================================================================
+// This allows themes to provide style overrides for Layer components.
+// Centralized here to ensure types are available regardless of which
+// hooks or components are imported.
+
+declare module '../theme/types' {
+ interface ComponentStyles {
+ hoverCard?: {
+ container?: StyleXStyles;
+ content?: StyleXStyles;
+ hoverIndication?: StyleXStyles;
+ };
+ tooltip?: {
+ container?: StyleXStyles;
+ content?: StyleXStyles;
+ hoverIndication?: StyleXStyles;
+ };
+ }
+}
diff --git a/packages/core/src/Layer/index.ts b/packages/core/src/Layer/index.ts
new file mode 100644
index 0000000000..ef7bc08623
--- /dev/null
+++ b/packages/core/src/Layer/index.ts
@@ -0,0 +1,46 @@
+/**
+ * @file index.ts
+ * @input Layer hooks and components
+ * @output Exports all Layer module public API
+ * @position Entry point for Layer module
+ *
+ * SYNC: When adding new Layer files, update exports here
+ */
+
+// Component style type augmentations (side-effect import)
+import './componentStyles';
+
+// Core layer hook
+export { useXDSLayer } from './useXDSLayer';
+export type {
+ LayerAlignment,
+ LayerPlacement,
+ ContextRenderProps,
+ FixedRenderProps,
+ ContextLayerOptions,
+ FixedLayerOptions,
+ ContextLayerReturn,
+ FixedLayerReturn,
+} from './useXDSLayer';
+
+// HoverCard hook and component
+export { useXDSHoverCard } from './useXDSHoverCard';
+export type {
+ HoverCardFocusTrigger,
+ XDSHoverCardOptions,
+ XDSHoverCardReturn,
+} from './useXDSHoverCard';
+
+export { XDSHoverCard } from './XDSHoverCard';
+export type { XDSHoverCardProps } from './XDSHoverCard';
+
+// Tooltip hook and component
+export { useXDSTooltip } from './useXDSTooltip';
+export type {
+ TooltipFocusTrigger,
+ XDSTooltipOptions,
+ XDSTooltipReturn,
+} from './useXDSTooltip';
+
+export { XDSTooltip } from './XDSTooltip';
+export type { XDSTooltipProps } from './XDSTooltip';
diff --git a/packages/core/src/Layer/useXDSHoverCard.tsx b/packages/core/src/Layer/useXDSHoverCard.tsx
new file mode 100644
index 0000000000..b569e7decf
--- /dev/null
+++ b/packages/core/src/Layer/useXDSHoverCard.tsx
@@ -0,0 +1,465 @@
+/**
+ * @file useXDSHoverCard.ts
+ * @input Uses useXDSLayer, React hooks
+ * @output Exports useXDSHoverCard hook for hover/focus triggered layers
+ * @position Layer hook; builds on useXDSLayer for hover card behavior
+ *
+ * SYNC: When modified, update:
+ * - /packages/core/src/Layer/README.md
+ * - /packages/core/src/Layer/index.ts
+ */
+
+import {
+ useCallback,
+ useContext,
+ useEffect,
+ useRef,
+ type ReactNode,
+ type RefCallback,
+} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import type { StyleXStyles } from '../theme/types';
+import { ThemeContext } from '../theme/ThemeContext';
+import {
+ useXDSLayer,
+ type ContextRenderProps,
+ type LayerAlignment,
+ type LayerPlacement,
+} from './useXDSLayer';
+import {
+ colorTokens,
+ elevationTokens,
+ radiusTokens,
+ spacingTokens,
+} from '../theme/tokens.stylex';
+
+const styles = stylex.create({
+ // Base container styles passed to useXDSLayer (includes animations)
+ container: {
+ backgroundColor: colorTokens.surface,
+ borderRadius: radiusTokens.container,
+ boxShadow: elevationTokens.hover,
+ // Animation: closed state (default) and open state
+ opacity: {
+ default: 0,
+ ':popover-open': 1,
+ },
+ transform: {
+ default: 'scale(0.95)',
+ ':popover-open': 'scale(1)',
+ },
+ // Transitions with allow-discrete for display/overlay
+ transitionProperty: 'opacity, transform, overlay, display',
+ transitionDuration: '0.15s',
+ transitionTimingFunction: 'ease',
+ transitionBehavior: 'allow-discrete',
+ // Entry animation starting state
+ '@starting-style': {
+ opacity: 0,
+ transform: 'scale(0.95)',
+ },
+ },
+ // Position-based margin styles
+ marginBlock: {
+ marginBlockStart: spacingTokens.space1,
+ marginBlockEnd: spacingTokens.space1,
+ marginInlineStart: 0,
+ marginInlineEnd: 0,
+ },
+ marginInline: {
+ marginBlockStart: 0,
+ marginBlockEnd: 0,
+ marginInlineStart: spacingTokens.space1,
+ marginInlineEnd: spacingTokens.space1,
+ },
+ // Content wrapper for padding and mouse events
+ content: {
+ paddingBlockStart: spacingTokens.space3,
+ paddingBlockEnd: spacingTokens.space3,
+ paddingInlineStart: spacingTokens.space3,
+ paddingInlineEnd: spacingTokens.space3,
+ },
+});
+
+/**
+ * Focus trigger behavior for hover cards
+ */
+export type HoverCardFocusTrigger = 'auto' | 'always' | 'never';
+
+export interface XDSHoverCardOptions {
+ /**
+ * Position placement relative to anchor
+ * @default 'above'
+ */
+ placement?: LayerPlacement;
+
+ /**
+ * Alignment along the placement axis
+ * @default 'center'
+ */
+ alignment?: LayerAlignment;
+
+ /**
+ * Delay before showing on hover (ms)
+ * @default 300
+ */
+ delay?: number;
+
+ /**
+ * Delay before hiding after mouse/focus leave (ms)
+ * @default 200
+ */
+ hideDelay?: number;
+
+ /**
+ * When to trigger on focus:
+ * - `auto`: Only if element is naturally focusable
+ * - `always`: Always attach focus listeners
+ * - `never`: Never attach focus listeners (for composite widgets)
+ *
+ * @default 'auto'
+ */
+ focusTrigger?: HoverCardFocusTrigger;
+
+ /**
+ * Whether the hover card is enabled.
+ * When false, hover/focus triggers are disabled.
+ *
+ * @default true
+ */
+ isEnabled?: boolean;
+
+ /**
+ * Callback fired when hover card is shown
+ */
+ onShow?: () => void;
+
+ /**
+ * Callback fired when hover card is hidden
+ */
+ onHide?: () => void;
+}
+
+export interface XDSHoverCardReturn {
+ /**
+ * Combined ref that sets both position and interaction on the same element.
+ * Shorthand for calling both positionRef and interactionRef.
+ */
+ ref: RefCallback<HTMLElement>;
+
+ /**
+ * Ref for the positioning anchor element.
+ * Injects anchorName style for CSS anchor positioning.
+ */
+ positionRef: RefCallback<HTMLElement>;
+
+ /**
+ * Ref for the interaction element.
+ * Attaches hover/focus event listeners via addEventListener.
+ * Can be the same element as positionRef or different.
+ */
+ interactionRef: RefCallback<HTMLElement>;
+
+ /**
+ * The CSS anchor name to use for positioning.
+ * Use this when you need to set anchorName manually (e.g., display:contents wrapper).
+ */
+ anchorId: string;
+
+ /**
+ * ID for aria-describedby on the trigger element.
+ * Caller should compose with other IDs using mergeIds utility.
+ */
+ describedBy: string;
+
+ /**
+ * Render function for hover card content.
+ * Returns anchor-positioned popover element.
+ */
+ renderHoverCard: (children: ReactNode, props?: ContextRenderProps) => ReactNode;
+}
+
+/**
+ * Check if an element is naturally focusable
+ */
+function isFocusable(element: HTMLElement): boolean {
+ // Elements with explicit tabindex
+ if (element.hasAttribute('tabindex')) {
+ return element.tabIndex >= 0;
+ }
+
+ // Naturally focusable elements
+ const focusableTags = ['A', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'];
+ if (focusableTags.includes(element.tagName)) {
+ return !(element as HTMLButtonElement).disabled;
+ }
+
+ // Elements with contenteditable
+ if (element.isContentEditable) {
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Hook for hover card behavior with hover/focus triggers.
+ *
+ * Builds on useXDSLayer to add:
+ * - Hover triggers with configurable delay
+ * - Focus triggers with auto-detection for focusable elements
+ * - Stay-open behavior when mouse/focus moves into the hover card
+ *
+ * @example
+ * ```tsx
+ * // Simple case: use combined ref
+ * const hoverCard = useXDSHoverCard({ placement: 'above' });
+ *
+ * <XDSButton ref={hoverCard.ref} aria-describedby={hoverCard.describedBy}>
+ * Hover me
+ * </XDSButton>
+ *
+ * {hoverCard.renderHoverCard(<ProfileCard user={user} />)}
+ *
+ * // Separate refs when position and interaction differ (e.g., display:contents wrapper)
+ * // Use positionRef for anchor, interactionRef for event listeners
+ * ```
+ */
+export function useXDSHoverCard(options: XDSHoverCardOptions = {}): XDSHoverCardReturn {
+ const {
+ placement = 'above',
+ alignment = 'center',
+ delay = 300,
+ hideDelay = 200,
+ focusTrigger = 'auto',
+ isEnabled = true,
+ onShow,
+ onHide,
+ } = options;
+
+ // Get theme context for component-level overrides
+ const themeContext = useContext(ThemeContext);
+ const themeContainerOverride = themeContext?.theme.components?.hoverCard?.container;
+ const themeContentOverride = themeContext?.theme.components?.hoverCard?.content;
+
+ // Select margin style based on placement axis
+ const marginStyle =
+ placement === 'above' || placement === 'below'
+ ? styles.marginBlock
+ : styles.marginInline;
+
+ const layer = useXDSLayer({
+ mode: 'context',
+ onShow,
+ onHide,
+ xstyle: [styles.container, marginStyle, themeContainerOverride],
+ });
+
+ const showTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+ const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+ const triggerRef = useRef<HTMLElement | null>(null);
+ const isHoveringContentRef = useRef(false);
+ // Track when we're dismissing via Escape to prevent re-show on refocus
+ const isEscapeDismissingRef = useRef(false);
+
+ // Clear all timeouts
+ const clearTimeouts = useCallback(() => {
+ if (showTimeoutRef.current) {
+ clearTimeout(showTimeoutRef.current);
+ showTimeoutRef.current = null;
+ }
+ if (hideTimeoutRef.current) {
+ clearTimeout(hideTimeoutRef.current);
+ hideTimeoutRef.current = null;
+ }
+ }, []);
+
+ // Schedule show with delay
+ const scheduleShow = useCallback(() => {
+ if (!isEnabled) return;
+ clearTimeouts();
+ showTimeoutRef.current = setTimeout(() => {
+ layer.show();
+ }, delay);
+ }, [isEnabled, clearTimeouts, layer, delay]);
+
+ // Schedule hide with delay
+ const scheduleHide = useCallback(() => {
+ clearTimeouts();
+ hideTimeoutRef.current = setTimeout(() => {
+ // Don't hide if hovering content
+ if (!isHoveringContentRef.current) {
+ layer.hide();
+ }
+ }, hideDelay);
+ }, [clearTimeouts, layer, hideDelay]);
+
+ // Event handlers
+ const handleMouseEnter = useCallback(() => {
+ scheduleShow();
+ }, [scheduleShow]);
+
+ const handleMouseLeave = useCallback(() => {
+ scheduleHide();
+ }, [scheduleHide]);
+
+ const handleFocusIn = useCallback(() => {
+ if (!isEnabled) return;
+ // Skip showing if we're in the middle of an Escape dismiss
+ if (isEscapeDismissingRef.current) {
+ isEscapeDismissingRef.current = false;
+ return;
+ }
+ clearTimeouts();
+ layer.show();
+ }, [isEnabled, clearTimeouts, layer]);
+
+ const handleFocusOut = useCallback(
+ (e: FocusEvent) => {
+ // Check if focus is moving to the hover card content
+ const relatedTarget = e.relatedTarget as HTMLElement | null;
+ const popoverElement = document.getElementById(layer.id);
+
+ if (popoverElement?.contains(relatedTarget)) {
+ // Focus moving into hover card, keep it open
+ return;
+ }
+
+ scheduleHide();
+ },
+ [layer.id, scheduleHide]
+ );
+
+ const handleKeyDown = useCallback(
+ (e: KeyboardEvent) => {
+ if (e.key === 'Escape') {
+ // Stop propagation so parent components don't react to the same Escape
+ e.stopPropagation();
+ // Hide immediately without refocusing (we're already on trigger)
+ clearTimeouts();
+ layer.hide();
+ }
+ },
+ [clearTimeouts, layer]
+ );
+
+ // Interaction ref that handles event listeners only
+ const interactionRef: RefCallback<HTMLElement> = useCallback(
+ (el: HTMLElement | null) => {
+ // Cleanup previous element
+ if (triggerRef.current) {
+ triggerRef.current.removeEventListener('mouseenter', handleMouseEnter);
+ triggerRef.current.removeEventListener('mouseleave', handleMouseLeave);
+ triggerRef.current.removeEventListener('focusin', handleFocusIn);
+ triggerRef.current.removeEventListener('focusout', handleFocusOut as EventListener);
+ triggerRef.current.removeEventListener('keydown', handleKeyDown);
+ }
+
+ if (el) {
+ // Attach hover listeners
+ el.addEventListener('mouseenter', handleMouseEnter);
+ el.addEventListener('mouseleave', handleMouseLeave);
+
+ // Attach focus listeners based on focusTrigger option
+ const shouldAttachFocus =
+ focusTrigger === 'always' ||
+ (focusTrigger === 'auto' && isFocusable(el));
+
+ if (shouldAttachFocus) {
+ el.addEventListener('focusin', handleFocusIn);
+ el.addEventListener('focusout', handleFocusOut as EventListener);
+ }
+
+ // Attach keydown for Escape handling
+ el.addEventListener('keydown', handleKeyDown);
+ }
+
+ triggerRef.current = el;
+ },
+ [focusTrigger, handleMouseEnter, handleMouseLeave, handleFocusIn, handleFocusOut, handleKeyDown]
+ );
+
+ // Combined ref - shorthand for calling both positionRef and interactionRef
+ const ref: RefCallback<HTMLElement> = useCallback(
+ (el: HTMLElement | null) => {
+ layer.ref(el);
+ interactionRef(el);
+ },
+ [layer.ref, interactionRef]
+ );
+
+ // Cleanup on unmount
+ useEffect(() => {
+ return () => {
+ clearTimeouts();
+ };
+ }, [clearTimeouts]);
+
+ // Render function that wraps layer.render with hover card behavior
+ const renderHoverCard = useCallback(
+ (children: ReactNode, props?: ContextRenderProps) => {
+ const renderProps = {
+ placement: props?.placement ?? placement,
+ alignment: props?.alignment ?? alignment,
+ };
+
+ return layer.render(
+ <div
+ {...stylex.props(styles.content, themeContentOverride)}
+ onMouseEnter={() => {
+ isHoveringContentRef.current = true;
+ clearTimeouts();
+ }}
+ onMouseLeave={() => {
+ isHoveringContentRef.current = false;
+ scheduleHide();
+ }}
+ onKeyDown={(e) => {
+ if (e.key === 'Escape') {
+ // Stop propagation so parent components don't react to the same Escape
+ e.stopPropagation();
+ // Set flag to prevent re-show when we refocus trigger
+ isEscapeDismissingRef.current = true;
+ // Hide immediately
+ clearTimeouts();
+ layer.hide();
+ // Refocus the trigger
+ triggerRef.current?.focus();
+ }
+ }}
+ onBlur={(e) => {
+ // Check if focus is moving back to the trigger or staying within content
+ const relatedTarget = e.relatedTarget as HTMLElement | null;
+ const popoverElement = e.currentTarget;
+
+ // If focus stays within the hover card, do nothing
+ if (popoverElement.contains(relatedTarget)) {
+ return;
+ }
+
+ // If focus is moving back to the trigger, do nothing
+ if (triggerRef.current?.contains(relatedTarget)) {
+ return;
+ }
+
+ // Focus is leaving the hover card entirely
+ scheduleHide();
+ }}
+ >
+ {children}
+ </div>,
+ renderProps
+ );
+ },
+ [layer, placement, alignment, clearTimeouts, scheduleHide, themeContentOverride]
+ );
+
+ return {
+ ref,
+ positionRef: layer.ref,
+ interactionRef,
+ anchorId: layer.anchorId,
+ describedBy: layer.id,
+ renderHoverCard,
+ };
+}
diff --git a/packages/core/src/Layer/useXDSLayer.tsx b/packages/core/src/Layer/useXDSLayer.tsx
new file mode 100644
index 0000000000..9bdfe6f5ed
--- /dev/null
+++ b/packages/core/src/Layer/useXDSLayer.tsx
@@ -0,0 +1,387 @@
+/**
+ * @file useXDSLayer.tsx
+ * @input Uses React hooks, Popover API, CSS anchor positioning
+ * @output Exports useXDSLayer hook for layer positioning and visibility
+ * @position Core layer utility; used by useXDSHoverCard, useXDSTooltip, etc.
+ *
+ * SYNC: When modified, update:
+ * - /packages/core/src/Layer/README.md
+ * - /packages/core/src/Layer/index.ts
+ */
+
+import React, {
+ useCallback,
+ useId,
+ useRef,
+ useState,
+ type ReactNode,
+ type RefCallback,
+} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import type { StyleXStyles } from '@stylexjs/stylex';
+import { spacingTokens } from '../theme/tokens.stylex';
+
+
+// Extend React's HTMLAttributes to include popover API attributes
+declare module 'react' {
+ interface HTMLAttributes<T> {
+ popover?: 'auto' | 'manual' | '';
+ }
+}
+
+const styles = stylex.create({
+ // Base reset for all layers
+ base: {
+ marginBlockStart: 0,
+ marginBlockEnd: 0,
+ marginInlineStart: 0,
+ marginInlineEnd: 0,
+ paddingBlockStart: 0,
+ paddingBlockEnd: 0,
+ paddingInlineStart: 0,
+ paddingInlineEnd: 0,
+ borderWidth: 0,
+ borderStyle: 'none',
+ overflow: 'visible',
+ },
+ // Fixed positioning mode
+ fixed: {
+ position: 'fixed',
+ },
+});
+
+/**
+ * Position placement relative to anchor
+ */
+export type LayerPlacement = 'above' | 'below' | 'start' | 'end';
+
+/**
+ * Alignment along the placement axis
+ */
+export type LayerAlignment = 'start' | 'center' | 'end';
+
+/**
+ * Render props for context mode (anchor positioning)
+ */
+export interface ContextRenderProps {
+ placement?: LayerPlacement;
+ alignment?: LayerAlignment;
+}
+
+/**
+ * Render props for fixed mode (manual coordinates)
+ */
+export interface FixedRenderProps {
+ x: number;
+ y: number;
+}
+
+/**
+ * Base options shared by both modes
+ */
+interface BaseLayerOptions {
+ /**
+ * Callback fired when layer is shown
+ */
+ onShow?: () => void;
+
+ /**
+ * Callback fired when layer is hidden
+ */
+ onHide?: () => void;
+
+ /**
+ * StyleX styles for the layer container
+ */
+ xstyle?: StyleXStyles;
+}
+
+/**
+ * Options for context mode (CSS anchor positioning)
+ */
+export interface ContextLayerOptions extends BaseLayerOptions {
+ mode: 'context';
+}
+
+/**
+ * Options for fixed mode (manual positioning)
+ */
+export interface FixedLayerOptions extends BaseLayerOptions {
+ mode: 'fixed';
+}
+
+/**
+ * Return type for context mode
+ */
+export interface ContextLayerReturn {
+ /**
+ * Ref to attach to trigger element.
+ * Injects anchorName style for CSS anchor positioning.
+ */
+ ref: RefCallback<HTMLElement>;
+
+ /**
+ * The CSS anchor name to use for positioning.
+ * Use this when you need to set anchorName manually (e.g., display:contents wrapper).
+ */
+ anchorId: string;
+
+ /**
+ * Show the layer
+ */
+ show: () => void;
+
+ /**
+ * Hide the layer
+ */
+ hide: () => void;
+
+ /**
+ * Whether the layer is currently open
+ */
+ isOpen: boolean;
+
+ /**
+ * Unique ID for aria-describedby
+ */
+ id: string;
+
+ /**
+ * Render function for layer content.
+ * Pass placement and alignment for anchor positioning.
+ */
+ render: (children: ReactNode, props?: ContextRenderProps) => ReactNode;
+}
+
+/**
+ * Return type for fixed mode
+ */
+export interface FixedLayerReturn {
+ /**
+ * Ref is undefined in fixed mode (no anchor element needed)
+ */
+ ref: undefined;
+
+ /**
+ * Show the layer
+ */
+ show: () => void;
+
+ /**
+ * Hide the layer
+ */
+ hide: () => void;
+
+ /**
+ * Whether the layer is currently open
+ */
+ isOpen: boolean;
+
+ /**
+ * Unique ID for aria-describedby
+ */
+ id: string;
+
+ /**
+ * Render function for layer content.
+ * Pass x and y coordinates for fixed positioning.
+ */
+ render: (children: ReactNode, props: FixedRenderProps) => ReactNode;
+}
+
+/**
+ * Map placement and alignment to CSS position-area value.
+ */
+function getPositionArea(
+ placement: LayerPlacement = 'above',
+ alignment: LayerAlignment = 'center'
+): string {
+ const placementMap: Record<LayerPlacement, string> = {
+ above: 'top',
+ below: 'bottom',
+ start: 'left',
+ end: 'right',
+ };
+
+ const cssPlacement = placementMap[placement];
+
+ // For above/below, alignment is horizontal
+ if (placement === 'above' || placement === 'below') {
+ if (alignment === 'start') return `${cssPlacement} span-right`;
+ if (alignment === 'end') return `${cssPlacement} span-left`;
+ return cssPlacement; // center
+ }
+
+ // For start/end, alignment is vertical
+ if (alignment === 'start') return `${cssPlacement} span-bottom`;
+ if (alignment === 'end') return `${cssPlacement} span-top`;
+ return `${cssPlacement} center`;
+}
+
+/**
+ * Core layer hook that handles popover behavior and positioning.
+ *
+ * Supports two positioning modes with type-safe render props:
+ * - `context`: CSS anchor positioning relative to a trigger element
+ * - `fixed`: Fixed positioning at specified coordinates
+ *
+ * @example
+ * ```tsx
+ * // Context mode (anchor positioning)
+ * const layer = useXDSLayer({ mode: 'context' });
+ *
+ * <button ref={layer.ref}>Trigger</button>
+ * {layer.render(<Content />, { placement: 'above', alignment: 'center' })}
+ *
+ * // Fixed mode (positioned at coordinates)
+ * const layer = useXDSLayer({ mode: 'fixed' });
+ *
+ * layer.show();
+ * {layer.render(<Content />, { x: mouseX, y: mouseY })}
+ * ```
+ */
+export function useXDSLayer(options: ContextLayerOptions): ContextLayerReturn;
+export function useXDSLayer(options: FixedLayerOptions): FixedLayerReturn;
+export function useXDSLayer(
+ options: ContextLayerOptions | FixedLayerOptions
+): ContextLayerReturn | FixedLayerReturn {
+ const { mode, onShow, onHide, xstyle } = options;
+ const id = useId();
+ const anchorId = `--xds-layer-${id.replace(/:/g, '')}`;
+
+ const [isOpen, setIsOpen] = useState(false);
+ const popoverRef = useRef<HTMLElement | null>(null);
+ const triggerRef = useRef<HTMLElement | null>(null);
+
+ const show = useCallback(() => {
+ if (popoverRef.current && !popoverRef.current.matches(':popover-open')) {
+ popoverRef.current.showPopover();
+ setIsOpen(true);
+ onShow?.();
+ }
+ }, [onShow]);
+
+ const hide = useCallback(() => {
+ if (popoverRef.current?.matches(':popover-open')) {
+ popoverRef.current.hidePopover();
+ setIsOpen(false);
+ onHide?.();
+ }
+ }, [onHide]);
+
+ // Ref for trigger element (context mode only)
+ const ref: RefCallback<HTMLElement> | undefined =
+ mode === 'context'
+ ? (el: HTMLElement | null) => {
+ // Cleanup previous element
+ if (triggerRef.current) {
+ (triggerRef.current.style as unknown as Record<string, string>).anchorName = '';
+ }
+
+ if (el) {
+ (el.style as unknown as Record<string, string>).anchorName = anchorId;
+ }
+
+ triggerRef.current = el;
+ }
+ : undefined;
+
+ // Handle popover toggle events (for sync with browser-initiated close)
+ const handleToggle = useCallback(
+ (e: Event) => {
+ const toggleEvent = e as ToggleEvent;
+ if (toggleEvent.newState === 'closed') {
+ setIsOpen(false);
+ onHide?.();
+ } else if (toggleEvent.newState === 'open') {
+ setIsOpen(true);
+ onShow?.();
+ }
+ },
+ [onShow, onHide]
+ );
+
+ // Render function for context mode
+ const renderContext = useCallback(
+ (children: ReactNode, props?: ContextRenderProps) => {
+ const { placement = 'above', alignment = 'center' } = props || {};
+
+ // CSS anchor positioning properties (dynamic, not in StyleX)
+ const anchorStyle: React.CSSProperties = {
+ positionAnchor: anchorId,
+ positionArea: getPositionArea(placement, alignment),
+ positionTryFallbacks: 'flip-block, flip-inline, flip-block flip-inline',
+ } as React.CSSProperties;
+
+ return (
+ <div
+ ref={(el) => {
+ popoverRef.current = el;
+ if (el) {
+ el.addEventListener('toggle', handleToggle);
+ }
+ }}
+ id={id}
+ popover="manual"
+ {...stylex.props(styles.base, xstyle)}
+ style={anchorStyle}
+ >
+ {children}
+ </div>
+ );
+ },
+ [anchorId, handleToggle, id, xstyle]
+ );
+
+ // Render function for fixed mode
+ const renderFixed = useCallback(
+ (children: ReactNode, props: FixedRenderProps) => {
+ const { x, y } = props;
+
+ // Dynamic position values
+ const positionStyle: React.CSSProperties = {
+ top: y,
+ left: x,
+ };
+
+ return (
+ <div
+ ref={(el) => {
+ popoverRef.current = el;
+ if (el) {
+ el.addEventListener('toggle', handleToggle);
+ }
+ }}
+ id={id}
+ popover="manual"
+ {...stylex.props(styles.base, styles.fixed, xstyle)}
+ style={positionStyle}
+ >
+ {children}
+ </div>
+ );
+ },
+ [handleToggle, id, xstyle]
+ );
+
+ if (mode === 'context') {
+ return {
+ ref: ref as RefCallback<HTMLElement>,
+ anchorId,
+ show,
+ hide,
+ isOpen,
+ id,
+ render: renderContext,
+ };
+ }
+
+ return {
+ ref: undefined,
+ show,
+ hide,
+ isOpen,
+ id,
+ render: renderFixed,
+ };
+}
diff --git a/packages/core/src/Layer/useXDSTooltip.tsx b/packages/core/src/Layer/useXDSTooltip.tsx
new file mode 100644
index 0000000000..6bbca6cc0f
--- /dev/null
+++ b/packages/core/src/Layer/useXDSTooltip.tsx
@@ -0,0 +1,393 @@
+/**
+ * @file useXDSTooltip.tsx
+ * @input Uses useXDSLayer, React hooks
+ * @output Exports useXDSTooltip hook for hover/focus triggered tooltips
+ * @position Layer hook; builds on useXDSLayer for tooltip behavior
+ *
+ * SYNC: When modified, update:
+ * - /packages/core/src/Layer/README.md
+ * - /packages/core/src/Layer/index.ts
+ */
+
+import {
+ useCallback,
+ useContext,
+ useEffect,
+ useRef,
+ type ReactNode,
+ type RefCallback,
+} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import type { StyleXStyles } from '../theme/types';
+import { ThemeContext } from '../theme/ThemeContext';
+import {
+ useXDSLayer,
+ type ContextRenderProps,
+ type LayerAlignment,
+ type LayerPlacement,
+} from './useXDSLayer';
+import {
+ colorTokens,
+ radiusTokens,
+ spacingTokens,
+ typographyTokens,
+} from '../theme/tokens.stylex';
+
+const styles = stylex.create({
+ // Base container styles - inverted colors for high contrast
+ container: {
+ // Inverted color palette: dark background, light text
+ backgroundColor: colorTokens.textPrimary,
+ color: colorTokens.surface,
+ borderRadius: radiusTokens.element,
+ // Typography
+ fontFamily: typographyTokens.fontFamilyBody,
+ fontSize: 14,
+ lineHeight: 1.4285714285714,
+ // Animation: closed state (default) and open state
+ opacity: {
+ default: 0,
+ ':popover-open': 1,
+ },
+ transform: {
+ default: 'scale(0.95)',
+ ':popover-open': 'scale(1)',
+ },
+ // Transitions with allow-discrete for display/overlay
+ transitionProperty: 'opacity, transform, overlay, display',
+ transitionDuration: '0.1s',
+ transitionTimingFunction: 'ease',
+ transitionBehavior: 'allow-discrete',
+ // Entry animation starting state
+ '@starting-style': {
+ opacity: 0,
+ transform: 'scale(0.95)',
+ },
+ },
+ // Position-based margin styles
+ marginBlock: {
+ marginBlockStart: spacingTokens.space1,
+ marginBlockEnd: spacingTokens.space1,
+ marginInlineStart: 0,
+ marginInlineEnd: 0,
+ },
+ marginInline: {
+ marginBlockStart: 0,
+ marginBlockEnd: 0,
+ marginInlineStart: spacingTokens.space1,
+ marginInlineEnd: spacingTokens.space1,
+ },
+ // Content wrapper for padding
+ content: {
+ paddingBlockStart: spacingTokens.space1,
+ paddingBlockEnd: spacingTokens.space1,
+ paddingInlineStart: spacingTokens.space2,
+ paddingInlineEnd: spacingTokens.space2,
+ },
+});
+
+/**
+ * Focus trigger behavior for tooltips
+ */
+export type TooltipFocusTrigger = 'auto' | 'always' | 'never';
+
+export interface XDSTooltipOptions {
+ /**
+ * Position placement relative to anchor
+ * @default 'above'
+ */
+ placement?: LayerPlacement;
+
+ /**
+ * Alignment along the placement axis
+ * @default 'center'
+ */
+ alignment?: LayerAlignment;
+
+ /**
+ * Delay before showing on hover (ms)
+ * @default 200
+ */
+ delay?: number;
+
+ /**
+ * Delay before hiding after mouse/focus leave (ms)
+ * @default 0
+ */
+ hideDelay?: number;
+
+ /**
+ * When to trigger on focus:
+ * - `auto`: Only if element is naturally focusable
+ * - `always`: Always attach focus listeners
+ * - `never`: Never attach focus listeners (for composite widgets)
+ *
+ * @default 'auto'
+ */
+ focusTrigger?: TooltipFocusTrigger;
+
+ /**
+ * Whether the tooltip is enabled.
+ * When false, hover/focus triggers are disabled.
+ *
+ * @default true
+ */
+ isEnabled?: boolean;
+
+ /**
+ * Callback fired when tooltip is shown
+ */
+ onShow?: () => void;
+
+ /**
+ * Callback fired when tooltip is hidden
+ */
+ onHide?: () => void;
+}
+
+export interface XDSTooltipReturn {
+ /**
+ * Combined ref that sets both position and interaction on the same element.
+ * Shorthand for calling both positionRef and interactionRef.
+ */
+ ref: RefCallback<HTMLElement>;
+
+ /**
+ * Ref for the positioning anchor element.
+ * Injects anchorName style for CSS anchor positioning.
+ */
+ positionRef: RefCallback<HTMLElement>;
+
+ /**
+ * Ref for the interaction element.
+ * Attaches hover/focus event listeners via addEventListener.
+ * Can be the same element as positionRef or different.
+ */
+ interactionRef: RefCallback<HTMLElement>;
+
+ /**
+ * The CSS anchor name to use for positioning.
+ * Use this when you need to set anchorName manually (e.g., display:contents wrapper).
+ */
+ anchorId: string;
+
+ /**
+ * ID for aria-describedby on the trigger element.
+ * Caller should compose with other IDs using mergeIds utility.
+ */
+ describedBy: string;
+
+ /**
+ * Render function for tooltip content.
+ * Returns anchor-positioned popover element.
+ */
+ renderTooltip: (children: ReactNode, props?: ContextRenderProps) => ReactNode;
+}
+
+/**
+ * Check if an element is naturally focusable
+ */
+function isFocusable(element: HTMLElement): boolean {
+ // Elements with explicit tabindex
+ if (element.hasAttribute('tabindex')) {
+ return element.tabIndex >= 0;
+ }
+
+ // Naturally focusable elements
+ const focusableTags = ['A', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'];
+ if (focusableTags.includes(element.tagName)) {
+ return !(element as HTMLButtonElement).disabled;
+ }
+
+ // Elements with contenteditable
+ if (element.isContentEditable) {
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Hook for tooltip behavior with hover/focus triggers.
+ *
+ * Builds on useXDSLayer to add:
+ * - Hover triggers with configurable delay
+ * - Focus triggers with auto-detection for focusable elements
+ * - Inverted color palette for high contrast
+ *
+ * Unlike HoverCard, tooltips:
+ * - Don't stay open when hovering the tooltip content
+ * - Have shorter delays
+ * - Use inverted colors (dark background, light text)
+ * - Are typically used for short, non-interactive text
+ *
+ * @example
+ * ```tsx
+ * const tooltip = useXDSTooltip({ placement: 'above' });
+ *
+ * <XDSButton ref={tooltip.ref} aria-describedby={tooltip.describedBy}>
+ * Hover me
+ * </XDSButton>
+ *
+ * {tooltip.renderTooltip('Helpful tooltip text')}
+ * ```
+ */
+export function useXDSTooltip(options: XDSTooltipOptions = {}): XDSTooltipReturn {
+ const {
+ placement = 'above',
+ alignment = 'center',
+ delay = 200,
+ hideDelay = 0,
+ focusTrigger = 'auto',
+ isEnabled = true,
+ onShow,
+ onHide,
+ } = options;
+
+ // Get theme context for component-level overrides
+ const themeContext = useContext(ThemeContext);
+ const themeContainerOverride = themeContext?.theme.components?.tooltip?.container;
+ const themeContentOverride = themeContext?.theme.components?.tooltip?.content;
+
+ // Select margin style based on placement axis
+ const marginStyle =
+ placement === 'above' || placement === 'below'
+ ? styles.marginBlock
+ : styles.marginInline;
+
+ const layer = useXDSLayer({
+ mode: 'context',
+ onShow,
+ onHide,
+ xstyle: [styles.container, marginStyle, themeContainerOverride],
+ });
+
+ const showTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+ const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+ const triggerRef = useRef<HTMLElement | null>(null);
+
+ // Clear all timeouts
+ const clearTimeouts = useCallback(() => {
+ if (showTimeoutRef.current) {
+ clearTimeout(showTimeoutRef.current);
+ showTimeoutRef.current = null;
+ }
+ if (hideTimeoutRef.current) {
+ clearTimeout(hideTimeoutRef.current);
+ hideTimeoutRef.current = null;
+ }
+ }, []);
+
+ // Schedule show with delay
+ const scheduleShow = useCallback(() => {
+ if (!isEnabled) return;
+ clearTimeouts();
+ showTimeoutRef.current = setTimeout(() => {
+ layer.show();
+ }, delay);
+ }, [isEnabled, clearTimeouts, layer, delay]);
+
+ // Schedule hide with delay
+ const scheduleHide = useCallback(() => {
+ clearTimeouts();
+ if (hideDelay > 0) {
+ hideTimeoutRef.current = setTimeout(() => {
+ layer.hide();
+ }, hideDelay);
+ } else {
+ layer.hide();
+ }
+ }, [clearTimeouts, layer, hideDelay]);
+
+ // Event handlers
+ const handleMouseEnter = useCallback(() => {
+ scheduleShow();
+ }, [scheduleShow]);
+
+ const handleMouseLeave = useCallback(() => {
+ scheduleHide();
+ }, [scheduleHide]);
+
+ const handleFocusIn = useCallback(() => {
+ if (!isEnabled) return;
+ clearTimeouts();
+ layer.show();
+ }, [isEnabled, clearTimeouts, layer]);
+
+ const handleFocusOut = useCallback(() => {
+ scheduleHide();
+ }, [scheduleHide]);
+
+ // Interaction ref that handles event listeners only
+ const interactionRef: RefCallback<HTMLElement> = useCallback(
+ (el: HTMLElement | null) => {
+ // Cleanup previous element
+ if (triggerRef.current) {
+ triggerRef.current.removeEventListener('mouseenter', handleMouseEnter);
+ triggerRef.current.removeEventListener('mouseleave', handleMouseLeave);
+ triggerRef.current.removeEventListener('focusin', handleFocusIn);
+ triggerRef.current.removeEventListener('focusout', handleFocusOut);
+ }
+
+ if (el) {
+ // Attach hover listeners
+ el.addEventListener('mouseenter', handleMouseEnter);
+ el.addEventListener('mouseleave', handleMouseLeave);
+
+ // Attach focus listeners based on focusTrigger option
+ const shouldAttachFocus =
+ focusTrigger === 'always' ||
+ (focusTrigger === 'auto' && isFocusable(el));
+
+ if (shouldAttachFocus) {
+ el.addEventListener('focusin', handleFocusIn);
+ el.addEventListener('focusout', handleFocusOut);
+ }
+ }
+
+ triggerRef.current = el;
+ },
+ [focusTrigger, handleMouseEnter, handleMouseLeave, handleFocusIn, handleFocusOut]
+ );
+
+ // Combined ref - shorthand for calling both positionRef and interactionRef
+ const ref: RefCallback<HTMLElement> = useCallback(
+ (el: HTMLElement | null) => {
+ layer.ref(el);
+ interactionRef(el);
+ },
+ [layer.ref, interactionRef]
+ );
+
+ // Cleanup on unmount
+ useEffect(() => {
+ return () => {
+ clearTimeouts();
+ };
+ }, [clearTimeouts]);
+
+ // Render function that wraps layer.render with tooltip styling
+ const renderTooltip = useCallback(
+ (children: ReactNode, props?: ContextRenderProps) => {
+ const renderProps = {
+ placement: props?.placement ?? placement,
+ alignment: props?.alignment ?? alignment,
+ };
+
+ return layer.render(
+ <div {...stylex.props(styles.content, themeContentOverride)}>{children}</div>,
+ renderProps
+ );
+ },
+ [layer, placement, alignment, themeContentOverride]
+ );
+
+ return {
+ ref,
+ positionRef: layer.ref,
+ interactionRef,
+ anchorId: layer.anchorId,
+ describedBy: layer.id,
+ renderTooltip,
+ };
+}
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 9ba4e0fe9c..ca98262a0b 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -1,6 +1,6 @@
/**
* @file index.ts
- * @input Imports from component directories (Button/, Layout/)
+ * @input Imports from component directories (Button/, Layout/, Layer/)
* @output Exports all public components and types for @xds/core
* @position Package entry point; consumed by external applications
*
@@ -13,5 +13,8 @@ export * from './Button';
// Layout utilities and components (includes XDSHStack, XDSVStack)
export * from './Layout';
+// Layer utilities and components (includes XDSHoverCard)
+export * from './Layer';
+
// Theme
export * from './theme';
diff --git a/packages/core/src/theme/defaultTheme.stylex.ts b/packages/core/src/theme/defaultTheme.stylex.ts
index ada28ef02e..4dd6fa57e0 100644
--- a/packages/core/src/theme/defaultTheme.stylex.ts
+++ b/packages/core/src/theme/defaultTheme.stylex.ts
@@ -146,13 +146,13 @@ const colorTheme = stylex.createTheme(colorTokens, {
// =============================================================================
const elevationTheme = stylex.createTheme(elevationTokens, {
- base: '0 0 1px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.4))',
+ base: '0px 0px 1px light-dark(rgba(0, 0, 0, 0.1), #111112)',
thumb: '0 1px 3px light-dark(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.4))',
dialog:
- '0 2px 2px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2)), 0 8px 24px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3))',
+ '0px 2px 2px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2)), 0px 8px 24px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3))',
hover:
- '0 1px 2px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2)), 0 2px 12px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2))',
- menu: '0 1px 1px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2)), 0 2px 8px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2))',
+ '0px 1px 2px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2)), 0px 2px 12px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2))',
+ menu: '0px 1px 1px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2)), 0px 2px 8px light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2))',
});
// =============================================================================