# MDX Structure Structure and conventions for API reference MDX pages at `site/src/content/docs/reference/`. ## Component Pages ### Frontmatter ```yaml --- title: MuteButton # PascalCase component name frameworkTitle: html: media-mute-button # HTML custom element tag name description: A button component for muting and unmuting audio playback --- ``` - `title`: PascalCase React component name - `frameworkTitle.html`: The `static tagName` from the HTML element file - `description`: One-line description of the component ### Page Structure ``` frontmatter imports (React demos, HTML demos) ## Anatomy ## Behavior (if applicable) ## Styling (if applicable) ## Accessibility (if applicable) ## Examples ### BasicUsage ### [Additional demos] ``` ## Imports Section ### React demo imports ```mdx {/* React demos */} import BasicUsageDemoReact from "@/components/docs/demos/{component}/react/css/BasicUsage"; import basicUsageReactTsx from "@/components/docs/demos/{component}/react/css/BasicUsage.tsx?raw"; import basicUsageReactCss from "@/components/docs/demos/{component}/react/css/BasicUsage.css?raw"; ``` - Component import: default export from `.tsx` (no extension needed) - Source imports: `?raw` suffix for displaying source code in tabs ### HTML demo imports ```mdx {/* HTML demos */} import BasicUsageDemoHtml from "@/components/docs/demos/{component}/html/css/BasicUsage.astro"; import basicUsageHtml from "@/components/docs/demos/{component}/html/css/BasicUsage.html?raw"; import basicUsageHtmlCss from "@/components/docs/demos/{component}/html/css/BasicUsage.css?raw"; import basicUsageHtmlTs from "@/components/docs/demos/{component}/html/css/BasicUsage.ts?raw"; ``` - `.astro` wrapper: renders live demo - `.html`, `.css`, `.ts`: `?raw` imports for source tabs ### Import naming convention | Type | Pattern | Example | |------|---------|---------| | React component | `{DemoName}DemoReact` | `BasicUsageDemoReact` | | React source | `{demoName}React{Ext}` | `basicUsageReactTsx` | | HTML component | `{DemoName}DemoHtml` | `BasicUsageDemoHtml` | | HTML source | `{demoName}Html` / `{demoName}Html{Ext}` | `basicUsageHtml`, `basicUsageHtmlCss` | ## Anatomy Section ```mdx ## Anatomy ```tsx ``` ```html ``` ``` For multi-part components, show composed usage: ```mdx ```tsx ``` ``` ## Prose Sections ### Behavior Explain state transitions, timing, and interaction logic. Use tables for enumerated states: ```mdx ## Behavior Toggles mute on and off. Exposes a derived `volumeLevel` based on the current volume and mute state: | Level | Condition | |-------|-----------| | `off` | Muted or volume is 0 | | `low` | Volume < 0.5 | ``` ### Styling **IMPORTANT:** All CSS code blocks in Styling sections MUST be wrapped in `` blocks. HTML examples use custom element selectors (`media-mute-button`), React examples use className-based selectors (`.mute-button`). Never show bare CSS without a framework wrapper — React users should not see HTML element selectors and vice versa. Show data attributes as a table, then framework-specific CSS selector patterns: ```mdx ## Styling | Attribute | Values | Description | |-----------|--------|-------------| | `data-muted` | Present / absent | Present when audio is muted | | `data-volume-level` | `"off"` \| `"low"` \| `"medium"` \| `"high"` | Current volume level | Use `data-volume-level` for multi-level icon switching: ```css media-mute-button[data-volume-level="off"] .icon-off { display: inline; } ``` React renders standard DOM elements with the same data attributes. Add a `className` and use it as the selector: ```css .mute-button[data-volume-level="off"] .icon-off { display: inline; } ``` ``` ### Accessibility Describe ARIA attributes, keyboard interactions, and label overrides: ```mdx ## Accessibility Renders a `