# OhMyEtch Docs
> Atomic, non-opinionated components for WordPress.
This file contains all documentation content in a single document following the llmstxt.org standard.
## OhMyEtch
OhMyEtch brings **atomic, headless-style components** to WordPress. Each component owns one job — accessible behavior, interaction logic, and the structural hooks you need — and nothing else. You compose them into any layout, any visual design, and any product surface you want.
That is the whole philosophy: **logic without opinion**.
## Atomic by design
Most WordPress component libraries ship finished UI patterns — cards, heroes, pricing tables, checkout shells — and ask you to adapt your design to theirs. OhMyEtch goes the other way.
An Accordion is not a FAQ block. A Dialog is not a modal popup template. A CartItemTitle is not a cart row layout. They are **atoms**: small, focused units that do one thing well and stay out of your way.
| What the component provides | What you provide |
|---|---|
| Keyboard navigation, ARIA, focus management | Typography, spacing, color |
| Open/close state, form scope, facet wiring | Grid, flex, breakpoints, brand |
| Consistent runtime behavior across the site | Markup structure inside slots, copy, imagery |
Because each atom has a narrow responsibility, the same component family can become wildly different experiences:
- **Accordion** → FAQ, settings panel, sidebar nav, product specs
- **Tabs** → product details, account settings, documentation sections
- **Dialog + Trigger** → newsletter signup, image lightbox entry, mobile menu
- **FacetTarget + SearchFacet** → job board filters, product catalog, map search
- **AddToCartForm + AttributeSelector** → variable product page, quick-view drawer, archive loop card
The component does not know your use case. It only guarantees the behavior works correctly every time.
## Composition is the product
OhMyEtch is built for **composition**, not configuration hacks.
Components nest inside each other. Triggers connect to targets by ID. Facets refresh targets. Woo atoms loop inside cart containers. You assemble molecules from atoms — exactly the structure your design needs, not the structure a plugin author guessed you would want.
That matters because real projects are diverse. A marketing site, a Woo store, and a filtered archive do not share one layout — but they can share the same **behavior layer**. OhMyEtch keeps that layer consistent while your Etch patterns, ACSS classes, and HTML stay entirely yours.
## Not opinionated — on purpose
Opinionated components save time until they do not. The moment you need a different markup order, a non-standard breakpoint, or a brand-specific interaction, you are fighting the block.
OhMyEtch deliberately avoids that:
- **No baked-in layouts** — slots and structure are yours to author
- **No visual theme** — default styling is minimal; design tokens and classes are yours
- **No product assumptions** — the same cart atom works in a drawer, a page, or a mini-cart dropdown
- **No dead ends** — when requirements change, you rearrange composition instead of replacing the component
This is what **headless** means in a WordPress context: the component runtime carries logic and accessibility; the presentation layer stays fully under your control.
## Why atomic wins in WordPress
WordPress sites are long-lived. Teams change. Designs evolve. Integrations multiply.
Atomic components stay stable because their contract is behavior, not appearance. When you refactor a pattern library, you restyle — you do not rewrite accordion keyboard handling. When you add WooCommerce, you compose new atoms into existing layouts instead of swapping entire page templates.
You get:
- **Predictable accessibility** — the same patterns everywhere, tested once
- **Reuse without duplication** — one Dialog family, many modal experiences
- **Freedom to scale** — from a single FAQ to a full checkout without changing philosophy
- **A system that grows with you** — new atoms join the same composition model
## What is in these docs
This site is the reference for composing OhMyEtch on real projects:
- **[UI Components](/category/ui-components)** — Accordion, Dialog, Tabs, Carousel, and more. Accessible, keyboard-navigable, composable families.
- **[Facets](/facets/overview)** — Search, filter, pagination, and map facets wired to dynamic result targets.
- **[Woo Components](/woo/overview)** — Cart, checkout, and product atoms for WooCommerce.
- **[Oh My IDEtch LocalWP Devkit](/oh-my-idetch/localwp-devkit/overview)** — A code-owned LocalWP workflow for building Etch sites with reusable projects, explicit checks, sync, WP-CLI wrappers, and project ZIPs.
Pick a family, read how it composes, and build the layout you actually want.
**Building with an AI agent?** See **[LLM & agent access](/llms)** for `llms.txt`, section bundles, and every plain Markdown export.
---
## Accordion
## Overview
Use the Accordion family when you need a group of expandable sections with built-in keyboard support, ARIA wiring, and animated panel open and close behavior. The family is composed, not standalone — the root component manages shared state and keyboard navigation, while child components define each individual section. Accordion works well for FAQs, settings panels, sidebar navigation, product feature lists, and any content that benefits from progressive disclosure.
## Authoring Structure
```
Accordion
└── Accordion Item
├── Accordion Header
│ └── Accordion Trigger
└── Accordion Content
```
### Placement Rules
| Component | Placement | Role |
|---|---|---|
| **Accordion** | Top-level wrapper. | Owns state, keyboard navigation, and shared options. |
| **Accordion Item** | Direct child of `Accordion`. | The runtime looks for direct item children when it initializes. |
| **Accordion Header** | Inside `Accordion Item`. | Provides heading semantics (`` – ``) for the trigger. |
| **Accordion Trigger** | Usually inside `Accordion Header`. | Interactive control users click or focus to toggle a panel. |
| **Accordion Content** | Inside `Accordion Item`, after the header. | The panel that opens and closes. |
## Quick Start
{`
{#slot default}
{#slot default}
{#slot default}Manage your account preferences here.{/slot}
{/slot}
{/slot}
`}
When the `AccordionHeader` has an empty slot and a `content.label` value, it auto-generates a trigger for you — no need to nest `AccordionTrigger` manually.
{`
{#slot default}
{#slot default}
{#slot default}
{#slot default}Shipping{/slot}
{/slot}
{#slot default}
Shipping content goes here.
{/slot}
{/slot}
{/slot}
`}
Use the explicit structure when you need custom markup inside the trigger — icons, badges, or any content beyond a plain label.
---
## Family Components
### Accordion (Root)
The root component wraps all items and manages shared behavior: expansion mode (single or multiple), keyboard navigation, loop wrapping, and animation timing. It does not render any visible UI itself — only a container element.
HTML tag for the root element.
Expansion mode. `"single"` allows only one item open at a time ( Disclosure pattern). `"multiple"` allows any number of items open simultaneously.
Orientation of the accordion. Affects which arrow keys navigate between triggers and how focus moves.
Whether keyboard navigation wraps from the last trigger back to the first, and vice versa.
Disables all items in the accordion when `true`. Individual items can still override this with their own `disabled` prop.
Duration of the expand/collapse animation in milliseconds, as a string.
CSS class applied to the root element.
#### Expansion Modes
- **`single`** — Opening one item automatically closes the previously open item. Only one panel is visible at a time. This is the classic accordion behavior.
- **`multiple`** — Each item toggles independently. Opening one does not affect others. Use this for disclosure-style UIs where users may want several sections visible.
#### Keyboard Behavior
When a trigger has focus:
| Key | Action |
|---|---|
| `Enter` / `Space` | Toggle the associated panel. |
| `ArrowDown` | Move focus to the next trigger (vertical orientation). |
| `ArrowUp` | Move focus to the previous trigger (vertical orientation). |
| `ArrowRight` | Move focus to the next trigger (horizontal orientation). |
| `ArrowLeft` | Move focus to the previous trigger (horizontal orientation). |
| `Home` | Move focus to the first trigger. |
| `End` | Move focus to the last trigger. |
When `loop` is `true`, pressing `ArrowDown` on the last trigger wraps to the first, and `ArrowUp` on the first wraps to the last. In RTL layouts, horizontal arrow keys are automatically reversed.
#### Accessibility
The root component generates unique IDs for each item and wires up ARIA attributes automatically:
- Each trigger has `aria-expanded` and `aria-controls` pointing to its content panel.
- Each content panel has `role="region"` and `aria-labelledby` pointing to its header.
- `data-ome-state` attributes sync open/closed state for CSS targeting.
---
### Accordion Item
Each `AccordionItem` represents a single expandable section. It is the direct child of the root `Accordion` and the parent of `AccordionHeader` and `AccordionContent`. The runtime discovers items by scanning for direct item children at initialization time.
HTML tag for the item wrapper.
Disables this specific item. Overrides the root `disabled` prop on a per-item basis.
Initial open state. In `single` mode, only the last item with `open="true"` will actually render open.
Additional CSS class added to the item when it is in the open state. Useful for CSS-driven animations or visibility changes.
CSS class applied to the item element.
---
### Accordion Header
The header provides semantic heading markup (`` – ``) for the trigger. It determines the heading level and can auto-generate a trigger when its slot is empty but a `content.label` value is provided. This is the simplest way to create an accordion — just set the label and move on.
HTML tag for the header wrapper.
Heading level for the header (`"1"` through `"6"`). Renders as `` – `` accordingly.
Tag used for the auto-generated trigger's inner label wrapper when the header creates a trigger from `content.label`.
Fallback trigger label. When the header slot is empty, this value is used to generate a trigger automatically.
CSS class applied to the header element.
#### Header Fallback Rendering
When the header slot is empty and `content.label` has a value, the header auto-generates a trigger element. This means you can build a working accordion with just `AccordionHeader` and `AccordionContent` — no explicit `AccordionTrigger` needed:
```
Accordion Header (slot empty + label set)
└── Auto-generated Trigger
└── Label text
└── Chevron icon
```
---
### Accordion Trigger
The interactive element users click, tap, or focus to toggle a panel. When used inside `AccordionHeader`, it receives heading semantics from the parent. When the slot is empty, the trigger renders a label wrapper and chevron icon using its `content.label` value.
Tag for the fallback label wrapper only. **This does not change the outer button element** — the trigger always renders a `` as its interactive root.
Disables this trigger independently of the item or root `disabled` setting.
Fallback label text. Used when the trigger slot is empty to render a text label and chevron.
CSS class applied to the trigger button element.
CSS class applied to the label text element inside the trigger.
CSS class applied to the chevron icon inside the trigger.
#### Trigger Fallback Rendering
When the trigger slot is empty and `content.label` is set, the trigger renders:
```
Label text
▼
```
---
### Accordion Content
The content panel that expands and collapses. It is animated by default using the root's `animationDuration` setting. Content is hidden via `height: 0` and `overflow: hidden` when collapsed — it remains in the DOM at all times.
HTML tag for the content panel.
When `true`, the collapsed panel uses the browser's `hidden="until-found"` attribute instead of `height: 0`. This allows browser find-in-page (`Ctrl+F` / `Cmd+F`) to search inside collapsed panels and expand them automatically when a match is found. Use this when your accordion contains searchable reference content.
CSS class applied to the content element.
---
## Common Mistakes
Do not place another block between `Accordion` and `AccordionItem`. The runtime scans for **direct** item children at initialization. Adding a wrapper (like a Group or Stack block) between them breaks item discovery and the accordion will not initialize.
`AccordionTrigger` `structure.tag` only changes the inner fallback label wrapper — the outer interactive element is always a ``. If you need a different element, use the trigger slot to provide your own content instead.
`AccordionContent` `settings.hiddenUntilFound` is specifically for browser find-in-page integration. It is not a general-purpose visibility toggle and may cause unexpected behavior if used outside its intended purpose.
---
## FAQs
Can I nest accordions inside each other?
Yes. You can place an `Accordion` inside an `AccordionContent` panel. Each nested accordion manages its own state independently. Make sure to use appropriate heading levels — if the outer accordion uses `level="2"`, the inner accordion should use `level="3"` to maintain a correct document outline.
How do I style individual items differently?
Use the `class` prop on `AccordionItem` to apply a custom class, and the `toggleClass` prop to add an additional class when the item is open. You can also target items with CSS using `data-ome-state="open"` or `data-ome-state="closed"` attributes that the runtime adds automatically.
Can I start with multiple items open?
In `multiple` mode, yes — set `open="true"` on each item you want expanded on load. In `single` mode, only one item can be open at a time, so only the last item with `open="true"` will actually render expanded.
What happens if I don't include a Header?
The accordion will still function, but you will lose heading semantics and ARIA labeling. The content panel will not have an `aria-labelledby` association, which reduces accessibility. Always include an `AccordionHeader` (or ensure your custom trigger provides equivalent semantics).
---
## Breadcrumbs
## Overview
Breadcrumbs is a **server-rendered** navigation component that automatically builds a breadcrumb trail from the active WordPress query. Unlike interactive components (Accordion, Tabs, etc.), Breadcrumbs has no client-side runtime — the trail is resolved entirely in PHP during block rendering and injected into the page as final HTML.
The component automatically handles pages with parent/ancestor hierarchies, single posts with category ancestry, custom post type archives, term archives, date archives, author archives, search results, and 404 pages. It also outputs `BreadcrumbList` JSON-LD structured data for SEO when enabled.
Breadcrumbs is a single-component family — there are no sub-components. It is placed into patterns or templates and the server-side trail resolver does the rest. When WordPress cannot infer an intermediate hierarchy item, such as a CPT archive before a taxonomy archive shared by multiple post types, use structured manual links.
## Authoring Structure
```
Breadcrumbs (OmeBreadcrumbs)
├── Home slot (optional custom home content)
└── Separator slot (optional custom separator content)
```
### Placement Rules
| Slot | Purpose |
|---|---|
| **home** | Custom content inside the home link. When empty, the `homeLabel` text is used. |
| **separator** | Custom separator between items. When empty, the `separator` text is used. |
## How It Works
Breadcrumbs uses a two-phase rendering pipeline:
1. **Editor / Preview phase** — The component renders a static preview with placeholder items ("Home", "Blog", "Current page") so the editor shows a representative breadcrumb trail.
2. **Frontend phase** — A block interceptor (`BreadcrumbsBlockInterceptor`) replaces the placeholder with a real breadcrumb trail resolved from the current WordPress query context via `BreadcrumbTrailResolver`.
This means the breadcrumb trail follows the current page context. Manual links are only needed for hierarchy items WordPress cannot determine safely from the active query.
### Supported WordPress Contexts
| Context | Trail |
|---|---|
| **Front page** | Hidden by default (enable with `showOnFrontPage`). |
| **Posts index** | Home → Blog (or custom Posts Page). |
| **Single post** | Home → Blog → Parent Category → Child Category → Post. |
| **Page (with ancestors)** | Home → Parent → … → Page. |
| **Custom post type** | Home → Archive → Parent Term → Child Term → Post (when a public hierarchical taxonomy is assigned). |
| **Post type archive** | Home → Archive. |
| **Term archive** | Home → … → Term (with ancestor terms for hierarchical taxonomies). |
| **Date archive** | Home → Year → Month → Day (drills down as deep as the URL). |
| **Author archive** | Home → Author name. |
| **Search results** | Home → Search. |
| **404** | Home → Not Found. |
## Quick Start
{` `}
{`
{#slot separator}
→
{/slot}
`}
{`
{#slot home}
{/slot}
`}
{` `}
---
## Props
Text used for the home breadcrumb. Shown when the `home` slot is empty.
Text shown between breadcrumb items. Shown when the `separator` slot is empty.
Accessible label for the `` landmark. Screen readers announce this to identify the navigation region.
Controls where manual links are inserted. Use `beforeCurrent` to place them immediately before the current page, or `afterHome` to place them immediately after the home crumb.
Structured breadcrumb links with text `label` and text `url` fields. Valid rows render with the same item, link, separator, and schema behavior as automatic crumbs.
Includes the home breadcrumb as the first item in the trail.
Includes the current page as the last item in the trail. When `false`, the trail ends at the parent item.
Renders the current page breadcrumb as a link (``) instead of a plain ``. The current item always has `aria-current="page"` regardless of this setting.
Keeps breadcrumbs visible on the front page. When `false` (default), the component outputs nothing on the front page.
Outputs a `BreadcrumbList` JSON-LD script tag after the navigation markup. Schema is only rendered when there are at least two items with URLs. Disable this if your theme or an SEO plugin already provides breadcrumb schema.
Removes automatic category or taxonomy crumbs from singular post and custom post type trails. Taxonomy archive pages still show their queried term hierarchy.
CSS class applied to the root `` element.
CSS class applied to the `` list element.
CSS class applied to each `` item element.
CSS class applied to each `` link element.
CSS class applied to the current page item (whether rendered as a link or span).
CSS class applied to each separator `` element.
---
## Default CSS
The default styles provide a horizontal flex layout with ACSS-aware custom properties:
```css
/* Root: inherits text color and uses small text size */
.ome-breadcrumbs-root-default {
color: var(--text-dark, currentColor);
font-size: var(--text-s, 0.875rem);
}
/* List: horizontal flexbox with wrapping */
.ome-breadcrumbs-list-default {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-xs, 0.75rem);
margin: 0;
padding: 0;
}
/* Items: inline flex, no list style */
.ome-breadcrumbs-item-default {
display: inline-flex;
align-items: center;
gap: var(--space-xs, 0.75rem);
list-style: none;
}
```
The fixed base styles enforce `box-sizing: border-box`, hide `[hidden]` elements, and provide `:focus-visible` outline styling on links — matching the same foundation used across all Etch components.
---
## Accessibility
The rendered markup uses semantic HTML:
- The root element is a `` with `aria-label` (defaults to "Breadcrumb").
- The list uses an ordered list `` for correct semantics.
- The current page item has `aria-current="page"`.
- Separators are marked `aria-hidden="true"` to avoid screen reader noise.
- `:focus-visible` outlines are provided by the fixed base styles.
---
## Common Mistakes
Breadcrumbs is entirely server-rendered. There is no JavaScript runtime for this component — the trail is resolved in PHP during `render_block`. You cannot dynamically update breadcrumbs with client-side JavaScript.
By default `showOnFrontPage` is `false`, which means the component outputs nothing on the front page. If your design calls for breadcrumbs on the homepage, set `showOnFrontPage` to `true` and `showHome` to `true`.
If you use Yoast SEO, Rank Math, or another plugin that generates `BreadcrumbList` JSON-LD, set `enableSchema` to `false` to avoid duplicate schema output.
The editor renders static placeholder items ("Home", "Blog", "Current page") so you can preview the visual design. The actual breadcrumb trail is only generated on the frontend from the real WordPress query context.
A taxonomy can be attached to multiple post types, so Breadcrumbs does not guess which CPT archive belongs before that term archive. Add a manual link for that hierarchy item instead.
---
## FAQs
Can I customize which categories appear for single posts?
The trail resolver picks the first assigned term (lowest `term_id`) from the post's categories. To control which category appears, assign only one category to the post, or use a plugin that filters `get_the_terms`.
Does this work with custom post types?
Yes. For custom post types with `has_archive`, the resolver includes the post type archive link. If the post type has hierarchical taxonomies, the first assigned term in the first public hierarchical taxonomy is included with its ancestors.
How do I add a manual hierarchy item?
Add rows to `manualLinks.links` with a `label` and `url`. By default, manual links appear before the current page. Set `manualLinks.position` to `afterHome` when the link should sit immediately after the home crumb.
Can I use a custom icon or SVG for the separator?
Yes. Use the `separator` slot to provide custom markup instead of the plain text separator:
```jsx
{#slot separator}
{/slot}
```
What happens on pages with no ancestors?
For a top-level page, the trail is simply: Home → Page Title. For nested pages, each ancestor is included in order: Home → Parent → Grandparent → Page Title.
Why is the schema not appearing?
Schema output requires at least two items with URLs in the trail. If `showHome` is `false` and only the current page remains, or if the trail has fewer than two linkable items, the JSON-LD script tag is omitted. Also check that `enableSchema` is `true`.
---
## Carousel
## Overview
Use the Carousel family when you need swipeable or keyboard-navigable slides with optional autoplay, looping, synced instances, and external navigation buttons. The root component owns the Swiper.js runtime configuration, while `Carousel Slide` defines each slide. External `Carousel Previous Button`, `Carousel Next Button`, and `Carousel Dots` components can be placed anywhere on the page and target a specific carousel by ID. Multiple carousels sharing a sync group ID stay aligned automatically — ideal for main-content-plus-thumbnail patterns.
## Authoring Structure
```
Carousel
├── Carousel Slide
│ └── slide content
├── Carousel Slide
│ └── slide content
└── Carousel Slide
└── slide content
Carousel Previous Button (anywhere on page)
Carousel Next Button (anywhere on page)
Carousel Dots (anywhere on page)
```
### Placement Rules
| Component | Placement | Role |
|---|---|---|
| **Carousel** | Top-level wrapper. | Owns the Swiper runtime, slide configuration, IDs, and sync settings. |
| **Carousel Slide** | Direct child of `Carousel`. | Each direct child becomes one navigable slide. |
| **Carousel Previous Button** | Anywhere on the page. | Targets a carousel by ID and moves it to the previous slide. |
| **Carousel Next Button** | Anywhere on the page. | Targets a carousel by ID and moves it to the next slide. |
| **Carousel Dots** | Anywhere on the page. | Renders clickable pagination bullets for a targeted carousel. |
## Quick Start
{`
{#slot default}
{#slot default}Slide 1{/slot}
{#slot default}Slide 2{/slot}
{/slot}
`}
{`
{#slot default}
{#slot default}{/slot}
{#slot default}{/slot}
{/slot}
`}
{`
{#slot default}
{#slot default}{/slot}
{#slot default}{/slot}
{/slot}
{#slot default}
{#slot default}{/slot}
{#slot default}{/slot}
{/slot}
`}
---
## Family Components
### Carousel (Root)
The root container wraps all slides and manages the Swiper.js runtime: slide layout, navigation wiring, keyboard support, autoplay, effects, and sync groups. It renders a `div` (configurable via `tag`) with the `swiper` class and a child `swiper-wrapper`. The slot accepts `Carousel Slide` children directly.
HTML tag for the carousel root element.
Stable carousel ID used by external buttons, dots, and synced carousels to target this instance. Required when using any external control.
Shared sync group ID. Carousels with the same group ID stay synchronized — sliding one advances the others.
Zero-based slide index that is active on first load.
Wraps from the last slide back to the first instead of disabling navigation at the ends.
Centers the active slide in the viewport.
Number of slides visible at once. Use `"auto"` to size slides from CSS widths.
Gap between slides in pixels.
Enables left and right arrow key navigation when the carousel root is focused.
Enables breakpoint-based slides per view and spacing overrides.
Minimum viewport width in pixels where this row starts applying.
Slides per view at this breakpoint. Use `"auto"` to size slides from CSS widths.
Gap between slides in pixels at this breakpoint.
Advances slides automatically.
Delay between autoplay transitions in milliseconds.
Stops autoplay after user interactions (swipe, click).
Pauses autoplay while the pointer is over the carousel.
Stops autoplay when the last slide is reached in non-loop mode.
Runs autoplay toward previous slides instead of next slides.
Active Swiper transition effect. `"slide"` is the lightweight default — other effects load their runtime only when selected.
**Fade effect.** Fades slides over each other instead of briefly showing content underneath.
**Coverflow effect.** Slide rotation in degrees.
**Coverflow effect.** Depth offset in pixels.
**Coverflow effect.** Spacing stretch between slides in pixels or percent.
**Coverflow effect.** Effect multiplier.
**Coverflow effect.** Slide scale effect.
**Coverflow / Flip / Cube / Cards effects.** Adds shadows to slides.
**Flip effect.** Limits edge slide rotation.
**Cube effect.** Adds a main cube shadow.
**Cube effect.** Main shadow offset in pixels.
**Cube effect.** Main shadow scale ratio.
**Cards effect.** Offset distance per slide in pixels.
**Cards effect.** Rotation angle per slide in degrees.
**Cards effect.** Enables cards rotation.
**Creative effect.** Swiper `creativeEffect` object for advanced transforms.
Uses the JSON config object as the source of truth for Swiper behavior while keeping identity-driven controls (navigation, dots, sync) wired automatically.
Custom Swiper configuration object. Effect selection and identity wiring stay controlled by Etch — the JSON refines behavior like breakpoints, autoplay, and keyboard options.
CSS class applied to the carousel root element. The `swiper` class is always included.
#### Settings and Autoplay Visibility
The **Settings** and **Autoplay** prop groups are visible only when `useCustomConfig` is `false`. When custom config mode is on, those props are hidden and the `jsonConfig` object becomes the behavior source of truth instead.
#### Sync Groups
Carousels that share the same `identity.groupId` stay synchronized via Swiper's Controller module. This is useful for main-carousel-plus-thumbnail patterns — sliding one carousel automatically advances the other. At least two carousels must share a group ID for sync to activate.
#### Navigation Boundary State
In non-loop mode, external navigation buttons receive a `data-ome-carousel-nav-disabled` attribute at the boundaries:
- The **Previous** button is disabled at the first slide.
- The **Next** button is disabled at the last slide.
When `loop` is `true`, buttons never disable — the carousel wraps around instead.
#### Keyboard Behavior
When the carousel root has focus:
| Key | Action |
|---|---|
| `ArrowRight` | Advance to the next slide. |
| `ArrowLeft` | Go back to the previous slide. |
Keyboard navigation is enabled by default (`keyboardEnabled: true`) and scoped to the viewport (`onlyInViewport: true`). Disable it by setting `keyboardEnabled` to `false`.
#### Accessibility
The root component wires up ARIA attributes via Swiper's A11y module:
- The carousel container announces `"Content carousel"` as its role message.
- Navigation buttons have `aria-label` defaults (`"Previous slide"`, `"Next slide"`), overridable via each button's `label` prop.
- Pagination dots announce `"Go to slide N"` via `aria-label`.
- The Swiper A11y module provides live-region announcements for slide changes, including `"This is the first slide"` and `"This is the last slide"` messages.
---
### Carousel Slide
Each `CarouselSlide` represents a single slide inside the carousel. It renders as a `` with the `swiper-slide` class and accepts any content in its default slot.
CSS class names applied to the slide container.
---
### Carousel Previous Button
An external `` element that navigates a targeted carousel backward. It can be placed anywhere on the page — it does not need to be inside the carousel root. When the slot is empty, a default left-arrow SVG icon is rendered automatically.
Target carousel ID. This must match `identity.id` on the carousel root you want to control.
Accessible label announced by assistive technology.
CSS class names applied to the button element.
#### Fallback Icon
When the button slot is empty, a default left-arrow SVG icon is rendered. Provide slot content only when you want custom button UI (text, icon, or both).
#### Boundary Behavior
At the first slide, the previous button receives `data-ome-carousel-nav-disabled` when looping is off. With `settings.loop="true"`, the carousel wraps instead of disabling the button.
---
### Carousel Next Button
An external `` element that navigates a targeted carousel forward. Identical behavior to the Previous Button but in the opposite direction. When the slot is empty, a default right-arrow SVG icon is rendered automatically.
Target carousel ID. This must match `identity.id` on the carousel root you want to control.
Accessible label announced by assistive technology.
CSS class names applied to the button element.
#### Fallback Icon
When the button slot is empty, a default right-arrow SVG icon is rendered. Provide slot content only when you want custom button UI.
#### Boundary Behavior
At the last slide, the next button receives `data-ome-carousel-nav-disabled` when looping is off. With `settings.loop="true"`, the carousel wraps instead of disabling the button.
---
### Carousel Dots
External pagination dots that render one clickable bullet per slide. The dots container can be placed anywhere on the page and targets a carousel by ID. At runtime, the template dot markup is extracted from the component and used to generate the correct number of bullets dynamically.
Target carousel ID. This must match `identity.id` on the carousel root.
CSS class names applied to the dots wrapper element.
CSS class names applied to each generated dot button. The active dot also receives `ome-carousel-dot-active` and `swiper-pagination-bullet-active`.
#### Dot Generation
On initialization, the dots component extracts a hidden template button (`data-ome-carousel-dot-template`) and uses it to generate the correct number of bullets via Swiper's `renderBullet` callback. Each bullet is a `` with `aria-label="Go to slide N"`. The active bullet receives the `ome-carousel-dot-active` class in addition to Swiper's default active class.
---
## CSS Custom Properties
### Navigation Buttons
```css
/* Disabled state */
[data-ome-carousel-prev][data-ome-carousel-nav-disabled],
[data-ome-carousel-next][data-ome-carousel-nav-disabled] {
cursor: not-allowed;
opacity: 0.5;
}
```
Navigation buttons receive `data-ome-carousel-nav-disabled` when the carousel is at the boundary in non-loop mode. Use this attribute to style the disabled state.
### Pagination Dots
```css
.ome-carousel-dots-default {
display: flex;
align-items: center;
gap: 0.5rem;
}
.ome-carousel-dot-default {
width: 0.75rem;
height: 0.75rem;
padding: 0;
border: 0;
border-radius: 999px;
background: currentColor;
opacity: 0.35;
cursor: pointer;
}
.ome-carousel-dot-default.ome-carousel-dot-active,
.ome-carousel-dot-default.swiper-pagination-bullet-active {
opacity: 1;
}
```
### Carousel Root
```css
[data-ome-carousel-root] {
width: 100%;
position: relative;
overflow: hidden;
}
[data-ome-carousel-root][data-ome-carousel-initialized] {
touch-action: pan-y;
}
```
The carousel root always receives `data-ome-carousel-root`. After initialization, `data-ome-carousel-initialized` is added and `touch-action: pan-y` is applied for swipe support.
---
## Common Mistakes
External buttons and dots target a carousel by ID. If `identity.id` is empty on the root, previous buttons, next buttons, and dots cannot connect. The Etch editor shows a warning callout when the ID is missing.
Only `Carousel Slide` children become navigable slides. Putting raw HTML or other blocks directly inside the carousel root (without wrapping them in a slide) breaks the Swiper layout.
In non-loop mode, the previous button disables at the first slide and the next button disables at the last slide. Enable `settings.loop="true"` if you need wrap-around navigation.
Custom JSON config can refine the selected effect's parameters but cannot activate a different effect. The `effects.effect` prop controls which effect loads. For example, setting `effect: "fade"` in the JSON has no effect when `effects.effect` is `"slide"`.
---
## FAQs
How do I sync two carousels together?
Set the same `identity.groupId` value on both carousel roots. The runtime uses Swiper's Controller module to keep them aligned. Each carousel also needs its own unique `identity.id`. This is commonly used for a main content carousel paired with a thumbnail strip.
Can I have multiple sets of navigation buttons for the same carousel?
Yes. You can place multiple `Carousel Previous Button` and `Carousel Next Button` components on the page, all targeting the same carousel ID. The runtime updates all matching buttons when the slide changes or the carousel reaches a boundary.
How do I make slides responsive at different viewport widths?
Set `enableResponsive` to `true` and add breakpoint rows. Each row specifies a minimum viewport width (`breakpoint`), `slidesPerView`, and `spaceBetween`. For example, a breakpoint at `768` with `slidesPerView: 2` shows two slides on screens 768px and wider.
When should I use custom config mode?
Use `useCustomConfig: true` when you need Swiper behavior that the built-in settings and autoplay props don't cover — for example, custom `freeMode`, `slidesPerGroup`, or advanced `breakpoints` configurations. The custom JSON becomes the source of truth for behavior, but identity-driven wiring (navigation buttons, dots, sync groups) stays connected automatically.
Do navigation buttons and dots need to be inside the carousel?
No. `Carousel Previous Button`, `Carousel Next Button`, and `Carousel Dots` can be placed anywhere on the page. They connect to the carousel by matching their `targeting.for` prop to the carousel's `identity.id`.
---
## Dialog
## Overview
Use the Dialog family when you need a modal overlay — confirmations, forms, product previews, alerts, or any content that demands focused user attention. The family is composed of five components that work together: the root `Dialog` holds the modal content, `DialogTrigger` opens it from anywhere on the page, and `DialogTitle`, `DialogDescription`, and `DialogClose` provide structure and accessibility inside.
Dialogs are unique among Etch components because **the trigger and the dialog are siblings, not parent and child**. They connect via a shared ID — `identity.dialogId` on the Dialog must match `targeting.targetDialogId` on the trigger. When opened, the dialog node is physically moved into a shared runtime host at the end of `document.body`, then restored to its authored position on close.
## Authoring Structure
```
DialogTrigger (separate from Dialog — anywhere on the page)
Dialog (the modal content)
├── DialogTitle
├── DialogDescription
├── (your content)
└── DialogClose
```
### Placement Rules
| Component | Placement | Role |
|---|---|---|
| **DialogTrigger** | Anywhere on the page — **not** inside `Dialog`. | Opens the dialog when clicked. Connects via `targetDialogId`. |
| **Dialog** | Separate from the trigger. | Root modal container. Holds all inner components. Connects via `dialogId`. |
| **DialogTitle** | Inside `Dialog`. | Provides accessible naming via `aria-labelledby`. Renders as a heading (`` by default). |
| **DialogDescription** | Inside `Dialog`. | Provides accessible context via `aria-describedby`. Renders as `` by default. |
| **DialogClose** | Inside `Dialog`. | Closes the active dialog when clicked. |
### Connection Rule
DialogTrigger and Dialog connect by ID — they are **never** nested:
- `Dialog` uses `identity.dialogId` to identify itself.
- `DialogTrigger` uses `targeting.targetDialogId` to specify which dialog it opens.
- These values **must match exactly** for the connection to work.
- Multiple triggers can target the same `dialogId`.
- Each dialog on a page must have a unique `dialogId`.
## Quick Start
{`
{#slot default}Subscribe{/slot}
{#slot default}
Stay updated
Get the latest news delivered to your inbox.
Close
{/slot}
`}
The trigger and dialog are siblings — the trigger sits wherever you need it in the page, and the dialog can be authored anywhere. They connect because both reference the same ID (`"newsletter"`).
{`
{#slot default}
Product details
Quick product overview.
Product information goes here.
{#slot default}×{/slot}
{/slot}
`}
Use the `placement` setting to position the dialog anywhere in the viewport. When the trigger slot is empty, `content.label` renders a fallback text button.
---
## Family Components
### Dialog (Root)
The root component holds all modal content and manages dialog behavior: focus trapping, scroll locking, close-on-escape, close-on-outside-click, overlay rendering, and viewport placement. It does not render visible UI itself until opened — only a hidden container. When opened, the runtime physically moves the dialog node into a shared host element at the end of `document.body`.
Unique identifier for this dialog. `DialogTrigger` components use this ID to open the dialog via their `targetDialogId` prop. Must be unique across the page.
Opens the dialog automatically when the runtime initializes. Useful for announcement or onboarding dialogs that should appear on page load.
Whether pressing `Escape` closes the active dialog.
Whether clicking the overlay backdrop closes the active dialog.
Keeps keyboard focus trapped inside the open dialog. Tab and Shift+Tab cycle through focusable elements within the dialog only.
Prevents background page scrolling while the dialog is open.
Returns focus to the element that opened the dialog (typically the trigger) after the dialog closes.
Controls where the dialog surface appears inside the viewport. `center` is the standard modal position. Other values align the dialog to the corresponding edge or corner.
CSS selector targeting a specific element inside the dialog that should receive focus when it opens. When empty, focus moves to the first focusable element in the dialog.
CSS class applied to the dialog surface element.
#### Placement Options
| Placement | Behavior |
|---|---|
| `center` | Centered both horizontally and vertically. Default modal position. |
| `top` | Aligned to the top edge, centered horizontally. |
| `bottom` | Aligned to the bottom edge, centered horizontally. |
| `left` | Aligned to the left edge, centered vertically. |
| `right` | Aligned to the right edge, centered vertically. |
| `bottom-center` | Same as `bottom`. |
| `bottom-left` | Bottom-left corner of the viewport. |
| `bottom-right` | Bottom-right corner of the viewport. |
#### CSS Custom Properties
These properties are available on the dialog surface element (`.ome-dialog-default`) for runtime customization:
| Property | Default | Description |
|---|---|---|
| `--ome-dialog-overlay-color` | `rgba(0,0,0,0.5)` | Background color of the overlay backdrop. |
| `--ome-dialog-offset-x` | `0px` | Horizontal offset from the computed placement position. |
| `--ome-dialog-offset-y` | `0px` | Vertical offset from the computed placement position. |
#### Keyboard Behavior
| Key | Action |
|---|---|
| `Escape` | Closes the dialog (when `closeOnEscape` is `true`). |
| `Tab` | Moves focus to the next focusable element inside the dialog (when `trapFocus` is `true`). |
| `Shift+Tab` | Moves focus to the previous focusable element inside the dialog (when `trapFocus` is `true`). |
#### Accessibility
The root component wires up ARIA attributes automatically:
- The dialog surface gets `role="dialog"` and `aria-modal="true"`.
- `aria-labelledby` is auto-wired to the `DialogTitle` element's generated ID.
- `aria-describedby` is auto-wired to the `DialogDescription` element's generated ID (if present).
- IDs are auto-generated when not explicitly set.
#### Behaviors
- **One dialog at a time.** Only one dialog can be active. Opening a new dialog closes the previous one without animation.
- **DOM teleport.** The dialog node is physically moved into a shared host element at the end of `document.body` while open, then restored to its authored DOM position on close. This ensures the dialog overlays all page content regardless of where it was authored.
---
### DialogTrigger
The interactive element users click to open a dialog. DialogTrigger is **always placed separately from Dialog** — they are siblings in the block tree, not parent and child. They connect via a shared ID: `targeting.targetDialogId` must match the dialog's `identity.dialogId`.
Multiple triggers can target the same dialog. When the trigger slot is empty, `content.label` renders a fallback text button.
ID of the dialog this trigger should open. Must match the `identity.dialogId` of a `Dialog` component on the page.
Fallback trigger label used when the trigger slot is empty. Renders as a plain text button.
Disables the trigger so it cannot open the dialog.
CSS class applied to the trigger button element.
#### Accessibility
- Triggers get `aria-haspopup="dialog"`, `aria-expanded`, and `aria-controls` wired automatically.
- Pressing `Enter` or `Space` on a focused trigger opens the target dialog.
---
### DialogTitle
Provides accessible naming for the dialog. The root `Dialog` auto-wires `aria-labelledby` to this element's ID, so screen readers announce the title when the dialog opens. Must be placed inside the `Dialog` slot.
HTML tag used for the title element. Common values: `"h2"`, `"h3"`, `"h4"`.
CSS class applied to the title element.
---
### DialogDescription
Provides additional context for screen readers. The root `Dialog` auto-wires `aria-describedby` to this element's ID. Must be placed inside the `Dialog` slot.
HTML tag used for the description element.
CSS class applied to the description element.
---
### DialogClose
Button that closes the active dialog. Must be placed inside the `Dialog` slot. You can include any content in its slot — text, icons, or custom markup.
Disables the close button so users cannot click it to dismiss the dialog.
CSS class applied to the close button element.
---
## Common Mistakes
`DialogTrigger` and `Dialog` are **siblings**, not parent and child. The trigger must be placed outside the dialog in the block tree. They connect by matching `targetDialogId` to `dialogId` — nesting breaks the connection and the trigger will not work.
Without matching IDs, the trigger has no way to know which dialog to open. Both `identity.dialogId` on `Dialog` and `targeting.targetDialogId` on `DialogTrigger` must be set to the same value.
Each dialog must have a unique `dialogId`. If two dialogs share the same ID, only the first one registers — the second will never open.
When a dialog opens, its DOM node is physically moved into a shared runtime host at the end of `document.body`. It does not render in-place where you authored it. This ensures the overlay appears above all page content.
---
## FAQs
Can I have multiple triggers for one dialog?
Yes. Any number of `DialogTrigger` components can target the same `dialogId`. Each trigger independently opens the same dialog. This is useful for pages that offer several entry points to the same form or overlay.
Can I have multiple dialogs on one page?
Yes. Give each dialog a unique `dialogId` and have its triggers target that specific ID. Only one dialog can be active at a time — opening a new dialog closes the previous one without animation.
Does DialogTitle have to be inside Dialog?
Yes. `DialogTitle` must be placed inside the `Dialog` slot. The runtime looks for it there to wire up `aria-labelledby`. If placed outside, the dialog will not have an accessible name.
What happens to the DOM when a dialog opens?
The dialog's DOM node is physically moved from its authored position into a shared host element appended to `document.body`. When the dialog closes, the node is moved back to its original position. This teleport ensures the overlay always renders above all other page content.
How do I position the dialog in the viewport?
Use the `settings.placement` prop on `Dialog`. Options are `center` (default), `top`, `bottom`, `left`, `right`, `bottom-center`, `bottom-left`, and `bottom-right`. For fine-tuning, use the CSS custom properties `--ome-dialog-offset-x` and `--me-dialog-offset-y` to shift the dialog from its computed position.
How do I change the overlay backdrop color?
Set the `--ome-dialog-overlay-color` CSS custom property on the dialog surface element (`.ome-dialog-default`). The default is `rgba(0,0,0,0.5)`. For a lighter backdrop: `--ome-dialog-overlay-color: rgba(0,0,0,0.2)`. For a solid backdrop: `--ome-dialog-overlay-color: rgba(0,0,0,0.85)`.
Can I auto-focus a specific element when the dialog opens?
Yes. Set `settings.initialFocusSelector` to a CSS selector matching the element you want focused (e.g. `"#email-input"`). When empty, focus moves to the first focusable element in the dialog.
---
## Drawer
## Overview
Use the Drawer family when you need a panel that slides in from the edge of the viewport — for mobile navigation, filter panels, quick settings, or any overlay content that should feel spatially connected to the screen edge. The family is composed of five components: a root panel, a remote trigger, a title, a description, and a close button. The trigger lives separately from the drawer — they connect by matching IDs, not by DOM nesting.
## Authoring Structure
**Important:** `DrawerTrigger` is always placed separately from `Drawer` — they are siblings, not nested. They connect via matching IDs: `identity.drawerId` on the Drawer must match `targeting.targetDrawerId` on the Trigger.
```
DrawerTrigger (separate, anywhere on page)
Drawer (the sliding panel)
├── DrawerTitle
├── DrawerDescription (optional)
├── (your content)
└── DrawerClose
```
### Placement Rules
| Component | Placement | Role |
|---|---|---|
| **DrawerTrigger** | Separate from `Drawer`. Anywhere on the page. | Button that opens the drawer by targeting its ID. |
| **Drawer** | Top-level. Can be anywhere in the DOM. | The sliding panel surface. Hosts title, description, content, and close. |
| **DrawerTitle** | Inside `Drawer`. | Provides accessible name via `aria-labelledby`. Renders as a heading. |
| **DrawerDescription** | Inside `Drawer`. Optional. | Provides accessible description via `aria-describedby`. |
| **DrawerClose** | Inside `Drawer`. | Button that dismisses the drawer. |
## Quick Start
{`
{#slot default}
Navigation
Home
About
Contact
Close
{/slot}
`}
The trigger and drawer are siblings connected by matching IDs (`mobile-menu`). The trigger can be placed anywhere on the page — it does not need to be near the drawer.
{`
{#slot default}Filters{/slot}
{#slot default}
Filters
Refine your search results.
{#slot default}×{/slot}
{/slot}
`}
Use custom slot content when you need icons, badges, or any markup beyond a plain label in the trigger or close button.
---
## Family Components
### Drawer (Root)
The root component renders the sliding panel surface. It is targeted by one or more `DrawerTrigger` components via a shared ID. When opened, the drawer's DOM node is physically moved into a shared runtime host — it does not render at its authored position. On close, the node is restored to its original location using a Comment anchor.
Unique ID that triggers use to target this drawer. Must match `targetDrawerId` on any trigger that should open it.
Edge the drawer slides from. `"bottom"` creates a bottom sheet with a drag handle. Other directions slide in without a handle.
Opens the drawer automatically when the runtime initializes.
When `true`, clicking the overlay or pressing `Escape` closes the drawer. When `false`, the drawer can only be closed via `DrawerClose`.
CSS class applied to the drawer surface element.
#### Direction Behavior
| Direction | Behavior |
|---|---|
| **`bottom`** | Slides up from the bottom edge. A drag handle element is auto-generated for bottom-sheet interaction. |
| **`right`** | Slides in from the right edge. No handle element. |
| **`top`** | Slides down from the top edge. No handle element. |
| **`left`** | Slides in from the left edge. No handle element. |
#### CSS Custom Properties
| Property | Default | Description |
|---|---|---|
| `--ome-drawer-overlay-color` | `rgba(0, 0, 0, 0.5)` | Background color of the overlay behind the drawer. |
| `--ome-drawer-animation-duration` | `250ms` | Duration of the slide in/out transition. |
#### Key Behaviors
- **One active drawer at a time** — opening a drawer closes any currently open drawer.
- **DOM portaling** — the drawer node is moved into a shared runtime host while open and restored on close.
- **Focus trap** — Tab/Shift+Tab is trapped inside the drawer while open.
- **Focus restoration** — focus returns to the opener element when the drawer closes.
- **Scroll lock** — body scrolling is disabled while the drawer is open, with `scrollbar-gutter: stable` to prevent layout shift.
#### Accessibility
- Drawer receives `role="dialog"` and `aria-modal="true"`.
- `aria-labelledby` is wired to the `DrawerTitle` element's ID.
- `aria-describedby` is wired to the `DrawerDescription` element's ID (if present).
- The drag handle (bottom direction only) gets `aria-hidden="true"`.
- IDs are auto-generated if not explicitly set.
---
### DrawerTrigger
The trigger is a `` that opens a specific drawer by targeting its ID. It is always placed separately from the `Drawer` — they are siblings in the editor, not nested. Multiple triggers can target the same drawer by sharing the same `targetDrawerId`.
ID of the drawer this trigger should open. Must match `identity.drawerId` on the target `Drawer`.
Fallback label text. Used when the trigger slot is empty to render a plain text label inside the button.
Disables the trigger so it cannot open the drawer.
CSS class applied to the trigger button element.
#### Trigger Accessibility
- `aria-haspopup="dialog"` on the trigger button.
- `aria-expanded` reflects whether the targeted drawer is open.
- `aria-controls` points to the drawer element's ID.
- `Enter` and `Space` open the targeted drawer.
---
### DrawerTitle
Provides an accessible name for the drawer via heading semantics. The drawer wires `aria-labelledby` to this element's ID automatically.
HTML tag for the title element. Use an appropriate heading level for your document outline.
CSS class applied to the title element.
---
### DrawerDescription
Provides an accessible description for the drawer. The drawer wires `aria-describedby` to this element's ID automatically. Optional — omit it if the drawer does not need a description.
HTML tag for the description element.
CSS class applied to the description element.
---
### DrawerClose
A `` that closes the active drawer. Place it inside the `Drawer` — typically at the top or bottom of the drawer content.
Disables the close button.
CSS class applied to the close button element.
---
## Keyboard Behavior
| Key | Context | Action |
|---|---|---|
| `Enter` / `Space` | Trigger focused | Opens the targeted drawer. |
| `Escape` | Drawer open | Closes the drawer (only when `dismissible="true"`). |
| `Tab` | Drawer open | Moves focus to the next focusable element inside the drawer (trapped). |
| `Shift` + `Tab` | Drawer open | Moves focus to the previous focusable element inside the drawer (trapped). |
| `Enter` / `Space` | Close button focused | Closes the drawer. |
---
## Common Mistakes
`DrawerTrigger` and `Drawer` must be **siblings**, not nested. The trigger targets the drawer by matching IDs (`targetDrawerId` = `drawerId`), not by DOM relationship. Nesting the trigger inside the drawer breaks the connection.
The trigger-to-drawer connection relies entirely on matching IDs. If `identity.drawerId` on the `Drawer` does not match `targeting.targetDrawerId` on the `DrawerTrigger`, the trigger will not open the drawer.
When a drawer opens, its DOM node is physically moved into a shared runtime host. It does not render where you placed it in the editor. On close, it is restored to its original position.
When `direction="bottom"`, a drag handle element is auto-generated inside the drawer for bottom-sheet interaction. This handle has `aria-hidden="true"` and is not interactive via keyboard — it is a visual and touch affordance only.
---
## FAQs
Can multiple triggers open the same drawer?
Yes. Set the same `targetDrawerId` on all triggers that should open the drawer. Each trigger independently targets the drawer by ID, so any number of triggers can point to the same drawer.
What is the difference between Dialog and Drawer?
Dialog is a centered modal surface with 9 placement options. Drawer slides in from a screen edge with 4 directions (bottom, right, top, left). Both trap focus and share the same one-active-at-a-time constraint — opening a drawer closes any open dialog, and vice versa.
Why does only the bottom direction have a handle?
The handle is a drag affordance specific to bottom-sheet interaction patterns. Users expect to be able to drag a bottom sheet down to dismiss it. Side and top drawers do not use this pattern, so no handle is generated for those directions.
Does the drawer animate?
Yes. The drawer uses a CSS transform transition for the slide-in/out animation. The duration is configurable via the `--ome-drawer-animation-duration` custom property (default: `250ms`).
Can I have a drawer inside a dialog?
Yes, but only one can be active at a time across both families. Opening a drawer will close any currently open dialog, and opening a dialog will close any currently open drawer.
---
## Lightbox
## Overview
Use the Lightbox family when you need an overlay gallery for images or custom HTML content. The root component manages gallery-wide behavior — navigation, animation, and presentation — while each Lightbox Item defines a clickable trigger and the full-size content shown when the overlay opens. Lightbox works well for image galleries, product photo viewers, portfolio showcases, and any content that benefits from a zoomable, swipeable full-screen presentation.
The component uses [PhotoSwipe](https://photoswipe.com/) under the hood and automatically detects image mode versus HTML mode based on what you place in each item's slots. Items within the same root form a gallery, and separate roots can opt into one shared gallery with `identity.groupId`.
## Authoring Structure
```
Lightbox
└── Lightbox Item
├── trigger slot
│ └── preview content (what users click)
├── full slot
│ └── opened content (what the overlay shows)
└── caption slot
└── optional caption shown in the opened overlay
```
### Placement Rules
| Component | Placement | Role |
|---|---|---|
| **Lightbox** | Top-level gallery wrapper. | Owns gallery state, runtime configuration, optional group identity, and PhotoSwipe initialization. |
| **Lightbox Item** | Descendant of `Lightbox`. | Each item becomes one gallery entry. Items are matched by DOM order within the root or grouped roots. |
| **trigger** slot | Inside `Lightbox Item`. | The preview content users click to open the overlay. Can be an image, text, or any markup. |
| **full** slot | Inside `Lightbox Item`. | The content rendered when the lightbox opens. Can be an image, HTML, or any markup. |
| **caption** slot | Inside `Lightbox Item`. | Optional overlay caption for the current item. Supports authored markup such as links. |
## Quick Start
{`
{#slot default}
{#slot trigger}
{/slot}
{#slot full}
{/slot}
{#slot caption}
Gallery image one with project notes.
{/slot}
{/slot}
`}
When both the trigger and full slots contain exactly one `` each, the runtime automatically enters **image mode** — PhotoSwipe handles pinch-to-zoom, swipe gestures, and responsive image sizing natively.
{`
{#slot default}
{#slot trigger}View Details{/slot}
{#slot full}
Product Details
Full product description rendered inside the lightbox overlay.
{/slot}
{/slot}
`}
When the full slot contains anything other than a single image, the runtime enters **HTML mode** — the content is rendered inside a centered, padded container within the overlay.
---
## Family Components
### Lightbox (Root)
The root component wraps all items and manages shared behavior: gallery navigation, animation settings, overlay appearance, and gesture handling. It does not render visible UI itself — only a container element with data attributes that the runtime reads on initialization.
Shared group ID used to make multiple Lightbox roots navigate as one gallery. Empty by default, so each root remains isolated unless you opt in.
Allows gallery navigation to wrap from last to first and first to last. When `false`, navigation stops at the first and last items.
Allows vertical drag gestures (swipe up or down) to close the lightbox overlay where supported.
Enables zooming with the mouse scroll wheel when the lightbox is open.
Opening and closing animation type. `"none"` opens instantly, `"fade"` uses an opacity transition, and `"zoom"` scales from the trigger element.
Show and hide animation duration in milliseconds. Only applies when `showHideAnimationType` is not `"none"`.
Background overlay opacity (0–1) used by the opened lightbox. Clamped to the 0–1 range at runtime.
Gallery item spacing as a ratio, forwarded to PhotoSwipe. Controls the gap between slides during swipe navigation.
Viewport padding in pixels applied around HTML-mode slides. Also sets the `--ome-lightbox-html-padding` CSS custom property.
CSS class applied to the root gallery wrapper element.
#### Grouped Roots
Set the same `identity.groupId` on multiple Lightbox roots when items need to live in separate sections but navigate as one gallery. The runtime collects all valid items from matching roots in document order. Clicking a trigger opens the shared gallery at that global item index.
{`
{#slot default}
{#slot trigger}{/slot}
{#slot full}{/slot}
{/slot}
{#slot default}
{#slot trigger}{/slot}
{#slot full}{/slot}
{/slot}
`}
If grouped roots use different behavior or presentation settings, the root whose trigger is clicked controls the opened PhotoSwipe instance. Keep those settings aligned across grouped roots for predictable navigation and animation.
#### Item Detection and Mode
The runtime automatically detects what mode to use for each Lightbox Item:
- **Image mode** — When both the trigger slot and the full slot each contain exactly one `` element, and the full-slot image has explicit `width` and `height` attributes. PhotoSwipe renders the image natively with pinch-to-zoom and responsive sizing. The trigger image is automatically used as the placeholder thumbnail (`msrc`) during the open animation.
- **HTML mode** — When the full slot contains anything other than a single image (or when the image is missing `width`/`height` attributes). The full slot's inner HTML is wrapped in a centered, scrollable container inside the overlay.
- **Caption slot** — When the optional caption slot contains content, its authored HTML is shown as a caption in the opened PhotoSwipe overlay. The caption source wrapper's classes are copied onto the visible overlay caption. Empty caption slots preserve the default no-caption behavior.
- **Lazy-loaded images** — The runtime resolves lazy-loaded images by checking `data-src`, `data-lazy-src`, `data-srcset`, and `data-lazy-srcset` attributes as fallbacks. `` element source sets are also resolved automatically.
#### Keyboard Behavior
When the lightbox overlay is open:
| Key | Action |
|---|---|
| `ArrowLeft` | Navigate to the previous gallery item. |
| `ArrowRight` | Navigate to the next gallery item. |
| `Escape` | Close the lightbox overlay and return focus to the trigger. |
When `loop` is `true`, navigating past the last item wraps to the first, and vice versa. Arrow keys, Escape, focus trapping, and focus return are always enabled and cannot be disabled.
#### Accessibility
The runtime enforces accessibility automatically:
- Each trigger button has `aria-haspopup="dialog"` and an accessible label derived from `content.triggerLabel`, the trigger's text content, or an inner image's `alt` attribute.
- If no accessible name can be derived, a fallback label of `"Open lightbox item"` is applied.
- Focus is trapped inside the lightbox overlay while open (`trapFocus: true`).
- Focus returns to the triggering element when the overlay closes (`returnFocus: true`).
- Invalid items (missing trigger or full content) are marked with `data-ome-invalid="true"` and their triggers are disabled with `aria-disabled="true"`.
- Caption slot content is shown only after the lightbox opens. Keep essential image meaning available through `alt` text, trigger text, or visible page content for users who cannot open the lightbox.
---
### Lightbox Item
Each `LightboxItem` represents a single gallery entry. It provides three slots — **trigger** (the clickable preview), **full** (the content shown in the overlay), and optional **caption** (caption content shown under the opened item). Items are ordered by DOM position within the root, or across grouped roots when `identity.groupId` is shared.
Accessible label for the trigger button. Also used as fallback visible text when the trigger slot is empty. If omitted and the trigger slot contains content, the label is inferred from the trigger's text or image `alt` attribute.
CSS class applied to the item wrapper element.
CSS class applied to the clickable trigger button.
CSS class applied to the hidden full-content wrapper.
CSS class applied to the hidden caption slot wrapper and copied onto the opened overlay caption.
#### Slot Rules
Every useful `Lightbox Item` needs content in the **full** slot — that is the content the overlay displays. The **trigger** slot can be custom markup (an image, text, icon, etc.) or fallback text from `content.triggerLabel`. The optional **caption** slot accepts authored markup and is rendered only in the opened overlay for that item. Classes on the hidden caption wrapper, including `styling.captionClass`, are copied to the opened overlay caption so each item can control its caption positioning and presentation.
#### Trigger Fallback Rendering
When the trigger slot is empty and `content.triggerLabel` has a value, the item renders the label text as the visible trigger button content:
```
Open image one
```
When the trigger slot has content, the `content.triggerLabel` is used only as the `aria-label` for accessibility.
#### Invalid Item Handling
If an item is missing its trigger or full container, the runtime marks it as invalid:
- `data-ome-invalid="true"` is set on the item element.
- The trigger button is disabled (`disabled` + `aria-disabled="true"`).
- The trigger cursor changes to `not-allowed` via the fixed styling.
- The item is skipped during gallery initialization.
---
## CSS Custom Properties
| Property | Default | Used By | Description |
|---|---|---|---|
| `--ome-lightbox-trigger-gap` | `var(--space-xs, 0.5rem)` | Trigger button children | Controls the gap between inline-flex children inside the trigger button. |
| `--ome-lightbox-html-padding` | `24px` | HTML-mode slides | Viewport padding around HTML-mode slide content. Set from `presentation.htmlViewportPadding`. |
### PhotoSwipe CSS Custom Properties
The following PhotoSwipe variables are set by the runtime and can be overridden in your own CSS:
| Property | Default | Description |
|---|---|---|
| `--pswp-bg` | `#000` | Overlay background color. |
| `--pswp-placeholder-bg` | `#222` | Placeholder background while images load. |
| `--pswp-root-z-index` | `2147483647` | Z-index for the PhotoSwipe root element. |
| `--pswp-icon-color` | `#fff` | Icon (close, arrows, zoom) fill color. |
| `--pswp-icon-color-secondary` | `#4f4f4f` | Secondary icon color. |
| `--pswp-icon-stroke-color` | `#4f4f4f` | Icon stroke color. |
| `--pswp-icon-stroke-width` | `2px` | Icon stroke width. |
| `--pswp-error-text-color` | `var(--pswp-icon-color)` | Error message text color. |
| `--pswp-transition-duration` | _(PhotoSwipe default)_ | Transition duration for UI element fade. |
---
## Common Mistakes
The full slot is the content the overlay displays. If it is empty, the item will be marked as invalid and skipped during gallery initialization. Always add content to the full slot.
When using image mode, the full-slot `` must have explicit `width` and `height` attributes. Without deterministic dimensions, the runtime falls back to HTML mode, which loses PhotoSwipe's native pinch-to-zoom and responsive sizing. A console warning is logged when this fallback occurs.
The trigger and full slots are separate by design. The trigger is what users click to open the lightbox. The full slot is what appears inside the overlay. They are not automatically shared or duplicated.
Extra wrappers between the root and items will still work because the runtime scans descendants with `querySelectorAll`, but the positional index used for gallery navigation is based on DOM order. Keep items close to the root for predictable ordering, or use `identity.groupId` when items need to live in separate Lightbox roots.
The Lightbox family is slot-driven. There is no separate prop for specifying the full-size image URL — place the image in the full slot and the runtime extracts `src`, `srcset`, dimensions, and alt text automatically.
---
## FAQs
Can I group lightbox items across separate sections?
Yes. Set the same `identity.groupId` on each Lightbox root. Empty group IDs preserve the default behavior where each root is its own gallery. Grouped roots navigate in document order across all matching roots.
How does image mode detection work?
The runtime checks if both the trigger slot and the full slot each contain exactly **one** `` element. If they do, and the full-slot image has explicit `width` and `height` attributes, it enters image mode. The full-slot image's `src` (or `data-src` / `data-lazy-src` for lazy-loaded images) becomes the lightbox source, and the trigger image's `src` becomes the placeholder thumbnail during the open animation. If any of these conditions are not met, the item falls back to HTML mode.
Can I mix image items and HTML items in the same gallery?
Yes. Each item is independently detected as image mode or HTML mode. You can have image items alongside HTML items in the same Lightbox root. Arrow key navigation works across all items regardless of mode.
How do I customize the overlay appearance?
Use the `presentation.bgOpacity` prop to change the overlay darkness, and override the PhotoSwipe CSS custom properties (like `--pswp-bg`, `--pswp-icon-color`) in your own stylesheet to change colors, z-index, and other visual aspects. The `presentation.htmlViewportPadding` prop controls the padding around HTML-mode slides.
Does Lightbox support lazy-loaded images?
Yes. The runtime resolves lazy-loaded images by checking `data-src`, `data-lazy-src`, `data-srcset`, and `data-lazy-srcset` attributes as fallbacks. This is compatible with common lazy-loading plugins like WP Rocket and BJ Lazy Load. `` element sources are also resolved automatically.
Can I open the lightbox programmatically?
The lightbox instance is stored on the root element as `element._omeLightbox`. You can use `element._omeLightbox.lightbox.loadAndOpen(index, dataSource)` to open the gallery at a specific item index. The runtime also syncs `data-ome-state` (`"open"` / `"closed"`) and `data-ome-current-index` on the root element for CSS targeting.
What happens if I have only one item?
A single-item gallery works normally — the overlay opens with the item, and navigation arrows are automatically hidden by PhotoSwipe when there is only one slide.
---
## Navigation Menu
## Overview
Use the Navigation Menu family when you need authored navigation items with optional dropdown panels, keyboard navigation, animated viewport transitions, and a mobile drawer helper that automatically derives its structure from the desktop menu. The desktop family is composed of six components that nest together, plus a separate mobile helper and an explicit mobile-only node for complex mega-menu content.
The root component manages open state, keyboard navigation, and optional animated viewport behavior. Navigation Menu Mobile is a **separate** component placed elsewhere on the page — it connects to the desktop menu by a shared `menuId` and builds a drawer-based mobile experience at runtime.
## Authoring Structure
The desktop menu follows a strict nesting hierarchy:
```
Navigation Menu (desktop root)
└── Navigation Menu List
├── Navigation Menu Item
│ ├── plain link
│ ├── OR Navigation Menu Trigger + Navigation Menu Content
│ │ └── optional Navigation Menu Mobile Item subtree inside content
│ └── OR link + Navigation Menu Trigger + Navigation Menu Content
└── Navigation Menu Item ...
Navigation Menu Mobile (separate — anywhere on the page)
```
### Desktop and Mobile Are Separate
Navigation Menu Mobile is **not** nested inside Navigation Menu. It is placed as a sibling element elsewhere on the page (typically inside the header shell alongside the desktop navigation). Both components share the same `menuId` value so the mobile helper can find and mirror the desktop structure at runtime.
In header patterns, the typical structure is:
```
Header Shell
├── Brand
├── Navigation Menu (desktop, menuId="primary-nav")
│ └── Navigation Menu List ...
├── Actions
└── Navigation Menu Mobile (separate, menuId="primary-nav")
```
### Placement Rules
| Component | Placement | Role |
|---|---|---|
| **Navigation Menu** | Top-level wrapper for the desktop navigation. | Owns orientation, open-state coordination, viewport behavior, and the menu identity. |
| **Navigation Menu List** | Direct child of `Navigation Menu`. | Groups authored top-level menu items. The runtime scans for this list when initializing. |
| **Navigation Menu Item** | Direct child of `Navigation Menu List`. | One navigation entry — a plain link, a dropdown parent, or both. |
| **Navigation Menu Trigger** | Inside `Navigation Menu Item`. | Interactive button that opens a dropdown panel. |
| **Navigation Menu Content** | Inside `Navigation Menu Item`, alongside a trigger. | Dropdown or mega-menu panel content. |
| **Navigation Menu Mobile Item** | Inside `Navigation Menu Content`. | Declares an explicit mobile tree for complex mega-menu content. |
| **Navigation Menu Mobile** | **Separate** from the desktop menu — anywhere on the page, connected by `menuId`. | Mirrors the desktop menu into a drawer-based mobile experience at runtime. |
## Quick Start
{`
{#slot default}
{#slot default}
{#slot default}
{#slot default}Products{/slot}
{#slot default}
Shop all products
{/slot}
{/slot}
{#slot default}
About
{/slot}
{/slot}
{/slot}
`}
{`
{#slot default}
{#slot default}
{#slot default}
{#slot default}Services{/slot}
{#slot default}
Design
Development
{/slot}
{/slot}
{/slot}
{/slot}
`}
The mobile helper reads the desktop menu structure at runtime and generates a drawer-based mobile navigation. No duplicate authoring is needed.
---
## Family Components
### Navigation Menu (Root)
The root component wraps all desktop navigation items and manages shared behavior: orientation, keyboard navigation, animated viewport mode, and the menu identity used by the mobile helper. It does not render significant visible UI itself — only a container element and an optional viewport.
HTML tag for the root element. Defaults to `nav` for proper landmark semantics.
Shared menu ID that `Navigation Menu Mobile` uses to find and connect to this desktop menu. Set this to the same value on both components to enable mobile mirroring.
Root orientation. Affects which arrow keys navigate between triggers and the layout direction. Use `vertical` for stacked or sidebar menu structures.
Enables the generated viewport that animates dropdown panel changes. When enabled, content panels are portaled into a viewport container with smooth height transitions and directional motion.
Makes the animated viewport align to a wider container instead of the trigger width. Requires `useAnimatedMenu` to be enabled and a `fullWidthTargetSelector` to be set.
CSS selector used to find the container element whose width the viewport should match. Only visible when `useFullWidth` is enabled. Can be a class selector like `.site-shell`.
CSS class applied to the root element.
CSS class applied to the generated animated viewport container. Only visible when `useAnimatedMenu` is enabled.
Accessible name applied to the `` landmark via `aria-label`. Set this so screen-reader users can distinguish multiple navigation regions on a page (e.g. `"Main"`, `"Footer"`, `"Legal"`).
#### Animated Viewport Mode
When `useAnimatedMenu` is `true`, the root component generates a viewport container that houses all dropdown panels. This enables:
- Smooth height transitions as panels open and close.
- Directional motion animations when switching between panels (content slides in from the direction of the newly focused trigger).
- Full-width mode that aligns the viewport to a wider parent container for mega-menu layouts.
Animated mode only activates for **horizontal** orientation and is automatically disabled inside the Etch builder (where it falls back to a non-animated preview).
#### Keyboard Behavior
When a trigger has focus in a **horizontal** menu:
| Key | Action |
|---|---|
| `Enter` / `Space` | Toggle the associated panel. |
| `ArrowRight` | Move focus to the next trigger. |
| `ArrowLeft` | Move focus to the previous trigger. |
| `ArrowDown` | Open the dropdown panel. |
| `Home` | Move focus to the first trigger. |
| `End` | Move focus to the last trigger. |
| `Escape` | Close the open panel and return focus to its trigger. |
In a **vertical** menu, `ArrowDown` / `ArrowUp` navigate between triggers and `ArrowRight` opens the panel.
Navigation wraps by default — pressing `ArrowRight` on the last trigger focuses the first, and vice versa.
By default the menu uses **roving tabindex**: exactly one top-level trigger is in the Tab order at a time (the others get `tabindex="-1"`), so a keyboard user Tabs into the menu once and then uses the arrow keys to move between triggers. Inside an open panel, Tab moves naturally through the panel's links (disclosure pattern — the panel is not a focus trap). To restore the legacy behavior where every trigger is individually Tab-reachable, see [Backward compatibility filters](#backward-compatibility-filters) below.
#### Accessibility
The navigation uses the **disclosure pattern**: each trigger is a button that shows/hides a panel of regular links. This is the recommended pattern for website navigation (as opposed to the application-style "menubar" pattern, which requires arrow-key navigation inside the panel and forbids Tab between items).
The runtime wires up ARIA attributes automatically:
- The root `` landmark has an `aria-label` (default `"Main"`, configurable via `accessibility.navAriaLabel`) so multiple nav regions can be distinguished.
- Each trigger has `aria-expanded` and `aria-controls` pointing at its sibling content panel's `id`. The trigger intentionally omits `aria-haspopup` — the disclosure panel has no `role="menu"`, and per the ARIA spec every `aria-haspopup` token (including `true`) would falsely declare a popup type the panel doesn't provide. If you don't set a `contentId` on the trigger/content pair, the runtime assigns a stable id automatically.
- Each content panel syncs `aria-hidden` with its open state. Panels do **not** carry `role="menu"` (disclosure pattern) — they are plain containers, and dropdown links are plain `` elements you can Tab through naturally.
- `data-ome-state` attributes (`open` / `closed`) are set on items, triggers, and content for CSS targeting.
When a panel opens, focus moves to the first link inside it; pressing `Escape` (or clicking outside the nav) closes the panel and returns focus to its trigger. Open/close state changes are announced to screen readers via an `aria-live` region. Background content is **not** inerted for the desktop menu (it's a disclosure, not a modal).
---
### Navigation Menu List
The list container groups top-level menu items. The runtime scans for the direct `Navigation Menu List` child when initializing the root component.
CSS class applied to the list element.
The list always renders as a `` element with `display: flex` and reset list styles. In horizontal mode the flex direction is `row`; in vertical mode it becomes `column`.
---
### Navigation Menu Item
Each `NavigationMenuItem` represents one navigation entry. It can contain a plain link, a trigger-plus-content dropdown pair, or a combination of both (a link that also opens a dropdown).
Disables this item and any trigger it contains. Disabled items cannot be opened or focused for activation.
CSS class applied to the item element.
The item always renders as an `` element. The runtime tracks open/closed state via `data-ome-state` on the item.
---
### Navigation Menu Trigger
The interactive button users click or hover to open a dropdown panel. The trigger always renders as a `` element and can optionally display a built-in chevron icon.
When set, emitted as `aria-controls` on the trigger so it points at its content panel. Must match `identity.contentId` on the paired `Navigation Menu Content`. If left empty, the runtime assigns an `id` to the content and an `aria-controls` to the trigger automatically — so you only need to set this if you want predictable, stable ids (e.g. for deep-linking or custom JS).
Prevents this trigger from opening its content panel. Overrides the item-level disabled prop.
Shows a built-in chevron icon inside the trigger button. The chevron rotates 180 degrees when the panel is open.
Preferred interaction mode. `hover` opens the panel on mouse enter with a small delay; `click` requires an explicit click. Inside the Etch builder, all triggers behave as click for reliable editing.
CSS class applied to the trigger button.
#### Trigger Interaction Modes
- **`hover`** — The panel opens when the cursor enters the trigger area (with a 50ms delay) and closes when the cursor leaves the entire navigation boundary (trigger + content + viewport). This is the default and provides the smoothest desktop experience.
- **`click`** — The panel only opens on explicit click. A document-level click listener closes the panel when clicking outside the navigation root.
Both modes support keyboard activation via `Enter` / `Space`.
---
### Navigation Menu Content
The dropdown or mega-menu panel paired with a trigger. Content panels are hidden by default and become visible when their sibling trigger opens them.
When set, emitted as the panel's `id` so the paired trigger's `aria-controls` can point at it. Must match `identity.contentId` on the paired `Navigation Menu Trigger`. If left empty, the runtime assigns an `id` automatically.
CSS class applied to the content panel.
#### Runtime Behavior
- In non-animated mode, content is positioned absolutely below its trigger item (or to the right in vertical orientation).
- In animated mode, content is portaled into the shared viewport container and animated with presence state transitions.
- Content panels sync `aria-hidden` and `data-ome-state` between `open` and `closed`. They do not carry a `role` (disclosure pattern — dropdown links are plain `` elements).
- The `hidden` attribute is toggled to control visibility.
---
### Navigation Menu Mobile
A separate component that mirrors the desktop navigation into a drawer-based mobile experience. It is **not** nested inside `Navigation Menu` — it is placed elsewhere on the page and connects to the desktop menu via a shared `menuId`.
At runtime, the mobile helper:
1. Finds the desktop `Navigation Menu` root by matching `menuId`.
2. Extracts the menu structure recursively (or reads explicit `Navigation Menu Mobile Item` nodes if present).
3. Generates a panel-based mobile drawer with sliding navigation and a back button.
In the Etch builder, the helper shows a static preview instead of live-extracted mobile navigation.
Must match `Navigation Menu.identity.menuId`. The mobile helper uses this value to find the desktop menu and wire its internal drawer.
Direction the mobile drawer slides from.
Allows overlay click and `Escape` to close the mobile drawer.
When enabled, the trigger displays visible label text. When disabled, only a hamburger icon is shown with a separate `triggerAriaLabel` for screen readers.
Visible label text and accessible name for the drawer trigger. Only shown when `showTriggerLabel` is `true`.
Screen-reader-only label for the trigger button when `showTriggerLabel` is `false`.
Fallback label used by the back button when the `backButton` slot is empty.
CSS class applied to the mobile helper wrapper.
CSS class applied to the drawer trigger button.
CSS class applied to the back button.
CSS class applied to the icon-only close button.
CSS class applied to the internal drawer root.
CSS class applied to the drawer header row.
CSS class applied to the drawer content wrapper.
CSS class applied to generated root and child lists.
CSS class applied to generated list items.
CSS class applied to generated links.
CSS class applied to generated submenu trigger buttons.
CSS class applied to the chevron icon shown on generated submenu triggers.
CSS class applied to the wrapper around the `before` slot.
CSS class applied to the wrapper around the `after` slot.
#### Slots
| Slot | Description |
|---|---|
| `before` | Renders before generated items in the root panel only. |
| `after` | Renders after generated items in the root panel only. |
| `backButton` | Replaces the default back button content. If omitted, the button falls back to a back icon plus `backButtonLabel`. |
#### Mobile Keyboard Behavior
Inside the mobile drawer, when a menu item has focus:
| Key | Action |
|---|---|
| `ArrowDown` | Move focus to the next menu item. |
| `ArrowUp` | Move focus to the previous menu item. |
| `Home` | Move focus to the first menu item. |
| `End` | Move focus to the last menu item. |
| `Enter` / `Space` | Activate the focused item (follow link or open submenu). |
| `ArrowRight` | Open a submenu (when focused on a submenu trigger). |
| `Escape` / `ArrowLeft` | Go back to the previous panel. |
#### How Content Extraction Works
The mobile helper extracts the navigation tree from the desktop menu in one of two ways:
1. **Explicit mobile items** — If a `Navigation Menu Content` subtree contains at least one `Navigation Menu Mobile Item`, the helper uses only those explicit nodes for that panel and ignores regular auto-generated links.
2. **Automatic extraction** — If no explicit mobile items exist, the helper recursively extracts the authored structure: links become mobile links, items with triggers become submenu branches, and nested navigation roots are traversed.
---
### Navigation Menu Mobile Item
An explicit mobile-only node authored inside `Navigation Menu Content` when complex mega-menu content needs a custom mobile tree that differs from the auto-extracted structure. If a content panel contains at least one `Navigation Menu Mobile Item`, the mobile helper uses only those explicit nodes.
HTML tag for the authored wrapper element. Common values are `div`, `ul`, `li`, or `a` depending on the structural role.
Mobile node mode. `trigger` creates a submenu branch that navigates to a child panel. `link` creates a direct navigation link.
Label shown in the generated mobile drawer UI for this node.
Destination URL. Required when `useAs` is `link`. Ignored for `trigger` nodes.
Optional CSS class list for the authored wrapper element.
#### When to Use Mobile Items
Use `Navigation Menu Mobile Item` when your desktop mega-menu has complex content (cards, images, multi-column layouts) that should not be naively extracted into the mobile drawer. By wrapping mobile-relevant content in explicit mobile items, you control exactly what appears in the mobile navigation while keeping the desktop layout free to include richer visual content.
---
## Common Mistakes
Do not place `Navigation Menu Item` blocks directly inside `Navigation Menu`. The runtime scans for a direct `Navigation Menu List` child at initialization. Always nest items inside a list.
`Navigation Menu Mobile` is a **separate** component. It must not be placed inside the desktop `Navigation Menu`. Place it elsewhere on the page and connect it via `menuId`.
If an item has `Navigation Menu Content`, it must also have a sibling `Navigation Menu Trigger`. Content without a trigger will not be openable.
The `menuId` on `Navigation Menu Mobile.identity.menuId` must exactly match `Navigation Menu.identity.menuId`. If the IDs do not match, the mobile helper will not find the desktop menu and the drawer will be empty.
Do not author a separate second menu tree for mobile. `Navigation Menu Mobile` derives its structure from the desktop menu automatically. Only use `Navigation Menu Mobile Item` when you need to customize the mobile tree for complex content.
---
## FAQs
Can I use Navigation Menu without the mobile helper?
Yes. `Navigation Menu Mobile` is entirely optional. The desktop navigation family works standalone. Only add the mobile helper when you need a drawer-based mobile experience that mirrors the desktop menu.
How does the animated viewport work?
When `useAnimatedMenu` is enabled on the root component, dropdown content panels are portaled into a shared viewport container. The viewport smoothly transitions its height when panels open and close, and content panels animate with directional motion (slide in from the direction of the newly focused trigger). For full-width mega-menus, enable `useFullWidth` and set `fullWidthTargetSelector` to the container the viewport should align to.
What happens when both a link and a trigger are in the same item?
The item renders as a "link-branch" — the link is clickable for navigation and the trigger opens a dropdown. In the mobile drawer, this becomes a row with both a tappable link and a submenu chevron button.
Can I nest navigation menus?
Yes. You can place a `Navigation Menu` inside a `Navigation Menu Content` panel for multi-level navigation. Nested menus manage their own state independently. The animated viewport is automatically disabled for nested menus to avoid conflicts.
How do I customize the mobile drawer trigger?
Use `showTriggerLabel` to toggle between a labeled trigger and an icon-only trigger. When `showTriggerLabel` is `false`, set `triggerAriaLabel` for screen reader accessibility. Style the trigger using `controlStyling.triggerClass`. For the hamburger icon itself, the component renders a built-in SVG.
When should I use Navigation Menu Mobile Item?
Use it when your desktop mega-menu has complex visual content (cards, multi-column layouts, featured sections) that should not be auto-extracted into the mobile drawer. By wrapping mobile-relevant content in explicit `Navigation Menu Mobile Item` nodes, you control exactly what appears in the mobile navigation. Simple dropdown menus do not need explicit mobile items — the auto-extraction handles them well.
---
## Backward compatibility filters
The accessibility improvements (roving tabindex, focus moving into the open panel, screen-reader announcements, inert drawer backgrounds) are **on by default**. If a site depends on the previous keyboard or focus behavior — for example a custom `:focus-within` CSS rule or JS that walks every trigger via Tab — you can opt out with WordPress filters in your theme's `functions.php`:
```php
// Global kill-switch: restore ALL legacy accessibility behavior.
add_filter( 'ome_a11y_use_legacy_behavior', '__return_true' );
// Or restore just one feature:
add_filter( 'ome_a11y_roving_tabindex', '__return_false' ); // every trigger Tab-reachable again
add_filter( 'ome_a11y_focus_into_overlay', '__return_false' ); // focus stays on the trigger when a panel opens
add_filter( 'ome_a11y_inert_background', '__return_false' ); // mobile drawer background stays interactive
```
These filters are part of the released public API and covered by the plugin's backward-compatibility guarantees. The ARIA attribute additions (`aria-controls`, `aria-label` on the landmark, content panel ids) are always on regardless of the filters — they're additive and don't change keyboard/focus behavior.
---
## Table of Contents
## Overview
The Table of Contents component automatically discovers headings in your page content, generates a clickable nested list of anchor links, and highlights the currently visible heading as the user scrolls. It requires no manual link management — drop the component on the page, configure which heading levels to include, and it builds itself at runtime.
The component is a single self-contained element (`OmeTableOfContents`). It is not a family — there are no child blocks to compose. All behavior is controlled through props on the root.
## How It Works
1. **Template phase** — The PHP builder renders a hidden template (``) containing a ``, ``, and `` skeleton. These are cloned at runtime to build the live list.
2. **Target discovery** — The runtime reads `targetSelector` to find the content container. If empty or invalid, it falls back to `main`, `article`, `[role='main']`, `.entry-content`, `.wp-block-post-content`, then `body`. The TOC root itself is always excluded from heading scanning.
3. **Heading extraction** — Headings from H2 through the configured depth are collected. Existing IDs are preserved; headings without IDs receive auto-generated slugs. Duplicate slugs are de-duplicated with numeric suffixes (e.g. `repeated-heading-2`).
4. **Tree building** — Headings are organized into a nested ``/`` tree that mirrors the heading hierarchy.
5. **Active tracking** — An `IntersectionObserver` watches all collected headings. As the user scrolls, the first visible heading's corresponding link receives `aria-current="location"`, and the item gets `data-ome-active`. The root H2 branch item receives `data-ome-active-branch`.
6. **Mutation watching** — A `MutationObserver` watches the target container. If headings are added or removed after load, the TOC automatically rebuilds itself after a short debounce.
## Quick Start
{` `}
This produces a `` that scans the page for H2–H3 headings, shows an "On this page" label, and highlights the active heading on scroll.
{` `}
---
## Props
### Structure
HTML tag used for the root element. Change to `"div"` if you need a generic container, but `"nav"` is recommended for accessibility since the TOC is a navigation landmark.
### Content
Shows a label above the generated table of contents. When `false`, no label text is rendered and the list starts immediately.
Text shown as the table of contents label. When mobile accordion is enabled, this same text is used as the disclosure button label.
### Settings
Includes H2 through the selected heading level. H1 is always skipped. `"3"` captures H2 and H3 — the most common range for blog posts and documentation. Use `"2"` for a flat H2-only list, or `"4"`–`"6"` for deeply structured content.
Pixel offset applied to target headings through `scroll-margin-top`. Set this to match your sticky header height so headings land below the header when scrolled to.
### Targeting
CSS selector for the content container to scan for headings. When empty, the runtime falls back to `main`, `article`, `[role='main']`, `.entry-content`, `.wp-block-post-content`, then `body` — whichever it finds first that is not inside the TOC root itself. Set this when your content lives in a specific container and you want to exclude headings from sidebars, headers, or footers.
### Behavior
Controls nested branch visibility. `"expanded"` shows all heading levels at all times. `"active-branch"` reveals nested links only under the currently active H2 branch — all other sub-lists are hidden. Use `"active-branch"` for long pages with many headings to reduce visual noise.
### Mobile
Turns the label into a disclosure button below the configured breakpoint. The TOC list collapses into an accordion panel that users can expand and collapse.
Viewport width in pixels where mobile accordion mode starts. Below this width, the label is replaced with a toggle button and the panel collapses.
Initial mobile accordion state when the page loads below the breakpoint. `"collapsed"` hides the list until the user taps the button. `"expanded"` shows it immediately.
### Styling
CSS class applied to the TOC root element.
CSS class applied to the label element.
CSS class applied to all generated `` branch lists.
CSS class applied to all generated `` items.
### Mobile Styling
CSS class applied to the mobile disclosure button (visible only when mobile accordion is enabled and viewport is below the breakpoint).
CSS class applied to the mobile disclosure panel that wraps the TOC list in mobile mode.
CSS class applied to the chevron SVG icon inside the mobile disclosure button. The chevron rotates 180 degrees when expanded.
### Advanced Styles
Reveals H2–H6 level-specific class controls up to the configured depth. When enabled, you can style each heading level's branches and items independently.
When Advanced Styles is enabled, the following per-level props become available for each heading level up to the configured depth:
| Level | Branch CSS Class | Item CSS Class |
|---|---|---|
| H2 | `ome-toc-h2-branch-default` | `ome-toc-h2-item-default` |
| H3 | `ome-toc-h3-branch-default` | `ome-toc-h3-item-default` |
| H4 | `ome-toc-h4-branch-default` | `ome-toc-h4-item-default` |
| H5 | `ome-toc-h5-branch-default` | `ome-toc-h5-item-default` |
| H6 | `ome-toc-h6-branch-default` | `ome-toc-h6-item-default` |
Each level-specific class sets a `--ome-toc-level` custom property on the element, useful for writing level-aware CSS.
---
## Active State Attributes
The runtime uses **data attributes** (not classes) to mark active state. Target these in your CSS:
| Attribute | Applied to | When |
|---|---|---|
| `data-ome-active` | `` | The currently active heading's list item. |
| `data-ome-active-branch` | `` | The root H2 branch item containing the active heading (only one at a time). |
| `aria-current="location"` | `` | The link pointing to the currently active heading. |
### CSS Example
```css
/* Style the active link */
[data-ome-toc-item][data-ome-active] > a {
color: var(--primary, #2563eb);
font-weight: 700;
}
/* Dim inactive branches in active-branch mode */
[data-ome-toc-item]:not([data-ome-active-branch]) {
opacity: 0.5;
}
```
---
## Mobile Accordion
When `mobile.enabled` is `true`, the component transforms below the breakpoint:
- The static label is replaced with a `` that toggles the TOC list.
- The button includes a chevron icon that rotates when expanded.
- The panel is hidden/shown via the `hidden` attribute.
- ARIA attributes (`aria-expanded`, `aria-controls`) are managed automatically.
- When the viewport crosses back above the breakpoint, the button is removed and the static label is restored.
---
## Heading Discovery Details
### Slug Generation
Headings without an existing `id` attribute receive an auto-generated slug:
1. Text is trimmed, lowercased, and Unicode-normalized (NFKD).
2. Diacritics are stripped.
3. Quotes and apostrophes are removed.
4. Non-alphanumeric characters are replaced with hyphens.
5. Leading/trailing hyphens are removed.
6. If the result is empty, the fallback slug `"section"` is used.
Duplicate IDs are resolved by appending a numeric suffix: `heading`, `heading-2`, `heading-3`, etc. Existing IDs on headings are always preserved.
### Content Container Fallbacks
When `targetSelector` is empty or does not match a valid element outside the TOC root, the runtime tries these selectors in order:
1. `main`
2. `article`
3. `[role='main']`
4. `.entry-content`
5. `.wp-block-post-content`
6. `body`
The first element found that is **not inside** the TOC root is used as the heading source.
---
## Common Mistakes
If the TOC root is inside the element it targets for headings, the runtime skips it correctly — but the `targetSelector` must resolve to an element outside the TOC root. If your selector accidentally targets the TOC itself, no headings will be found and the component hides itself. Use a specific content selector (like `article.post-content`) when the TOC is nested inside a shared layout.
Active state is communicated through `data-ome-active`, `data-ome-active-branch`, and `aria-current="location"` — not CSS classes. Do not write selectors like `.is-active` or `.active-link`. Use `[data-ome-active] > a` in your CSS instead.
H1 is always excluded. The minimum heading level is H2. Setting `depth` to `"2"` produces a flat list of H2 headings only — no nesting.
If your site has a sticky header, headings will scroll behind it when the user clicks a TOC link. Set `offset` to your header height (e.g. `"96"`) so `scroll-margin-top` pushes the heading below the header.
---
## FAQs
What happens when there are no headings?
The TOC root is hidden (`hidden` attribute) and no links are rendered. It becomes completely invisible — no empty container or label is shown. If headings are later added via JavaScript (e.g. dynamic content), the MutationObserver triggers a rebuild and the TOC reappears automatically.
Can I have multiple TOC components on the same page?
Yes. Each TOC instance manages its own heading collection, active tracking, and mobile accordion independently. Use `targetSelector` on each instance to point to different content containers so they don't scan each other's headings.
How does the component handle duplicate heading text?
Headings with identical text receive unique auto-generated IDs: the first gets `some-heading`, the second `some-heading-2`, and so on. Headings that already have an `id` attribute keep that ID unchanged — even if it duplicates another heading's slug.
Does the TOC update when content changes dynamically?
Yes. A `MutationObserver` watches the target container's subtree. When headings are added or removed, the TOC rebuilds itself after a 50ms debounce. The IntersectionObserver for active tracking is also re-created during the rebuild.
How do I style each heading level differently?
Enable **Advanced Styles** (`advanced_styles.enabled = true`), then set per-level branch and item classes. Each level's default class sets `--ome-toc-level` on the element. You can use this custom property to write level-aware CSS:
```css
[data-ome-toc-item] {
padding-inline-start: calc((var(--ome-toc-level, 2) - 2) * 1rem);
}
```
Can I use the TOC without the label?
Yes. Set `content.showLabel` to `false`. The list renders without any label text. If mobile accordion is enabled, the disclosure button uses the `aria-label` on the root nav element instead.
---
## Tabs
## Overview
Use the Tabs family when you need a tabbed interface where one content panel is visible at a time, selected by clicking its corresponding trigger. The family is composed, not standalone — the root component manages shared state and keyboard navigation, while child components define the trigger list and content panels. Tabs work well for product feature sections, settings panels, pricing tiers, and any content that benefits from organizing information into mutually exclusive views.
## Authoring Structure
```
Tabs
├── TabsList
│ ├── TabsTrigger (1st)
│ ├── TabsTrigger (2nd)
│ └── TabsTrigger (3rd)
├── TabsContent (1st)
├── TabsContent (2nd)
└── TabsContent (3rd)
```
### Placement Rules
| Component | Placement | Role |
|---|---|---|
| **Tabs** | Top-level wrapper. | Owns state, keyboard navigation, and shared options. |
| **TabsList** | Direct child of `Tabs`. | Container for trigger buttons. Receives `role="tablist"`. |
| **TabsTrigger** | Inside `TabsList`. | Interactive button that activates its paired content panel. |
| **TabsContent** | Direct child of `Tabs`, sibling to `TabsList`. | The content panel that shows or hides based on the active trigger. |
### Pairing Rule
Triggers and content panels are paired by **position** — the first `TabsTrigger` inside `TabsList` pairs with the first `TabsContent` that is a direct child of `Tabs`. The second pairs with the second, and so on. This is purely positional; labels and IDs are not used for matching. If trigger and content counts mismatch, extra triggers are disabled and extra content panels stay hidden.
## Quick Start
{`
{#slot default}
{#slot default}
{/slot}
{#slot default}Overview content goes here.{/slot}
{#slot default}Details content goes here.{/slot}
{#slot default}Changelog content goes here.{/slot}
{/slot}
`}
{`
{#slot default}
{#slot default}
{#slot default}Features{/slot}
{#slot default}Pricing{/slot}
{#slot default}FAQ{/slot}
{/slot}
{#slot default}Features content.{/slot}
{#slot default}Pricing content.{/slot}
{#slot default}FAQ content.{/slot}
{/slot}
`}
---
## Family Components
### Tabs (Root)
The root component wraps all lists and panels, and manages shared behavior: active tab state, keyboard navigation, orientation, and optional responsive accordion mode. It does not render any visible UI itself — only a container element.
HTML tag for the root element.
Controls layout direction and keyboard behavior. `"horizontal"` uses ArrowLeft/ArrowRight for navigation. `"vertical"` uses ArrowUp/ArrowDown.
Zero-based index of the tab that should be active on initial load. If the index is invalid or points to a disabled trigger, it falls back to the first enabled trigger.
Disables the entire tabs interface when `true`. Individual triggers can still override this with their own `disabled` prop.
CSS class applied to the root element.
Enables responsive accordion mode. When the viewport width is below `accordionBreakpoint`, the runtime restructures the tabs into an accordion.
Viewport width in pixels below which accordion mode activates. Only applies when `enableResponsiveAccordion` is `true`.
Controls Etch editor preview behavior. `"auto"` follows the canvas width. `"tabs"` always shows tabs. `"accordion"` always shows the accordion. Only applies when responsive accordion is enabled.
Animation duration in milliseconds for accordion panel expand/collapse. Only applies when responsive accordion is enabled.
Adds indicator spans to triggers in accordion mode. Only applies when responsive accordion is enabled.
CSS class applied to each generated accordion item wrapper. Only applies when responsive accordion is enabled.
CSS class applied to each generated accordion header wrapper. Only applies when responsive accordion is enabled.
CSS class applied to generated accordion indicators. Only applies when `showAccordionIndicator` is `true`.
#### Keyboard Behavior — Tabs Mode
When a trigger has focus in tabs mode:
| Key | Action |
|---|---|
| `Enter` / `Space` | Activate the focused trigger. |
| `ArrowRight` | Move focus to the next trigger and activate it (horizontal). Wraps to first. RTL-aware. |
| `ArrowLeft` | Move focus to the previous trigger and activate it (horizontal). Wraps to last. RTL-aware. |
| `ArrowDown` | Move focus to the next trigger and activate it (vertical). Wraps to first. |
| `ArrowUp` | Move focus to the previous trigger and activate it (vertical). Wraps to last. |
| `Home` | Focus and activate the first enabled trigger. |
| `End` | Focus and activate the last enabled trigger. |
In horizontal tabs, arrow keys automatically reverse in RTL layouts.
#### Keyboard Behavior — Accordion Mode
When the responsive accordion is active, keyboard behavior changes to match the Accordion component:
| Key | Action |
|---|---|
| `Enter` / `Space` | Toggle the associated panel. |
| `ArrowDown` | Move focus to the next trigger (does **not** activate). |
| `ArrowUp` | Move focus to the previous trigger (does **not** activate). |
| `Home` | Move focus to the first trigger (does **not** activate). |
| `End` | Move focus to the last trigger (does **not** activate). |
Focus movement in accordion mode does **not** auto-activate — you must click or press `Enter`/`Space` to open a panel.
#### Responsive Accordion
When enabled and the viewport drops below `accordionBreakpoint`, the runtime:
1. Creates an accordion list element.
2. Moves each trigger-content pair into accordion item wrappers.
3. Replaces original positions with comment placeholders.
4. Changes ARIA roles (`tab` → `button`, `tabpanel` → `region`).
5. Adds indicators if `showAccordionIndicator` is `true`.
When the viewport exceeds the breakpoint, everything is restored to the original tabs DOM.
#### Accessibility
The root component generates unique IDs for each trigger-content pair and wires up ARIA attributes automatically:
- **TabsList**: `role="tablist"`, `aria-orientation` synced to the `orientation` setting by the runtime.
- **TabsTrigger**: `role="tab"`, `aria-selected`, `aria-controls` pointing to its content panel, `tabIndex` (`0` when active, `-1` when inactive).
- **TabsContent**: `role="tabpanel"`, `aria-labelledby` pointing to its trigger, `tabIndex="0"`.
- **Disabled triggers**: `aria-disabled="true"`, `tabIndex="-1"`.
- In accordion mode, triggers use `role="button"` and `aria-expanded`; content panels use `role="region"`.
---
### TabsList
The `TabsList` is the container for all `TabsTrigger` elements. It receives `role="tablist"` and manages focus roving for its child triggers. Place it as a direct child of the root `Tabs` component.
CSS class applied to the list element.
---
### TabsTrigger
The interactive button that activates its paired content panel. When the slot is empty, the trigger renders its `content.label` value as text. Triggers are paired with content panels by position — the first trigger in `TabsList` activates the first `TabsContent` child of `Tabs`.
Disables this trigger independently of the root `disabled` setting. A disabled trigger cannot receive focus or become active, and receives `aria-disabled="true"`.
Fallback label text. Used when the trigger slot is empty.
CSS class applied to the trigger element.
#### Trigger Slot Content
When the trigger slot is populated, the slot content replaces the fallback label. Use this for rich trigger content — icons, badges, or any markup beyond plain text:
```
{#slot default}
⚙ Settings
{/slot}
```
---
### TabsContent
The content panel that shows or hides based on the active trigger. Only one panel is visible at a time — Tabs always keeps exactly one panel active. Place content panels as direct children of the root `Tabs` component, as siblings to `TabsList`.
CSS class applied to the content panel.
---
## CSS Custom Properties
The default tab styles reference these CSS custom properties. Override them to customize appearance without replacing the default classes:
| Variable | Used For | Fallback |
|---|---|---|
| `--space-s` | Gap between list and content panels. | `1rem` |
| `--btn-padding-block` | Trigger padding (block axis). | — |
| `--btn-padding-inline` | Trigger padding (inline axis). | — |
| `--border-color-dark` | Inactive trigger border color. | — |
| `--text-dark-muted` | Inactive trigger text color. | — |
| `--primary` | Active trigger border color. | — |
| `--heading-color` | Active trigger text color. | — |
| `--ome-tabs-accordion-animation-duration` | Accordion animation duration (set inline from the `accordionAnimationDuration` prop). | — |
---
## Pattern Examples
### Vertical Tabbed Timeline
Used by the **Testimonial8** pattern — a vertical tabbed timeline with custom styled trigger cards:
- `orientation="vertical"`
- 4 triggers (Discovery, Onboarding, Building, Scaling) inside custom styled cards
- 4 content panels with testimonials
- Two-column grid layout (`0.35fr / 0.65fr`)
### Vertical Tabbed Features with Images
Used by the **FeatureSection20** pattern — vertical tabs with image content panels:
- `orientation="vertical"`
- 4 triggers as feature cards with icons
- 4 content panels showing images
- Two-column grid layout (`0.45fr / 0.55fr`)
Both patterns use vertical orientation and custom styling classes to override the default trigger appearance.
---
## Common Mistakes
`TabsContent` panels must be **direct children of the root `Tabs` component**, not inside `TabsList`. The runtime pairs triggers and content by scanning `TabsList` children for triggers and `Tabs` children (excluding `TabsList`) for content panels. Placing content inside `TabsList` breaks pairing.
If you have more triggers than content panels, the extra triggers are disabled. If you have more content panels than triggers, the extra panels stay hidden. Always ensure the counts match.
In tabs mode, arrow keys move focus **and** activate the tab. In accordion mode (when responsive accordion is active), arrow keys only move focus — you must click or press `Enter`/`Space` to open a panel.
Triggers and content panels are paired by **position only**. The second `TabsTrigger` always pairs with the second `TabsContent`, regardless of labels or any other attribute. Reordering one without the other breaks the pairing.
---
## FAQs
Can I have nested tabs?
Yes. You can place a `Tabs` component inside a `TabsContent` panel. Each nested tabs instance manages its own state independently. Be mindful of the visual complexity — deeply nested tabs can be difficult to navigate.
How does the responsive accordion work?
When `enableResponsiveAccordion` is `true` and the viewport drops below `accordionBreakpoint`, the runtime restructures the DOM into accordion items. Triggers become accordion headers with `role="button"` and `aria-expanded`, and content panels become regions. When the viewport exceeds the breakpoint, the original tabs DOM is restored. The transition is seamless — no page reload required.
What if I need all panels collapsed?
Tabs always keeps exactly one panel active. If you need the ability to collapse all panels, use the Accordion component with `type="single"` instead.
Can I change the default active tab?
Yes. Use the `defaultIndex` setting on the root `Tabs` component. It is zero-based — `"0"` activates the first tab, `"1"` the second, and so on. If the index is invalid or points to a disabled trigger, it falls back to the first enabled trigger.
How do vertical tabs work with keyboard navigation?
In vertical orientation, `ArrowUp` and `ArrowDown` navigate between triggers instead of `ArrowLeft` and `ArrowRight`. `Home` and `End` still jump to the first and last enabled triggers. The arrow keys auto-activate the focused tab, same as horizontal mode.
---
## Facet Overview
# Facet Overview
Facets are controls that update one or more `Facet Target` result containers. A facet does not own the results. It sends a value for a shared target ID, the backend re-renders that target's stored Etch loop template, and the runtime swaps the returned markup into the target.
The basic structure is:
```text
Search Facet, Select Facet, Radio List Facet, Checkbox List Facet, Map Address Facet, Map Radius Facet, Map Facet, Pagination Facet, Load More Facet, Reset Facet
|
| shared target ID
v
Facet Target
|
v
Etch loop slot + fallback slot
```
One target can be controlled by many facets. The E2E scenarios combine `post_type`, `category_name`, `tag`, meta queries, date queries, ACF relationship filters, pagination, reset, load more, and map bounds against the same target. The combined result is an intersection unless a specific mode documents a different behavior.
## What Authors Configure
Every useful facet setup needs three decisions:
| Decision | Where it lives | What it controls |
| --------------- | ------------------------------------------------------------------ | ---------------------------------------------- |
| Target binding | Facet `target` and Facet Target `target` | Which result container receives updates. |
| Argument mode | Facet settings and mode-specific groups | Which query clause the selected value becomes. |
| Authored values | Option values, search input value, map bounds, pagination controls | The value sent for that query clause. |
The component family pages describe the markup and props for each family. The system pages explain how those props work together across families.
## Component Families
- [Facet Target](/facets/component-families/facet-target) stores and refreshes the result template.
- [Search Facet](/facets/component-families/search-facet) sends text input values.
- [Select Facet](/facets/component-families/select-facet) sends single or multiple selected option values.
- [SearchSelect Facet](/facets/component-families/search-select-facet) sends searchable single or multiple option values.
- [Radio List Facet](/facets/component-families/radio-list-facet) sends one selected option value and can include a reset option.
- [Checkbox List Facet](/facets/component-families/checkbox-list-facet) sends multiple selected option values.
- [Map Facet](/facets/component-families/map-facet) sends a geographic bounding box and reads Map POI data from the target loop.
- [Map Address Facet](/facets/component-families/map-address-facet) sends selected address coordinates for proximity filtering.
- [Map Radius Facet](/facets/component-families/map-radius-facet) chooses the distance used with a same-target map address selection.
- [Pagination Facet](/facets/component-families/pagination-facet) sends page offsets for a target.
- [Load More Facet](/facets/component-families/load-more-facet) requests another batch for a target.
- [Reset Facet](/facets/component-families/reset-facet) clears all active filters for a target.
## Accessibility Contract
Facet controls expose native or ARIA semantics for their interaction model. Search facets are named search inputs, select facets use listbox-style popups, search-select facets use editable combobox popups, radio list facets use a radiogroup, and checkbox list facets use grouped checkboxes.
Facet targets announce result changes politely. During refreshes, targets expose busy state, then the shared status region announces `No results found`, `1 result found`, or the current result count.
Keyboard users can open dropdown facets with standard keys, close popups with Escape, move focus forward with Tab, activate buttons with Enter or Space, and update radio and checkbox facets without pointer input.
## Start Here
Read these pages in order when building a facet interface:
1. [How Facets Work](/facets/how-facets-work) for the request and target lifecycle.
2. [Facet Events API](/facets/custom-events) for public control events, result lifecycle hooks, response metadata, and Map event recipes.
3. [Argument Modes](/facets/argument-modes) for the exact meaning of each mode.
4. [Shared Props](/facets/shared-props) for props shared across select, search select, radio, checkbox, and search.
5. [Availability, Counts, and Options](/facets/availability-counts-and-options) for dynamic option state.
6. [Recipes](/facets/recipes) for codebase-backed examples from the E2E scenarios.
---
## How Facets Work
# How Facets Work
Facet runtime is target-centric. Every control identifies a `target`, and every `Facet Target` with the same target ID participates in that target scope.
## Render and Refresh Lifecycle
1. During the original page render, `FacetBlockInterceptor` detects `Facet Target` components.
2. The target's loop and fallback slots are normalized and stored as the refresh template.
3. Facet controls register query descriptors for the same target ID.
4. On interaction, the client builds scoped facet clauses and calls the facet REST endpoint.
5. The endpoint applies those clauses to the target loop config, re-renders the stored target template, computes pagination and availability metadata, and returns markup.
6. The client replaces the target content, updates URL state, updates option availability, applies pagination metadata, and reruns returned scripts when the target allows it.
For public browser hooks around dynamic content, control interaction, and response metadata, see the [Facet Events API](/facets/custom-events). The `ome:facet:target-content-updated` event is the supported synchronous seam for customizing newly inserted authored result markup.
## Target ID Rules
- The `target` string is the connection between controls and result containers.
- Controls with different target IDs do not affect each other.
- Multiple target containers can share a target ID, but they share the same scoped request state.
- Empty target IDs are not useful at runtime; the PHP components show inline builder guidance when target is missing.
## Facet Target Behavior
`Facet Target` owns the content that gets replaced. Its loop slot is the normal result state, and its fallback slot is shown when the refreshed loop produces no rendered items.
Important target props:
| Prop | Meaning |
| ---------------------- | ------------------------------------------------------------------------------- |
| `target` | Shared target ID. |
| `rerun_scripts` | Allows scripts returned by refreshed markup to run again. Defaults to `true`. |
| `preview_fallback` | Shows the fallback slot in Etch preview instead of the loop slot. |
| `scroll_to_top` | Scrolls to the target after connected facet updates. |
| `used_with_map` | Marks the target as map-paired, so map and result updates coordinate correctly. |
| `load_more_on_scroll` | Adds internal offset and posts-per-page controls for infinite scroll. |
| `load_more_batch_size` | Batch size used by infinite scroll. |
Nested loops have a specific rule: if a Facet Target lives inside another Etch loop, outer loop params must be resolved during the original render pass. The current implementation freezes those params through `FacetLoopParamResolver` before the target template is stored, and the E2E `nested_loop_context` scenario verifies that refreshed results keep the correct outer-loop context.
## URL State
Facet state is serialized under the target ID. The E2E URL tests cover direct-link hydration for search, checkbox, radio, select, pagination, map state, ACF relationship, and mapped bundle filters.
Examples:
```text
ome[products][category_name]=shoes
ome[products][meta_value:price]=50
ome[products][tax_query:facet_color]=red
ome[products][acf_relationship:facet_related_posts]=123
ome[products][geo_bbox]=40.5,-74.3,40.9,-73.7
```
The exact URL key depends on the facet clause type and mode-specific options such as `meta_key`, `taxonomy`, or date `column`.
## Pagination, Load More, and Reset
- `Pagination Facet` writes pagination state for a target and receives total pages, total items, current page, per-page, and offset metadata from responses.
- `Load More Facet` writes hidden offset and posts-per-page controls, then appends another batch through the same target request path.
- `load_more_on_scroll` on `Facet Target` uses the same internal offset mechanism without requiring a visible button.
- `Reset Facet` clears all controls connected to the target and returns the target to its unfiltered state.
Pagination and load-more offsets are relative to the target's first rendered result. If the connected WP_Query loop has an authored `offset`, the endpoint preserves that offset as the base, applies pagination after it, and reports totals for the post-base-offset result set.
When any normal facet value changes, pagination resets to page 1. The multi-facet E2E scenario verifies that changing `category_name` after navigating to page 2 resets pagination before showing the narrowed result set.
## Map Pairing
`Map Facet` is a facet control with type `geo_bbox`. It sends the map viewport as a bounding box and reads Map POI elements from the connected target loop.
Use a map-paired setup when:
- the target loop renders listings,
- each listing includes a `Map POI`,
- the map and result target share the same target ID,
- the target sets `used_with_map` when map coordination is needed.
The map runtime can use detailed POI markup for smaller sets and lightweight coordinate responses for large sets.
---
## Facet Events API
# Facet Events API
Facet events are browser `CustomEvent` objects for observing facet controls, customizing authored result markup, and reacting to completed result updates. Listen on a component root when you own one instance, or use event delegation on `document` when several facets share an integration.
The events are documented as observation contracts, not as a command API. Do not dispatch synthetic copies to operate a facet. For backward compatibility, some component `change` event names are also consumed by OME's internal adapters, so synthetic dispatch can trigger legacy internal behavior; that behavior is unsupported and must not be used as an integration contract. Propagation methods are not a control API either.
## Which Event Should I Use?
| Goal | Event |
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| Observe a Select opening or closing. | `ome:select:open` or `ome:select:close` |
| Observe a Search Select opening, closing, or receiving query text. | `ome:search-select:open`, `ome:search-select:close`, or `ome:search-select:input` |
| React to a value committed directly through one control. | The component-specific `change` event, `ome:map-address-change`, `ome:map-radius-change`, or `ome:map:bbox-change` |
| Release resources that belong to result content about to be removed. | `ome:facet:target-will-update` |
| Change links, text, classes, attributes, or widgets in newly inserted authored results. | `ome:facet:target-content-updated` |
| Run work after the complete synchronous target update has settled. | `ome:facet:target-updated` |
| Observe count, pagination, or Map POI response metadata. | `ome:facet:response` |
| Observe creation of a Map Facet instance. | `ome:map:initialized` |
Use the Facet Target lifecycle for integrations that care about result changes from any cause, including Reset Facet, pagination, Load More, and URL-driven requests. Control events describe the control itself; they do not guarantee that a request or target update follows.
## Shared Event Rules
Public events dispatched from a facet or Map component root use this DOM configuration:
```js
{
bubbles: true,
composed: true,
cancelable: false,
}
```
This means:
- `event.target` is the component root or physical Facet Target that emitted the event.
- A listener on `document` can use event delegation across component instances.
- Calling `preventDefault()` cannot cancel OME behavior.
- Do not use `stopPropagation()` or `stopImmediatePropagation()` to control OME. An intentionally earlier `stopImmediatePropagation()` can prevent other observers from receiving a DOM event and is unsupported.
- Event handlers run synchronously. Returning a promise or using `await` does not pause OME.
`ome:facet:response` is the exception to the root dispatch rule: it is dispatched directly on `document`. It remains composed and non-cancelable, but bubbling has no practical extra reach from that target.
### Stable semantic fields
New public fields use snake_case and contain serializable semantic data. Control events share:
```ts
interface FacetControlDetail {
readonly target_id: string;
readonly facet_id: string;
}
```
- `target_id` identifies the logical result scope that the control affects.
- `facet_id` identifies the filter or query-clause key, such as `category_name`, `geo_radius`, or `geo_bbox`.
- `event.target` identifies the exact component instance. You do not need a DOM reference inside `event.detail`.
- A cleared scalar value is `null` in the stable fields.
Existing camelCase fields and DOM-element references are retained as legacy compatibility fields. They are documented separately below and are not used in new examples.
## Interaction Events
Interaction events report transient UI state. They do not mean that the selected value or result content changed.
| Event | Dispatch target | When it fires | Stable detail |
| ------------------------- | ------------------------- | ---------------------------------- | ---------------------------------------------------------------------------- |
| `ome:select:open` | Select Facet root. | Its popup opens. | Control fields, selection snapshot, `mode`, `state: "open"`, and `reason`. |
| `ome:select:close` | Select Facet root. | Its popup closes. | Control fields, selection snapshot, `mode`, `state: "closed"`, and `reason`. |
| `ome:search-select:open` | Search Select Facet root. | Its popup opens. | Select fields plus `query`. |
| `ome:search-select:close` | Search Select Facet root. | Its popup closes. | Select fields plus `query`. |
| `ome:search-select:input` | Search Select Facet root. | Its internal search query changes. | Control fields, selection snapshot, `mode`, `query`, and `previous_query`. |
Select and Search Select open/close reasons are:
```ts
type FacetInteractionReason =
| "trigger"
| "item-select"
| "escape"
| "outside-click"
| "tab"
| "another-control"
| "input-focus"
| "input-change";
```
Only Search Select uses `input-focus` and `input-change`. `another-control` means that another overlay handled by the same choice runtime opened: another Select-style UIChoice for Select, or another Search Select for Search Select. Keep a fallback branch when switching on `reason`, because future versions can add another semantic reason.
## Value Change Events
A value change event reports a value committed directly through that control by the user.
These events are not emitted for initial HTML or URL hydration, option-availability synchronization, dependent Map synchronization, or as one event per control during a global Reset Facet action. Observe the Facet Target lifecycle when the integration cares about the resulting content rather than the direct control interaction.
| Event | Dispatch target | Stable detail |
| -------------------------- | ------------------------- | --------------------------------------------------------------------- |
| `ome:select:change` | Select Facet root. | Selection snapshot and `mode`. |
| `ome:search-select:change` | Search Select Facet root. | Selection snapshot, `mode`, and `query`. |
| `ome:checkbox-list:change` | Checkbox List Facet root. | `selected_values`, `previous_values`, `changed_value`, and `checked`. |
| `ome:radio-list:change` | Radio List Facet root. | Selection snapshot. |
| `ome:map-address-change` | Map Address Facet root. | Nested `address` snapshot or `null`. |
| `ome:map-radius-change` | Map Radius Facet root. | Nested `radius` snapshot or `null`. |
| `ome:map:bbox-change` | Map Facet root. | Numeric `bounds`, `center`, and `zoom`. |
### Select, Search Select, and Radio snapshots
Selection events use a common semantic snapshot:
```ts
interface FacetSelectionSnapshot {
readonly selected_value: string | null;
readonly previous_value: string | null;
readonly selected_values: readonly string[];
readonly previous_values: readonly string[];
}
type FacetSelectMode = "single" | "multiple";
```
Select and Search Select add `mode`. Search Select also includes its current `query`. Radio List exposes the arrays as well as the nullable scalar values, so one delegated selection handler can work across all three component families.
### Checkbox List payload
```ts
interface CheckboxListChangeDetail extends FacetControlDetail {
readonly selected_values: readonly string[];
readonly previous_values: readonly string[];
readonly changed_value: string;
readonly checked: boolean;
}
```
`changed_value` and `checked` describe the directly toggled item. The two arrays describe the complete state before and after that action.
### Map Address payload
```ts
interface MapAddressChangeDetail extends FacetControlDetail {
readonly facet_id: "geo_radius";
readonly address: {
readonly label: string;
readonly lat: number;
readonly lng: number;
readonly provider_id: string;
} | null;
}
```
Selecting a suggestion supplies the human-readable label and numeric coordinates. Clearing that selection supplies `address: null`. Map Address and Map Radius share `facet_id: "geo_radius"` because together they form one proximity clause.
### Map Radius payload
```ts
interface MapRadiusChangeDetail extends FacetControlDetail {
readonly facet_id: "geo_radius";
readonly radius: {
readonly value: number;
readonly unit: "mi" | "km";
} | null;
}
```
### Map bounding-box payload
```ts
interface MapBboxChangeDetail extends FacetControlDetail {
readonly facet_id: "geo_bbox";
readonly bounds: {
readonly south: number;
readonly west: number;
readonly north: number;
readonly east: number;
};
readonly bbox: string;
readonly center: {
readonly lat: number;
readonly lng: number;
};
readonly zoom: number;
}
```
The stable values are plain serializable values. `bbox` is the serialized `south,west,north,east` clause value; `bounds` avoids requiring consumers to parse it. The event does not expose a Leaflet bounds or Map instance.
## Facet Target Update Lifecycle
The lifecycle describes accepted dynamic content updates, not the request lifecycle:
```text
old authored content is present
│
├─ ome:facet:target-will-update
│
├─ replace or append content and reconcile fallback
│
├─ ome:facet:target-content-updated ← synchronous customization seam
│
├─ OME hydration, response metadata, dependent Map sync,
│ returned script scheduling, URL sync, and loading cleanup
│
└─ ome:facet:target-updated
```
All three events have the same detail:
```ts
interface FacetTargetLifecycleDetail {
readonly target_id: string;
readonly template_id: string;
readonly update_mode: "replace" | "append";
}
```
| Event | DOM visible to the listener | Intended use |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `ome:facet:target-will-update` | Existing result content is still present. | Release third-party observers, widgets, or resources owned by the outgoing authored content. |
| `ome:facet:target-content-updated` | Replacement or appended content and fallback state are already in the physical target. Dependent result views have not consumed that content yet. | Synchronously customize newly inserted authored result markup. This is the only supported mutation seam. |
| `ome:facet:target-updated` | Synchronous OME target work is complete and the loading state is cleared. | Observe or measure the settled update. |
`update_mode: "replace"` means the response replaced the result content. `update_mode: "append"` means Load More or infinite scroll extended the existing result content. A content handler must be idempotent because it can run repeatedly against appended or replacement markup.
### Physical targets and logical targets
Several Facet Target elements can share one `target_id`. The lifecycle emits one event per physical Facet Target for each phase, with that element available as `event.target`. The response event is different: `ome:facet:response` emits once per logical `target_id` update. When those physical targets use different templates, its summary can combine fields from more than one template response; the precedence rules are documented below.
### Lifecycle limits
- A failed, invalid, aborted, or stale response does not begin the content lifecycle.
- A rare synchronous failure in a later OME hydration step can happen after `will-update` and `content-updated`. OME then restores the previous content and omits `target-updated`. There is no rollback event in v1, so customization handlers must be idempotent and release old integrations again on the next `will-update`.
- The initial server render does not emit these events. Run an enhancement function once for existing markup, then listen for dynamic `ome:facet:target-content-updated` events.
- These are content events, not a request lifecycle. They do not expose request start, network timing, request data, a correlation identifier, or cancellation.
- There is no rollback phase in v1. A future additive detail field can identify another update cause without changing `update_mode`.
- Handlers are synchronous and non-cancelable. OME does not wait for promises returned by a listener.
- `ome:facet:target-updated` confirms synchronous hydration and scheduling. It does not wait for returned module scripts or other async modules to finish executing.
## Supported Customization Boundary
During `ome:facet:target-content-updated`, you may synchronously change authored result markup that your site owns:
- update an authored link `href` or image `src`;
- change authored text;
- add or remove your own classes and attributes;
- initialize your own result widget or add your own authored element.
The following are unsupported:
- changing or removing OME component roots or OME-owned `data-ome-*` attributes;
- changing Facet Target identity, Map POI identity, or Map coordinates;
- mutating `event.detail`, the response summary, `pois`, or `selected_content`;
- treating `will-update` or `target-updated` as markup mutation hooks;
- delaying OME with async work or trying to cancel the lifecycle.
Use your own class or data attribute as the integration selector. This keeps the handler independent of OME runtime markup.
## Facet Response Event
`ome:facet:response` is an advanced, read-only summary dispatched on `document` once per logical accepted target update.
```ts
interface FacetResponseDetail {
readonly target_id: string;
readonly count: number;
readonly pagination?: {
readonly per_page: number;
readonly offset: number;
readonly current_page: number;
readonly total_pages: number;
readonly total_items: number;
readonly has_prev_page: boolean;
readonly has_next_page: boolean;
readonly range_start: number;
readonly range_end: number;
readonly unbounded?: boolean;
};
readonly pois?: readonly {
readonly value: string;
readonly slug?: string;
readonly lat: number;
readonly lng: number;
readonly hover_content?: string;
readonly selected_content?: string;
}[];
readonly visible_values?: readonly string[];
readonly map_poi_detail_mode?: "full" | "lightweight";
readonly map_poi_detail_threshold?: number;
readonly map_poi_result_count?: number;
readonly map_poi_truncated?: boolean;
}
```
For a logical target backed by multiple template responses, OME builds the summary in registered target order:
- `count` and other base fields come from the first registered Facet Target template.
- `pagination` comes from the last template response in that order that contains pagination metadata.
- Map fields come from the first template response in that order that contains any Map payload.
The resulting fields can therefore describe different physical templates that share the same `target_id`. Treat the event as a logical-target summary rather than as one raw response. Pagination fields are absent when none of the template responses includes pagination metadata. Map fields are absent when none includes Map data.
The event fires after every physical target has received its new content, availability and pagination metadata have been applied, and the internal Map synchronization has run. It fires before `ome:facet:target-updated`, which additionally confirms returned-script scheduling, URL synchronization, and loading cleanup.
Use this event for analytics, diagnostics, or read-only synchronization. Do not mutate its detail to change results or Map POIs. Internal Map synchronization does not depend on listener order or on consumers modifying this public event; use `ome:facet:target-content-updated` for authored markup customization.
## Map Initialized Event
`ome:map:initialized` is dispatched from the Map Facet root after its runtime instance and initial POI state have been created.
```ts
interface MapInitializedDetail {
readonly target_id: string;
}
```
It does not mean that map tiles or animations have finished, and it does not expose a Leaflet instance or a public Map control API.
## Example: Handle Selection Facets Together
```js
const selection_events = [
"ome:select:change",
"ome:search-select:change",
"ome:radio-list:change",
];
for (const event_name of selection_events) {
document.addEventListener(event_name, (event) => {
if (!(event instanceof CustomEvent)) {
return;
}
const { target_id, facet_id, selected_values } = event.detail;
if (target_id === "products" && facet_id === "category_name") {
console.log("Selected categories", selected_values);
}
});
}
```
## Example: Observe A Settled Target Update
```js
document.addEventListener("ome:facet:target-updated", (event) => {
if (
!(event instanceof CustomEvent) ||
!(event.target instanceof HTMLElement)
) {
return;
}
if (event.detail.target_id !== "articles") {
return;
}
console.log(
"Rendered article cards",
event.target.querySelectorAll(".article-card").length,
);
});
```
## Example: Add `saddr` To Map POI Direction Links
Suppose the selected slot of each authored Map POI contains this link:
```html
Get directions
```
Keep the selected address by logical target, then change the authored links only in the content-update seam:
```js
const start_addresses = new Map();
function update_direction_links(root, target_id) {
const start_address = start_addresses.get(target_id) ?? null;
for (const link of root.querySelectorAll("[data-directions-link]")) {
if (!(link instanceof HTMLAnchorElement)) {
continue;
}
const authored_href = link.getAttribute("href");
if (!authored_href) {
continue;
}
const url = new URL(authored_href, window.location.href);
if (start_address === null) {
url.searchParams.delete("saddr");
} else {
url.searchParams.set("saddr", start_address);
}
link.href = url.toString();
}
}
document.addEventListener("ome:map-address-change", (event) => {
if (!(event instanceof CustomEvent)) {
return;
}
const { target_id, address } = event.detail;
start_addresses.set(target_id, address?.label ?? null);
});
document.addEventListener("click", (event) => {
if (!(event.target instanceof Element)) {
return;
}
const reset = event.target.closest("[data-directions-address-reset]");
if (!(reset instanceof HTMLElement)) {
return;
}
const target_id = reset.dataset.directionsTargetId;
if (target_id) {
start_addresses.set(target_id, null);
}
});
document.addEventListener("ome:facet:target-content-updated", (event) => {
if (
!(event instanceof CustomEvent) ||
!(event.target instanceof HTMLElement)
) {
return;
}
update_direction_links(event.target, event.detail.target_id);
});
function enhance_existing_targets() {
for (const target of document.querySelectorAll(".dealer-results")) {
if (target instanceof HTMLElement) {
update_direction_links(target, "dealers");
}
}
}
enhance_existing_targets();
```
Add the authored `.dealer-results` class to the dealer Facet Target. If the page also has a global Reset Facet, add your own `data-directions-address-reset` and `data-directions-target-id="dealers"` attributes to that authored reset control. Global Reset clears controls silently, so this optional click handler clears the integration's state before the next result update without depending on OME-owned attributes.
The helper runs once for the initial server-rendered DOM; the lifecycle listener handles every later replacement or append. Calling the function repeatedly is safe because `URL.searchParams.set()` replaces the existing value instead of duplicating it. Clearing Map Address directly or through the authored Reset integration stores `null`, and the next content update removes `saddr`.
Initial URL hydration does not emit a value change event. If another integration already knows an initial human-readable address, seed `start_addresses` before calling `enhance_existing_targets()`.
This recipe runs before the Map runtime consumes the new Map POI selected content. A `MutationObserver` and response-payload mutation are not needed.
## Example: Observe Response Counts
```js
document.addEventListener("ome:facet:response", (event) => {
if (
!(event instanceof CustomEvent) ||
event.detail.target_id !== "products"
) {
return;
}
window.dataLayer?.push({
event: "facet_results_updated",
result_count: event.detail.count,
});
});
```
## Example: Read Map Viewport State
```js
document.addEventListener("ome:map:bbox-change", (event) => {
if (!(event instanceof CustomEvent)) {
return;
}
const { bounds, center, zoom } = event.detail;
console.log({ bounds, center, zoom });
});
```
## Legacy Compatibility Fields
Existing integrations can continue to receive the historical fields below. New integrations should use the semantic snake_case fields and `event.target` instead.
| Event family | Legacy compatibility fields |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Select | `selectId`, `selectedValue`, `selectedValues`, `previousValue`, `previousValues`, `highlightedValue`, `rootElement`, `triggerElement`, `contentElement`, `itemElement` |
| Search Select | `searchSelectId`, `previousQuery`, the Select-style value fields, `rootElement`, `inputElement`, `triggerElement`, `contentElement`, `itemElement` |
| Radio List | `selectedValue`, `previousValue`, `rootElement`, `itemElement` |
| Map Address | `target`, `label`, string `lat`, string `lng`, `providerId` |
| Map Radius | `target`, string `value`, string `unit` |
These fields are preserved for backwards compatibility, but their DOM references and presentation-oriented shapes should not be used as the basis of a new integration.
---
## Argument Modes
# Argument Modes
Argument mode decides what a facet value becomes in the backend query. Select, SearchSelect, Radio List, and Checkbox List share the `FacetQueryProperties` mode system. Search Facet implements the same mode names separately because text search needs partial-match aliases and multi-argument text bundling.
## Mode Summary
| Mode | Runtime facet type | Used by | Value meaning |
| --------------------------- | ---------------------------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `default` | selected query argument, such as `category_name` or `post_type` | Search and option facets | The value is assigned to a standard WP query argument. |
| `meta` | `meta_value` | Search and option facets | The value is compared against a configured post meta key. |
| `serialized_meta` | `serialized_meta_value` | Search and option facets | The value is matched against one stored string inside a serialized string-array meta field. |
| `tax` | `tax_query` for option facets, `tax_query_like` for Search Facet | Search and option facets | The value is interpreted as a term field for a configured taxonomy. |
| `date` | `date_query` | Search and option facets | The value is interpreted as a date range for a configured post date column. |
| `acf_relationship` | `acf_relationship` | Search and option facets | The value is a related post ID, or comma-separated IDs, matched against a serialized relationship meta field. |
| multi-argument Search Facet | `query_bundle` | Search Facet only | One typed text value expands into multiple query clauses. |
| multi-argument option facet | `mapped_bundle` | Select, SearchSelect, Radio List, Checkbox List | One authored option expands into multiple query clauses with per-option mapped values. |
## Default Query Argument
Default mode writes a standard query argument.
Option facets use values from `FacetQueryProperties`, including:
```text
search, p, name, title, post_type, order, orderby, category_name, tag, author, author_name, year, monthnum, posts_per_page
```
Search Facet has a filter-oriented set and uses partial aliases for text fields:
```text
search, p, title_like, name_like, post_type, category_name_like, tag_like, author, author_name_like, year, monthnum
```
Use default mode for common query arguments like post type, category slug, tag slug, author, year, month, ordering, and posts per page.
## Meta Argument
Meta mode uses:
- `meta_key`
- `meta_compare`
- `meta_type`
Option facets default `meta_compare` to `=`, while Search Facet defaults it to `LIKE`. Supported compares are:
```text
=, !=, >, >=, <, <=, LIKE, NOT LIKE, IN, NOT IN, BETWEEN, NOT BETWEEN, EXISTS, NOT EXISTS
```
Use comma-separated values for `IN`, `NOT IN`, `BETWEEN`, and `NOT BETWEEN`. E2E coverage verifies exact numeric matches, char matches, bool matches, range compares, substring compares, set compares, and values with spaces.
## Serialized Multi-Value Meta
Serialized Multi-Value Meta mode uses:
- `serialized_meta_argument.meta_key`
Use this mode when a post meta field stores a PHP serialized array of string option values. Common examples are Meta Box or ACF multi-select and checkbox choice fields stored in post meta.
Example stored value:
```text
a:3:{i:0;s:3:"omv";i:1;s:2:"ff";i:2;s:3:"veg";}
```
Authoring setup:
```text
argument_mode = serialized_meta
serialized_meta_argument.meta_key = mk_meta_types
option values = omv, ff, veg
```
Authored option values must match the stored string values, not the visible labels when labels differ. Selecting multiple values for the same serialized meta key matches posts that contain any selected value, then combines with other active facets normally.
Serialized Multi-Value Meta does not expose `meta_compare` or `meta_type`. Use Meta Argument for plain scalar meta, numeric comparisons, ranges, substring comparisons, `EXISTS`, `NOT EXISTS`, or other normal `meta_compare` behavior.
Advanced integrations may see the runtime clause type `serialized_meta_value`. Readable URL keys use the typed form `serialized_meta.` when a typed key is needed.
## Taxonomy Argument
Tax mode uses:
- `taxonomy`
- `tax_field`
Supported fields are:
```text
slug, term_id, name, term_taxonomy_id
```
Option facets produce exact `tax_query` clauses. Search Facet produces `tax_query_like`, so it can search term names or slugs by typed text where supported by the backend clause handling.
The taxonomy E2E scenario verifies `facet_color` with all four fields and also covers multiple taxonomy filters.
## Date Query
Date mode uses a configured date column:
```text
post_date, post_modified, post_date_gmt, post_modified_gmt
```
Authored option values should use:
```text
YYYY-MM-DD,YYYY-MM-DD
```
The first date is the start, and the second is the end. Search Facet sends the typed input through the same `date_query` facet type.
## ACF Relationship
ACF relationship mode uses `acf_relationship_argument.meta_key`, which is the relationship field stored on the posts being filtered.
The value must be a numeric related post ID, or a comma-separated list of related post IDs. It does not reverse-resolve a bidirectional relationship stored only on the related posts.
Example rule:
```text
If you filter Events by Speaker, the Event posts must store the selected Speaker IDs in the configured relationship field.
```
The `wp_query_args` E2E scenario verifies select and checkbox ACF relationship filters, counts, unavailable state, comma-list option values, and direct URL hydration.
## Search Facet Query Bundle
When `target_multiple_query_arguments` is enabled on Search Facet, the control renders as `query_bundle`.
One typed search value is applied to every row in `query_argument_mappings`. The `query_argument_relation` setting controls whether the generated clauses are joined with `AND` or `OR`. Search mappings normalize common exact types to partial search aliases, for example `title` becomes `title_like` and `category_name` becomes `category_name_like`.
Use this when one text field should search several places, such as title or priority, or title or category.
## Option Facet Mapped Bundle
When `target_multiple_query_arguments` is enabled on Select, SearchSelect, Radio List, or Checkbox List, the root facet type becomes `mapped_bundle`.
The parent facet defines `query_argument_mappings`. Each option defines `query_value_mappings`. At runtime, an option is valid only when its value mappings can be matched to the parent mapping keys.
Example:
```text
Parent mappings:
- category -> default category_name
- priority -> meta facet_priority
Option "News + High priority":
- category = facets-e2e-news
- priority = high
```
The mapped bundle E2E coverage verifies filtering, URL restore, counts, unavailable state, and availability updates after other filters change.
---
## Shared Props
# Shared Props
Many facet families share the same logic even when their markup is different. The most important distinction is whether a prop belongs to the parent facet or to an authored option.
## Parent Facet Props
These props apply to Select, SearchSelect, Radio List, and Checkbox List through `FacetQueryProperties`. Search Facet has matching props implemented in its own component file.
| Prop | Applies to | Why it matters |
| --------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| `target` | All facet controls | Connects the control to the Facet Target with the same target ID. |
| `argument_mode` | Search and option facets when `target_multiple_query_arguments` is false | Chooses the single query mode. |
| `target_multiple_query_arguments` | Search and option facets | Switches from one query target to multi-argument behavior. |
| `options_behavior` | Select, SearchSelect, Radio List, Checkbox List | Controls unavailable option behavior after availability data changes. |
| `show_counts` | Select, SearchSelect, Radio List, Checkbox List | Enables dynamic result counts on options. |
| `selection_mode` | Select and SearchSelect | Chooses single or multiple selected values. |
| `aria_label` | Radio List and Checkbox List | Names the `radiogroup` or `group` for assistive technology. |
| `default_label` | Select and SearchSelect | Text shown when nothing is selected, and the built-in clear item label for Select. |
| `placeholder` | Search and SearchSelect | Text shown in the input before a value is typed. |
## Single-Argument Groups
When `target_multiple_query_arguments` is false, the selected `argument_mode` decides which group is active:
| Group | Active when | Required values |
| --------------------------- | ------------------------------------- | --------------------------------------- |
| `default_query_argument` | `argument_mode` is `default` | `facet_key` |
| `meta_argument` | `argument_mode` is `meta` | `meta_key`, `meta_compare`, `meta_type` |
| `serialized_meta_argument` | `argument_mode` is `serialized_meta` | `meta_key` |
| `taxonomy_argument` | `argument_mode` is `tax` | `taxonomy`, `tax_field` |
| `date_argument` | `argument_mode` is `date` | `column` |
| `acf_relationship_argument` | `argument_mode` is `acf_relationship` | `meta_key` |
## Multi-Argument Parent Props
When `target_multiple_query_arguments` is true, the parent facet uses `query_argument_mappings`.
Each row needs:
| Prop | Meaning |
| --------------------------------------- | -------------------------------------------------------------- |
| `mapping_key` | Stable row key referenced by option value mappings. |
| `argument_mode` | Query mode for this mapped row. |
| `facet_key` | Used when row mode is `default`. |
| `meta_key`, `meta_compare`, `meta_type` | Used when row mode is `meta`. |
| `meta_key` | Used when row mode is `serialized_meta` or `acf_relationship`. |
| `taxonomy`, `tax_field` | Used when row mode is `tax`. |
| `column` | Used when row mode is `date`. |
For Search Facet, the typed input becomes the value for every mapped row. For option facets, each option supplies its own values through `query_value_mappings`.
## Option Props
Select, SearchSelect, Radio List, and Checkbox List option components share these concepts:
| Prop | Applies to | Meaning |
| ------------------------------ | --------------------------------- | ---------------------------------------------------------------------- |
| `content.value` | Single-argument option mode | Value sent when the option is selected. |
| `content.label` | All option modes | Visible label and count base text. |
| `metadata` | All option modes | Optional key/value rows serialized for custom JavaScript integrations. |
| `query_value_mappings` | Multi-argument option mode | Per-option values keyed by parent `mapping_key`. |
| `disabled` | All option families | Prevents authored selection. |
| `is_default` | Select, Radio List, Checkbox List | Marks initial selection when no URL or runtime value already exists. |
| `used_with_multiple_arguments` | Option components | Shows mapping-driven authoring instead of manual `content.value`. |
| `count_display` | Option components | Chooses inline count text or a separate count span. |
`used_with_multiple_arguments` is an authoring switch for option components. It should match the parent facet's multi-argument setup: enable it when the parent has `target_multiple_query_arguments` enabled and the option needs `query_value_mappings`.
## Count Display
`count_display` supports:
| Value | Behavior |
| -------- | ------------------------------------------------------------------------- |
| `inline` | Runtime appends counts to the visible label text. |
| `span` | Runtime writes counts into a separate `data-ome-facet-option-count` span. |
Use `span` when the count needs separate styling or layout. The PHP components include Etch preview count props for span mode so authors can style the counter before runtime data exists.
## Reset Props
Radio List has built-in reset props:
| Prop | Meaning |
| ------------------- | -------------------------------------------------------- |
| `show_reset_option` | Adds a reset choice before authored options. |
| `reset_option_mode` | Renders the reset choice as radio-style or button-style. |
| `reset_label` | Label for the built-in reset choice. |
Reset Facet is a separate component. It clears all controls for the target rather than only one radio list selection.
---
## Availability, Counts, and Options
# Availability, Counts, and Options
Availability is the runtime metadata that tells option facets which values currently produce results. It is computed per target after a facet request and then applied by the client to Select, SearchSelect, Radio List, and Checkbox List controls.
## Options Behavior
`options_behavior` controls what happens to unavailable options.
| Value | Behavior |
| --------- | ------------------------------------------------------------------------------- |
| `all` | Keep every authored option visible and enabled. Counts can still update. |
| `disable` | Keep unavailable options visible, but mark them disabled and prevent selection. |
| `hide` | Hide unavailable options from the UI. |
The option behavior E2E scenario verifies all three modes across Select, SearchSelect, Radio List, and Checkbox List.
## Dynamic Counts
`show_counts` enables result counts on option values when availability data exists.
Counts are based on the current target scope and the other active filters. For example, after a search narrows results to one post, category options can update to `News category (1)` and `Guides category (0)`.
Count rendering depends on each option's `count_display`:
- `inline` appends the count to the label text.
- `span` writes the count into a separate counter span.
## Serialized Meta Availability
For `serialized_meta_value`, availability and counts are computed from individual string values inside the serialized array stored at the configured `meta_key`. A post with this stored value can contribute counts to `omv`, `ff`, and `veg` separately:
```text
a:3:{i:0;s:3:"omv";i:1;s:2:"ff";i:2;s:3:"veg";}
```
When authored option values are available, the availability descriptor limits counts to those values. Empty values, non-array meta values, unparseable values, and non-string array entries do not produce option availability entries.
## Cross-Facet Behavior
Facet availability is cross-facet. A change in one control can change the option state of another control connected to the same target.
Example from E2E behavior:
```text
Search "Foo" narrows results to Alpha Foo.
Category "news" remains available with count 1.
Category "guides" becomes unavailable with count 0.
```
This works for single-mode facets and for mapped bundles. Mapped bundle availability is keyed by a generated control scope so each authored bundle can be counted independently.
## Selected Values That Become Unavailable
Select and SearchSelect can reset a selected value when that value becomes unavailable in `disable` or `hide` mode. The option behavior tests cover auto-reset for selected categories after a search makes the selected category unavailable.
Radio and checkbox behavior also syncs disabled, hidden, ARIA, and selected state through their runtimes so stale state is not left in the DOM after an update.
## Default Selections
Authored default options initialize controls only when there is no URL, runtime, or restored value already present.
- Select supports authored default options and has a built-in empty option using the `default_label`.
- Radio List supports default options and can also render a built-in reset option.
- Checkbox List supports multiple authored defaults.
- SearchSelect options do not expose `is_default` in the current PHP component.
Direct URL state wins over authored defaults. The URL parameter E2E suite verifies direct-link hydration for several facet families.
## Performance Boundary
Availability computation may fan out across descriptors, including mapped bundle descriptors. The endpoint limits expensive paths with query budgets, descriptor truncation metadata, and sampled post IDs. Authoring a large number of mapped bundles is supported, but it has a real availability cost because every bundle may need a count.
Use `show_counts` and `disable` or `hide` when users benefit from availability feedback. Leave `options_behavior` as `all` and `show_counts` as false when the UI does not need dynamic option state.
---
## Facet Recipes
# Facet Recipes
These recipes use real scenarios from the test suite. They describe authoring intent and the important prop choices rather than copying fixture-only helper code.
## CPT and Taxonomy Filter
Use this when a result loop lists a custom post type and users need to filter by a custom taxonomy.
Example data:
```text
Post type: facettestcpt
Taxonomy: facet_color
Terms: red, blue, green
Target ID: catalog-results
```
Authoring setup:
1. Add a `Facet Target` with `target = catalog-results`.
2. Place the WP Query loop in the target loop slot. The loop should include the desired post type.
3. Add a `Select Facet`, `Radio List Facet`, or `Checkbox List Facet` with the same `target`.
4. Set `argument_mode = tax`.
5. Set `taxonomy = facet_color`.
6. Set `tax_field = slug` when option values are slugs like `red`.
7. Add options with values matching the selected field.
The taxonomy E2E suite verifies `slug`, `term_id`, `name`, and `term_taxonomy_id`.
## Multiple Facets to One Target
Use this when users need to narrow the same result grid with several independent controls.
Example:
```text
Target ID: multi-combo-target
Facet 1: Select post_type = post
Facet 2: Select category_name = facets-e2e-news
Facet 3: Select tag = facets-e2e-beta
Facet 4: Radio meta facet_priority = high
```
Each facet uses the same `target`. The backend combines the active clauses, and the result is the intersection. The E2E suite verifies two-way, three-way, and four-way intersections, fallback on zero results, recovery after clearing one facet, and pagination reset after changing a facet.
## Meta Filter
Use meta mode when the filtered value lives in post meta.
Example data:
```text
Meta key: facet_price
Values: 10, 25, 50, 75, 100
```
Authoring setup:
```text
argument_mode = meta
meta_key = facet_price
meta_compare = BETWEEN
meta_type = numeric
option value = 25,75
```
The meta query E2E suite verifies exact matches, numeric ranges, char values, bool values, `LIKE`, `NOT LIKE`, `IN`, `NOT IN`, `BETWEEN`, and `NOT BETWEEN`.
## Meta Box or ACF Multi-Select Filter
Use Serialized Multi-Value Meta mode when a Meta Box, ACF, or custom choice field stores selected option keys as a PHP serialized string array.
Example stored post meta:
```text
Meta key: mk_meta_types
Stored value: a:3:{i:0;s:3:"omv";i:1;s:2:"ff";i:2;s:3:"veg";}
Stored option values: omv, ff, veg
```
Authoring setup:
1. Add a `Facet Target` with the target ID for the results, such as `products`.
2. Add a `Select Facet`, `SearchSelect Facet`, `Radio List Facet`, or `Checkbox List Facet` with the same `target`.
3. Set `argument_mode = serialized_meta`.
4. Set `serialized_meta_argument.meta_key = mk_meta_types`.
5. Add options whose values match the stored option values, such as `omv`, `ff`, and `veg`.
6. Use labels for the human-readable text only.
Example option setup:
```text
Option label: Vegetarian
Option value: veg
```
If this setup returns zero records, check the stored option values and meta key first. Use stored values, not labels, and use the field's post meta key. Do not use Meta Argument with `meta_compare = IN` for PHP serialized arrays like the example above; `IN` compares against whole meta values, while Serialized Multi-Value Meta matches the serialized string tokens inside the array.
## Date Range Filter
Use date mode when authored options represent date ranges.
```text
argument_mode = date
column = post_date
option value = 2024-01-01,2024-12-31
```
The first date is the start date and the second date is the end date. Supported columns are `post_date`, `post_modified`, `post_date_gmt`, and `post_modified_gmt`.
## ACF Relationship Filter
Use ACF relationship mode when the posts being filtered store related post IDs in a relationship field.
```text
Filtered posts: Projects
Related posts: People
Relationship field on Projects: project_people
Facet option value: numeric Person post ID
```
Authoring setup:
```text
argument_mode = acf_relationship
acf_relationship_argument.meta_key = project_people
option value = 123
```
The directional rule is important: the relationship field must be stored on the posts being filtered. The facet does not reverse-resolve a relationship stored only on the related posts.
Comma-separated option values are supported for matching any of several related IDs:
```text
option value = 123,456
```
## Mapped Bundle Option
Use mapped bundle when one option should apply several query clauses.
Example option:
```text
Label: News + High priority
category mapping: category_name = facets-e2e-news
priority mapping: facet_priority = high
```
Parent facet:
```text
target_multiple_query_arguments = true
query_argument_mappings:
- mapping_key = category, argument_mode = default, facet_key = category_name
- mapping_key = priority, argument_mode = meta, meta_key = facet_priority, meta_compare = =, meta_type = char
```
Option:
```text
used_with_multiple_arguments = true
query_value_mappings:
- mapping_key = category, value = facets-e2e-news
- mapping_key = priority, value = high
```
The runtime expands the selected option into both clauses.
## Search Across Multiple Arguments
Use Search Facet multi-argument mode when one input should search more than one field.
```text
target_multiple_query_arguments = true
query_argument_relation = OR
query_argument_mappings:
- mapping_key = native-search, argument_mode = default, facet_key = search
- mapping_key = priority, argument_mode = meta, meta_key = facet_priority, meta_compare = LIKE, meta_type = char
```
Typing one value creates a `query_bundle` and applies the typed value to each mapped row. Search mappings normalize common text fields to partial aliases, so `title` behaves like `title_like`.
## Map and POIs
Use Map Facet when the target loop renders listings with coordinates.
Authoring setup:
1. Add `Map Facet` with `target = map-results`.
2. Configure `lat_meta_key` and `lng_meta_key`.
3. Add `Facet Target` with the same `target` and `used_with_map = true`.
4. Inside the target loop, add `Map POI`.
5. Set POI `value`, `lat`, and `lng` from the current loop item.
The map runtime reads initial POIs from the DOM and sends `geo_bbox` values as the map moves.
## Nested Loop Target
If the target is inside an outer Etch loop, keep the target template inside the original render context. The current implementation stores resolved outer-loop params before AJAX refresh, and the `nested_loop_context` E2E scenario verifies that searching for `Alice` still returns `Alice Alpha` and `Alice Beta` from the correct outer-loop rows.
---
## Checkbox List Facet
# Checkbox List Facet
`Checkbox List Facet` is a multi-select option list. It sends all selected option values for the configured target and argument mode.
## Authoring Structure
```text
Checkbox List Facet
└── Checkbox List Facet Option
```
## Parent Props
| Group | Prop | Default | Meaning |
| ----------- | --------------------------------- | -------------------------------------- | --------------------------------------------- |
| Settings | `target` | empty | Shared target ID. |
| Settings | `argument_mode` | `default` | Single argument mode. |
| Settings | `target_multiple_query_arguments` | `false` | Enables mapped bundle mode. |
| Settings | `options_behavior` | `all` | Availability behavior. |
| Settings | `show_counts` | `false` | Enables dynamic counts. |
| Settings | `aria_label` | `Filter options` | Accessible name for the checkbox group. |
| Mode groups | mode-specific props | varies | See [Argument Modes](/facets/argument-modes). |
| Styling | `class` | `ome-checkbox-list-facet-root-default` | Root list class. |
## Option Props
| Group | Prop | Default | Meaning |
| -------------------- | ------------------------------------------------------------ | ------------------ | ------------------------------------------------------ |
| Content | `value` | empty | Sent value in single-argument mode. |
| Content | `label` | `Option` | Visible label. |
| Metadata | `key`, `value` | empty | Optional rows for custom JavaScript integrations. |
| Query Value Mappings | `mapping_key`, `value` | empty | Values used when parent mapped bundle mode is enabled. |
| Settings | `disabled` | `false` | Prevents selection. |
| Settings | `is_default` | `false` | Preselects the option when no restored value exists. |
| Settings | `mode` | `checkbox` | Option presentation: `checkbox` or `button`. |
| Settings | `used_with_multiple_arguments` | `false` | Switches option authoring to query value mappings. |
| Settings | `count_display` | `inline` | Inline count text or separate count span. |
| Styling | option, button, indicator, tick, label, input, count classes | component defaults | Option presentation classes. |
## Runtime Notes
- The public `ome:checkbox-list:change` payload and delegated-listener examples are documented in the [Facet Events API](/facets/custom-events).
- Multiple options can be selected at the same time.
- `mode = button` changes presentation only; the facet remains multi-select.
- The runtime syncs `data-ome-selected-values`, hidden transport inputs, `aria-checked`, disabled state, hidden state, and count displays.
## Example
```text
Checkbox List Facet:
- target = posts
- argument_mode = default
- facet_key = name
Options:
- beta-bar
- gamma-baz
```
---
## Facet Target
# Facet Target
`Facet Target` is the result container. Facet controls do not replace content directly; they send state for a target ID, and the target receives refreshed loop markup from the facet endpoint.
## Structure
```text
Facet Target
├── loop slot
└── fallback slot
```
The loop slot renders the normal results. The fallback slot renders when the refreshed loop has no items.
## Props
| Group | Prop | Default | Meaning |
| --------- | ---------------------- | -------------------------- | ------------------------------------------------------- |
| Structure | `tag` | `div` | HTML tag for the live result wrapper. |
| Structure | `fallback_tag` | `div` | HTML tag for the fallback wrapper. |
| Settings | `target` | empty | Shared target ID used by connected facets. |
| Settings | `rerun_scripts` | `true` | Reruns inline scripts returned with refreshed markup. |
| Settings | `preview_fallback` | `false` | Shows fallback in Etch preview instead of loop content. |
| Settings | `scroll_to_top` | `false` | Scrolls to this target after connected facet updates. |
| Settings | `used_with_map` | `false` | Marks the target as paired with a Map Facet. |
| Settings | `load_more_on_scroll` | `false` | Enables infinite scroll controls inside the target. |
| Settings | `load_more_batch_size` | `10` | Batch size for infinite scroll. |
| Styling | `class` | `ome-facet-target-default` | Root target class. |
## Runtime Contract
The rendered target uses `data-ome-facet-target`, `data-ome-facet-loop`, `aria-live="polite"`, and target-specific data attributes for scripts, scrolling, map pairing, and infinite scroll.
If `load_more_on_scroll` is enabled, the component renders hidden controls for `offset` and `posts_per_page`. Those controls are part of the same facet request flow as the visible Load More Facet.
The public [Facet Events API](/facets/custom-events) defines `ome:facet:target-will-update`, `ome:facet:target-content-updated`, and `ome:facet:target-updated`. Use the content-updated phase for synchronous changes to authored markup; it runs after replacement or append and before dependent result views consume the new content.
## Nested Loop Rule
If a target lives inside another Etch loop, the outer loop params are resolved during the original render before the template is stored. The nested loop E2E scenario verifies that a Search Facet refresh keeps the correct outer-loop context after AJAX refresh.
## Example
```text
Target ID: article-results
Facet Target:
- target = article-results
- loop slot = WP Query loop
- fallback slot = "No posts found."
Search Facet:
- target = article-results
- default query argument = search
```
---
## Load More Facet
# Load More Facet
`Load More Facet` requests the next batch of items for a connected target. It renders hidden `offset` and `posts_per_page` controls plus a visible button.
## Props
| Group | Prop | Default | Meaning |
| --- | --- | --- | --- |
| Settings | `target` | empty | Shared target ID. |
| Settings | `batch_size` | `10` | Number of additional items requested per click. |
| Content | `label` | `Load more` | Fallback label when the default slot is empty. |
| Styling | `class` | `ome-load-more-facet-default` | Button class. |
## Runtime Notes
- The button uses the same target-scoped facet request flow as other controls.
- It updates hidden offset state before requesting the next batch.
- The hidden `offset` is relative to the target's first rendered result. If the connected WP_Query loop has an authored `offset`, the server keeps that as the base and applies Load More batches after it.
- Normal facet changes reset load-more controls for the target.
- Infinite scroll on `Facet Target` uses the same offset and batch-size concepts without a visible button.
Use Load More Facet when users should deliberately request another batch. Use target `load_more_on_scroll` when the page should fetch more automatically near the bottom of the target.
---
## Map Address Facet
`Map Address Facet` lets visitors search an address or ZIP code through the OME LocationIQ proxy. It stores the selected label, latitude, longitude, and provider ID on the component root, then combines with a same-target [Map Radius Facet](/facets/component-families/map-radius-facet) to emit a `geo_radius` value.
## Required Setup
- Configure a LocationIQ token in OME settings.
- Store latitude and longitude meta on each result post.
- Use the same target ID on `Map Address Facet`, `Map Radius Facet`, [Map Facet](/facets/component-families/map-facet), and [Facet Target](/facets/component-families/facet-target).
- Set matching latitude and longitude meta keys on the address and map components.
## Props
| Group | Prop | Default | Meaning |
| -------- | ---------------------- | ---------------------------------------- | -------------------------------------------------------------- |
| Settings | `target` | empty | Shared target ID. |
| Settings | `placeholder` | `Search address...` | Placeholder text shown inside the address input. |
| Settings | `minimum_query_length` | `3` | Number of characters required before lookup starts. |
| Settings | `debounce_ms` | `300` | Delay before address lookup requests are sent. |
| Settings | `clear_aria_label` | `Clear address` | Accessible name for the clear button inside the address input. |
| Query | `lat_meta_key` | `latitude` | Meta key used for result latitude values. |
| Query | `lng_meta_key` | `longitude` | Meta key used for result longitude values. |
| Styling | `class` | `ome-map-address-facet-default` | Root wrapper class. |
| Styling | `input_class` | `ome-map-address-facet-default__input` | The search input. |
| Styling | `clear_button_class` | `ome-map-address-facet-default__clear` | The inline ✕ clear button. |
| Styling | `results_class` | `ome-map-address-facet-default__results` | The results list. |
| Styling | `result_item_class` | `ome-map-address-facet-default__result` | Each result item (applied by the runtime). |
| Styling | `status_class` | `ome-map-address-facet-default__status` | The status region. |
| Styling | `results_host_class` | `ome-map-address-facet-default__host` | The floating results host overlay. |
### Preview
The Map Address Facet ships an Etch-builder preview mode so you can design the results dropdown and clear button before live geocoding is wired up.
| Group | Prop | Default | Meaning |
| ------- | ------------------- | ------- | ------------------------------------------------------------ |
| Preview | `show_results` | `true` | In Etch: render two sample addresses into the results list. |
| Preview | `show_clear_button` | `true` | In Etch: render the clear ✕ visibly (no selection required). |
## Runtime Behavior
Typing opens geocode suggestions. Selecting a suggestion filters the target when a radius is selected, centers the paired map, fits the selected radius, and draws the radius circle. Clearing the address clears the radius filter and removes the map circle.
The public `ome:map-address-change` event exposes the selected human-readable address or `null`. The [Facet Events API](/facets/custom-events) includes a complete recipe for adding that address as `saddr` to authored Map POI direction links before Map consumes refreshed selected content.
### Clear button
When an address is selected, an inline ✕ icon appears at the right edge of the input. Clicking it clears the selection, the input value, and the cached results list. The icon's accessible name is configurable via `settings.clear_aria_label`.
### Selection clears results
Selecting an address from the dropdown closes the dropdown immediately and clears the cached results. The dropdown cannot reappear until a new query is typed.
---
## Map Facet
# Map Facet
`Map Facet` filters a target by the visible map bounds. It sends a `geo_bbox` facet value and reads `Map POI` elements from the connected target loop.
## Authoring Structure
```text
Map Facet
Facet Target
└── loop slot
└── Map POI
```
The map and target must share the same target ID.
## Map Facet Props
| Group | Prop | Default | Meaning |
| -------- | ---------------------------- | ---------------------------- | --------------------------------------------------------------------------------- |
| Settings | `target` | empty | Shared target ID. |
| Settings | `lat_meta_key` | `latitude` | Backend meta key for latitude. |
| Settings | `lng_meta_key` | `longitude` | Backend meta key for longitude. |
| Settings | `center_lat` | `0` | Initial map center latitude. |
| Settings | `center_lng` | `0` | Initial map center longitude. |
| Settings | `zoom` | `4` | Initial Leaflet zoom. |
| Settings | `min_zoom` | `2` | Minimum Leaflet zoom. |
| Settings | `max_zoom` | `18` | Maximum Leaflet zoom. |
| Settings | `tile_url` | empty | Optional custom tile layer URL. |
| Settings | `fit_bounds_on_filter` | `true` | Allows runtime to fit map bounds from filtered POIs. |
| Settings | `bbox_debounce_ms` | `300` | Delay before map movement updates the bbox value. |
| Styling | `class` | `ome-map-facet-root-default` | Map root class. |
| Styling | `bubble_class` | empty | Optional class added to generated cluster bubbles. |
| Styling | `radius_circle_border_color` | `rgba(37, 99, 235, 0.85)` | Stroke color for selected proximity radius circles. |
| Styling | `radius_circle_fill_color` | `rgba(37, 99, 235, 0.14)` | Fill color for selected proximity radius circles; use rgba/hsla for transparency. |
## Map POI Props
| Group | Prop | Default | Meaning |
| ------- | ------- | ------- | ------------------------------------------ |
| Content | `value` | empty | Stable POI identifier. |
| Content | `lat` | empty | POI latitude. |
| Content | `lng` | empty | POI longitude. |
| Styling | `class` | empty | Optional class for the hidden POI carrier. |
## Runtime Notes
- Public `ome:map:bbox-change`, `ome:map:initialized`, response metadata, and Map POI content customization are documented in the [Facet Events API](/facets/custom-events).
- `Map Facet` renders `data-ome-facet="geo_bbox"`.
- The bbox value serializes as `south,west,north,east`.
- `Map POI` is hidden DOM data, not visible listing content.
- POI hover and selected slots can provide marker popup content.
- Large responses can switch to lightweight coordinate-only POI data.
- When paired with [Map Address Facet](/facets/component-families/map-address-facet) and [Map Radius Facet](/facets/component-families/map-radius-facet), the map centers on the selected address, fits the selected radius, and draws a non-interactive radius circle.
## Example
```text
Map Facet:
- target = stores
- lat_meta_key = store_lat
- lng_meta_key = store_lng
Facet Target:
- target = stores
- used_with_map = true
Map POI inside loop:
- value = current post ID or slug
- lat = current item store_lat
- lng = current item store_lng
```
---
## Map Radius Facet
`Map Radius Facet` is an atomic choice control for proximity distance. It does not emit a facet clause by itself. The same-target [Map Address Facet](/facets/component-families/map-address-facet) combines the selected address coordinate and selected radius into `geo_radius`.
## Required Setup
- Use the same target ID on `Map Radius Facet`, [Map Address Facet](/facets/component-families/map-address-facet), [Map Facet](/facets/component-families/map-facet), and [Facet Target](/facets/component-families/facet-target).
- Add `Map Radius Facet Option` children with numeric radius values.
- Choose `Miles` or `Kilometers`; option values are interpreted in that unit.
- Set matching latitude and longitude meta keys on the address and map components.
## Props
| Group | Prop | Default | Meaning |
| -------- | --------------- | ------- | -------------------------------------------------------------- |
| Settings | `target` | empty | Shared target ID. |
| Settings | `unit` | `mi` | Interprets option values as miles (`mi`) or kilometers (`km`). |
| Settings | `default_value` | empty | Radius selected on load/reset. |
Option labels are authored manually. Use labels like `25 miles`, `40 km`, or any wording that fits the site.
## Runtime Behavior
Selecting a radius does not filter by itself. When a same-target address is selected, the address and radius controls emit `geo_radius` with the selected latitude, longitude, radius value, and unit. The paired map centers on the selected address, fits the selected radius, and draws the radius circle.
The public `ome:map-radius-change` event exposes a numeric radius snapshot or `null`. Its payload and its relationship to the same-target Map Address event are documented in the [Facet Events API](/facets/custom-events).
### Select dropdown floats
In select mode, the radius dropdown floats over the page via Etch's shared UIChoice host (the same floating mechanism used by the Select Facet). It no longer pushes page layout down when opened.
---
## Pagination Facet
# Pagination Facet
`Pagination Facet` controls the current page for a target. It renders hidden `offset` state and receives pagination metadata from facet responses.
## Props
| Group | Prop | Default | Meaning |
| --- | --- | --- | --- |
| Settings | `target` | empty | Shared target ID. |
| Settings | `sibling_count` | `1` | Numeric page buttons shown on each side of the current page. |
| Settings | `tag` | `nav` | Root wrapper tag. |
| Settings | `aria_label` | `Pagination` | Accessible navigation label. |
| Settings | `hide_when_single_page` | `true` | Hides pagination when only one page exists. |
| Settings | `scroll_to_top` | `false` | Scrolls to the target after pagination changes. |
| Labels | `prev_label` | `Previous` | Previous button label. |
| Labels | `next_label` | `Next` | Next button label. |
| Range | `show_range` | `true` | Shows the live range summary. |
| Range | `range_label` | `Showing` | Prefix for the range summary. |
| Styling | `class`, `range_class` | component defaults | Root and range summary classes. |
## Runtime Notes
- Pagination sends `offset` for the target.
- The sent `offset` is relative to the target's first rendered result. If the connected WP_Query loop has an authored `offset`, the server keeps that as the base and applies pagination after it.
- Responses update current page, total pages, total items, per-page, and offset.
- Changing a normal facet resets pagination to page 1.
- Pagination hides on zero results even when `hide_when_single_page` is false.
The multi-facet E2E scenario verifies pagination reset after a facet value changes.
---
## Radio List Facet
# Radio List Facet
`Radio List Facet` is a single-select option list. It renders a `radiogroup`, stores the selected value in a hidden input, and can include a built-in reset item before authored options.
## Authoring Structure
```text
Radio List Facet
└── Radio List Facet Option
```
## Parent Props
| Group | Prop | Default | Meaning |
| ----------- | --------------------------------- | ----------------------------------- | --------------------------------------------- |
| Settings | `target` | empty | Shared target ID. |
| Settings | `argument_mode` | `default` | Single argument mode. |
| Settings | `target_multiple_query_arguments` | `false` | Enables mapped bundle mode. |
| Settings | `options_behavior` | `all` | Availability behavior. |
| Settings | `show_counts` | `false` | Enables dynamic counts. |
| Settings | `aria_label` | `Filter options` | Accessible name for the radiogroup. |
| Reset | `show_reset_option` | `false` | Adds a reset choice before authored options. |
| Reset | `reset_option_mode` | `radio` | Reset item presentation: `radio` or `button`. |
| Reset | `reset_label` | `Reset selection` | Reset item label. |
| Mode groups | mode-specific props | varies | See [Argument Modes](/facets/argument-modes). |
| Styling | `class` | `ome-radio-list-facet-root-default` | Root list class. |
## Option Props
| Group | Prop | Default | Meaning |
| -------------------- | ----------------------------------------------- | ------------------ | ---------------------------------------------------------- |
| Content | `value` | empty | Sent value in single-argument mode. |
| Content | `label` | `Option` | Visible label. |
| Metadata | `key`, `value` | empty | Optional rows for custom JavaScript integrations. |
| Query Value Mappings | `mapping_key`, `value` | empty | Values used when parent mapped bundle mode is enabled. |
| Settings | `disabled` | `false` | Prevents selection. |
| Settings | `is_default` | `false` | Authored default or reset choice depending on reset setup. |
| Settings | `mode` | `radio` | Option presentation: `radio` or `button`. |
| Settings | `used_with_multiple_arguments` | `false` | Switches option authoring to query value mappings. |
| Settings | `count_display` | `inline` | Inline count text or separate count span. |
| Styling | option, button, indicator, label, count classes | component defaults | Option presentation classes. |
## Runtime Notes
- The public `ome:radio-list:change` selection snapshot and delegated-listener examples are documented in the [Facet Events API](/facets/custom-events).
- Only one option can be selected.
- The built-in reset option uses an empty value.
- `mode = button` changes presentation only; the facet remains single-select.
- The runtime manages `aria-checked`, roving focus, disabled state, selected state, and highlighted state.
---
## Reset Facet
# Reset Facet
`Reset Facet` clears active controls for a target and requests the unfiltered target state.
## Props
| Group | Prop | Default | Meaning |
| --- | --- | --- | --- |
| Settings | `target` | empty | Shared target ID. |
| Settings | `label` | `Reset filters` | Fallback button label when the default slot is empty. |
| Styling | `class` | `ome-reset-facet-default` | Button class. |
## Runtime Notes
- Reset Facet clears all registered facet controls for the same target.
- It also clears URL state for that target.
- Radio List's built-in reset option clears only that radio list selection. Reset Facet clears the whole target scope.
Use Reset Facet when users need one clear action for a complete faceted interface.
---
## Search Facet
# Search Facet
`Search Facet` renders a search input. Unlike option facets, it sends the typed value from the input instead of an authored option value.
## Props
| Group | Prop | Default | Meaning |
| ------------------------- | --------------------------------------- | -------------------------- | ------------------------------------------------------------ |
| Settings | `target` | empty | Shared target ID. |
| Settings | `placeholder` | `Search...` | Input placeholder. |
| Settings | `aria_label` | `Search` | Accessible name for the rendered search input. |
| Settings | `argument_mode` | `default` | Single argument mode when multi-argument search is disabled. |
| Settings | `target_multiple_query_arguments` | `false` | Renders a `query_bundle` search input when enabled. |
| Settings | `query_argument_relation` | `AND` | Relation for multi-argument search mappings. |
| Default Query Argument | `facet_key` | `search` | Query argument for default mode. |
| Meta Argument | `meta_key`, `meta_compare`, `meta_type` | ``, `LIKE`, `char` | Meta query settings. |
| Taxonomy Argument | `taxonomy`, `tax_field` | ``, `slug` | Taxonomy search settings. |
| Date Argument | `column` | `post_date` | Date query column. |
| ACF Relationship Argument | `meta_key` | empty | Relationship field stored on filtered posts. |
| Query Argument Mappings | `mapping_key`, mode-specific props | empty | Multi-argument search rows. |
| Styling | `class` | `ome-search-facet-default` | Input class. |
## Accessibility
Search Facet renders a native `type="search"` input with an `aria-label`. Keep the label specific to the target content when more than one search facet appears on a page.
## Default Query Keys
Search Facet supports filter-focused keys:
```text
search, p, title_like, name_like, post_type, category_name_like, tag_like, author, author_name_like, year, monthnum
```
Use Search Facet for text input and partial matching. Use an option facet when users should choose from known values.
## Multi-Argument Search
When `target_multiple_query_arguments` is true, the rendered input type is `query_bundle`. The typed value is copied into every row in `query_argument_mappings`.
```text
target_multiple_query_arguments = true
query_argument_relation = OR
query_argument_mappings:
- native-search -> default search
- priority -> meta facet_priority LIKE char
```
This makes one input search across native search and a meta field.
## ACF Relationship Search
ACF relationship mode expects numeric related post IDs. It filters the relationship field stored on the posts being filtered.
---
## SearchSelect Facet
# SearchSelect Facet
`SearchSelect Facet` is a searchable option selector. It is useful when the authored option set is large enough to need filtering inside the dropdown.
## Authoring Structure
```text
SearchSelect Facet
└── SearchSelect Facet Option
```
## Parent Props
| Group | Prop | Default | Meaning |
| ----------- | ------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------ |
| Settings | `target` | empty | Shared target ID. |
| Settings | `argument_mode` | `default` | Single argument mode. |
| Settings | `target_multiple_query_arguments` | `false` | Enables mapped bundle mode. |
| Settings | `options_behavior` | `all` | Availability behavior. |
| Settings | `show_counts` | `false` | Enables dynamic counts. |
| Settings | `selection_mode` | `single` | `single` or `multiple`. |
| Settings | `placeholder` | `Search...` | Search input placeholder. |
| Settings | `default_label` | `Select option...` | Text shown when nothing is selected. |
| Mode groups | mode-specific props | varies | See [Argument Modes](/facets/argument-modes). |
| Styling | `class`, `control_class`, `trigger_class`, `input_class`, `content_class`, `listbox_class`, `selection_class` | component defaults | Classes for the searchable select shell, popup, internal listbox, and selected-value text. |
## Option Props
| Group | Prop | Default | Meaning |
| -------------------- | ------------------------------ | ------------------ | ------------------------------------------------------ |
| Content | `value` | empty | Sent value in single-argument mode. |
| Content | `label` | `Option Label` | Visible label, search text, and pill label. |
| Metadata | `key`, `value` | empty | Optional rows for custom JavaScript integrations. |
| Query Value Mappings | `mapping_key`, `value` | empty | Values used when parent mapped bundle mode is enabled. |
| Settings | `disabled` | `false` | Prevents selection. |
| Settings | `used_with_multiple_arguments` | `false` | Switches option authoring to query value mappings. |
| Settings | `count_display` | `inline` | Inline count text or separate count span. |
| Styling | `class`, span count classes | component defaults | Option and count classes. |
## Runtime Notes
- Public `ome:search-select:open`, `ome:search-select:close`, `ome:search-select:input`, and `ome:search-select:change` payloads and examples are documented in the [Facet Events API](/facets/custom-events).
- The root stores selected state with `data-ome-selected-value` and `data-ome-selected-values`.
- `selection_mode = multiple` renders multiple selected values as removable selections.
- SearchSelect uses the shared search-select runtime plus facet-specific query binding.
- The popup contains a search input and an internal `listbox`. Older custom markup that places options directly in the popup is migrated into that listbox at runtime for compatibility.
- SearchSelect options do not expose an authored `is_default` prop in the current PHP component.
## CSS Custom Properties
| Property | Default | Meaning |
| --------------------------------------- | --------- | ------------------------------------------------------ |
| `--ome-search-select-placeholder-color` | `#64748b` | Placeholder text color for the search input. |
| `--ome-search-select-empty-color` | `#475569` | Empty-selection text color when no option is selected. |
## Example
```text
SearchSelect Facet:
- target = posts
- argument_mode = default
- facet_key = name
- placeholder = Search by slug
Option:
- value = beta-bar
- label = Beta Bar Post
```
---
## Select Facet
# Select Facet
`Select Facet` renders a custom listbox-style dropdown. It can select one value or multiple values, and it can either send one query clause or expand an option into a mapped bundle.
## Authoring Structure
```text
Select Facet
└── Select Facet Option
```
## Parent Props
| Group | Prop | Default | Meaning |
| ----------- | ------------------------------------------------------------------------------ | ------------------ | ---------------------------------------------- |
| Settings | `target` | empty | Shared target ID. |
| Settings | `argument_mode` | `default` | Single argument mode. |
| Settings | `target_multiple_query_arguments` | `false` | Enables mapped bundle mode. |
| Settings | `options_behavior` | `all` | Availability behavior. |
| Settings | `show_counts` | `false` | Enables dynamic counts. |
| Settings | `selection_mode` | `single` | `single` or `multiple`. |
| Settings | `tag` | `div` | Root wrapper tag. |
| Settings | `default_label` | `Select option...` | Trigger label and built-in clear option label. |
| Settings | `aria_label` | `Filter options` | Accessible name for the dropdown listbox. |
| Mode groups | mode-specific props | varies | See [Argument Modes](/facets/argument-modes). |
| Styling | `class`, `trigger_class`, `trigger_label_class`, `content_class`, `item_class` | component defaults | Classes for the dropdown shell and items. |
## Option Props
| Group | Prop | Default | Meaning |
| -------------------- | ------------------------------ | ------------------ | ------------------------------------------------------ |
| Content | `value` | empty | Sent value in single-argument mode. |
| Content | `label` | `Option Label` | Visible option label. |
| Metadata | `key`, `value` | empty | Optional rows for custom JavaScript integrations. |
| Query Value Mappings | `mapping_key`, `value` | empty | Values used when parent mapped bundle mode is enabled. |
| Settings | `disabled` | `false` | Prevents selection. |
| Settings | `is_default` | `false` | Initial selected option when no restored value exists. |
| Settings | `used_with_multiple_arguments` | `false` | Switches option authoring to query value mappings. |
| Settings | `count_display` | `inline` | Inline count text or separate count span. |
| Styling | `class`, span count classes | component defaults | Option and count classes. |
## Runtime Notes
- Public `ome:select:open`, `ome:select:close`, and `ome:select:change` payloads and examples are documented in the [Facet Events API](/facets/custom-events).
- The root stores selected state in `data-ome-selected-value` and `data-ome-selected-values`.
- Single selection uses one value. Multiple selection serializes multiple values for the same facet key.
- A built-in empty option uses `__ome-empty__` internally and clears the selection.
- In mapped bundle mode, option `query_value_mappings` must match parent `query_argument_mappings` by `mapping_key`.
- The popup content owns the `listbox` semantics and uses `settings.aria_label` as its accessible name.
## Example
```text
Select Facet:
- target = products
- argument_mode = default
- facet_key = category_name
- selection_mode = single
Option:
- value = shoes
- label = Shoes
```
---
## Woo Components
Woo components let you build WooCommerce product, cart, checkout, account, and order-received screens with Etch blocks. WooCommerce still owns products, carts, shipping, payment, orders, and Store API requests. OhMyEtch gives you component pieces you can place, style, and compose.
## Start With A View
Pick the customer-facing screen you want to build first:
| I want to build... | Start here |
| --- | --- |
| A shop or product listing | [Product Archive](/woo/flows/product-archive) |
| A single product page | [Single Product](/woo/flows/single-product) |
| A cart page | [Cart Page](/woo/flows/cart-page) |
| A checkout page | [Checkout Page](/woo/flows/checkout-page) |
| An account area | [My Account Page](/woo/flows/my-account-page) |
| The thank-you screen after checkout | [Order Received Page](/woo/flows/order-received-page) |
Those guides show the minimum working structure first. Use the reference pages after you know which view you are composing.
## The Basic Pattern
Most Woo screens follow the same pattern:
1. Put the right parent component on the page.
2. Place the child components inside the parent slot.
3. Bind product, cart, or checkout data from the current context.
4. Style with class props; keep JavaScript integrations on Woo custom events.
The most important context rule is simple:
| Context | Use |
| --- | --- |
| Inside a product loop | `{item.*}` and `{item.omewoo.*}` |
| On a single product template | `{this.*}` and `{this.omewoo.*}` |
| Inside `CartItems` | Cart item atoms read the current cart row. |
| Inside `CheckoutProvider` / `CheckoutForm` | Checkout controls read the checkout scope. |
Read [Data Context and Dynamic Sources](/woo/data-context-and-dynamic-sources) when you need the full data map.
## Component Families
| Component family | Relationship |
| --- | --- |
| Product purchase | Optional structural `ProductProvider` owns shared product/variation state. `AddToCartForm` owns the purchase draft and Add action; Provider-scoped `ProductCartQuantity` separately reads and mutates the confirmed quantity already in the cart. |
| Cart items | `CartItems` owns the item loop. `CartItemImage`, `CartItemTitle`, `CartItemPrice`, `CartItemSubtotal`, `CartItemQuantity`, `CartItemRemove`, and `CartAttributeList` read the current row. |
| Cart attributes | `CartAttributeList` loops the selected variation attributes for a cart item. `CartAttributeName` and `CartAttributeValue` read each attribute row. |
| Totals | `CartTotalsList` and `OrderSummaryTotalsList` provide layout. The total atoms render `total_items`, `total_discount`, `total_shipping`, `total_tax`, and `total_price`. |
| Coupons | `CouponForm` mutates the cart. `CouponAppliedList` renders active coupon rows. `CouponRemoveButton` belongs inside each coupon row. |
| Checkout | `CheckoutProvider` scopes checkout UI. `CheckoutForm` serializes fields and submits. Address forms, payment selector, terms, notices, and place-order controls belong inside that checkout scope. |
| Order summary | `OrderSummary` renders read-only cart rows and totals for checkout; it intentionally reuses cart item atoms and totals atoms. |
| My Account | `AccountProvider` owns one slot per account endpoint and switches between them. Auth forms post to core handlers; orders, addresses, details, payment methods, and downloads read the account dynamic sources. |
| Order received | `OrderReceivedProvider` switches the checkout page between the in-progress checkout and the received order. The received components read the validated `receivedOrder` source. |
Use [Component Families](/woo/component-families/product-purchase) when you want the prop-level reference for a specific group.
## Routes Still Matter
Woo starters also need to own Woo's WordPress routes, not only the component
trees. Read [Woo Template Integration Contract](/woo/flows/template-integration-contract)
before publishing starter guidance for `archive-product`, `single-product`,
cart, checkout, order confirmation, or product taxonomy archives.
## What WooCommerce Still Owns
Woo components use WooCommerce Store API for cart and checkout actions. Native Woo hooks still run through those Store API paths, so Woo extensions that adjust validation, pricing, cart data, checkout data, payment handling, or order status can stay involved.
## Start Here
1. Build one complete screen with [Product Archive](/woo/flows/product-archive), [Single Product](/woo/flows/single-product), [Cart Page](/woo/flows/cart-page), [Checkout Page](/woo/flows/checkout-page), [My Account Page](/woo/flows/my-account-page), or [Order Received Page](/woo/flows/order-received-page).
2. Use [Recipes](/woo/recipes) for focused tasks such as a product card, coupon form, or shipping selector.
3. Use [Woo Custom Events](/woo/custom-events) for mini-cart drawers, analytics, cart refresh integrations, or checkout instrumentation.
4. Use [Data Context and Dynamic Sources](/woo/data-context-and-dynamic-sources) before composing loops or binding `{item.*}` and `{this.*}` values.
5. Use [Component Families](/woo/component-families/product-purchase) when authoring a specific component group.
6. Read [Woo Template Integration Contract](/woo/flows/template-integration-contract) before creating a complete starter.
7. Run a multilingual or multicurrency store? Read [Multilingual and Multicurrency (WPML/WCML)](/woo/multilingual-and-multicurrency) for the supported setup.
---
## Product Archive
A product archive is a list of Woo products. Build it with a normal product loop, then place Woo purchase components inside each loop item.
## Minimum Structure
```text
Archive template
CartCount
CartNotices
Product loop over product posts
Product image
Product title
ProductProvider bound to {item.omewoo}
ProductPrice, ProductSku, ProductAvailability, ProductDescription
AddToCartForm
AttributeSelector loop for variable products
AddToCartButton
```
Use `{item.*}` because each product card is inside the loop.
{`{#loop products as item}
Product image: {item.omewoo.media.image.url}
Product title: {item.title}
{#slot default}
{#slot default}
{#loop item.omewoo.attributes as attribute}
{/loop}
{/slot}
{/slot}
{/loop}`}
## Step 1: Create A Product Loop
The archive page or `archive-product` template needs a loop that queries Woo `product` posts. Inside that loop, the current product is available as `item`.
| Binding | Meaning |
| --- | --- |
| `{item.id}` | Current product ID. |
| `{item.title}` | Current product title. |
| `{item.omewoo.media.image.url}` | Product image URL. |
| `{item.omewoo.media.image.alt}` | Product image alt text. |
| `{item.omewoo.price.html}` | Server-formatted price HTML for Product Price. |
| `{item.omewoo.product.sku}` | Base SKU for Product SKU. |
| `{item.omewoo.purchase.availabilityHtml}` | Woo availability HTML for Product Availability. |
| `{item.omewoo.description.shortHtml}` | Short base content for Product Description. |
| `{item.omewoo.product.type}` | Product type used by purchase controls. |
| `{item.omewoo.attributes}` | Variable-product attribute objects for selector loops. |
| `{item.omewoo.variants}` | Variation catalogue used by variable product forms. |
## Step 2: Put Product Purchase Inside The Card
Bind one `ProductProvider` per card to the complete `{item.omewoo}` object when multiple product atoms need the same selected-variation state. The nearest-provider rule keeps repeated cards isolated.
The Provider is a real structural card container, so choose its `structure.tag` and use `styling.class` for card layout. Product readouts may sit directly in its default slot; only setters and purchase actions need the nested `AddToCartForm` boundary.
Use `AddToCartForm` inside that Provider when the card has a real purchase area. The form owns the product ID, product type, variation setters, and submit state. The add-to-cart button should use `trigger=form_submit` inside that form.
For simple products, a standalone `AddToCartButton` can work outside a form if you pass `behavior.standalone_product.product_id`. Existing archive forms without a Provider also remain supported. For mixed product lists, the Provider plus form pattern is easier because it shares derived variation state while retaining the released purchase flow.
## Step 3: Add Variation Selectors When Needed
Variable products expose selector rows under `{item.omewoo.attributes}`. Loop that array inside the form and pass each row into `AttributeSelector`.
The selector writes the selected option back into the nearest `AddToCartForm`. The form waits for required variation choices before it sends the add-to-cart request.
## Step 4: Keep Cart Feedback Outside The Cards
`CartCount` is placed above the product loop so successful add-to-cart actions from any card update one shared count. `CartNotices` is also outside the product cards, which gives the archive one live region for errors and success messages.
This pairing matters because product cards can be repeated many times, but cart state is global for the page.
## Next References
- [Product Purchase](/woo/component-families/product-purchase) explains `AddToCartForm`, `AttributeSelector`, `AddToCartButton`, `VariationResetButton`, and `BuyNowButton`.
- [Cart State and Notices](/woo/component-families/cart-state-and-notices) explains `CartCount` and `CartNotices`.
- [Data Context and Dynamic Sources](/woo/data-context-and-dynamic-sources) explains when to use `{item.*}` and `{this.*}`.
- [Woo Template Integration Contract](/woo/flows/template-integration-contract) explains the `archive-product` route.
---
## Single Product
A single product template renders one Woo product: the product WordPress is currently resolving. Build it with `{this.*}` and `{this.omewoo.*}` values.
## Minimum Structure
```text
Single product template
CartCount
CartNotices
Product image
Product title
ProductProvider bound to {this.omewoo}
ProductPrice, ProductSku, ProductAvailability, ProductDescription
AddToCartForm
AttributeSelector loop for variable products
AddToCartButton
BuyNowButton
```
The current product is the WordPress queried object. That makes `{this.id}`, `{this.title}`, and `{this.omewoo.*}` the correct bindings.
{`Product image: {this.omewoo.media.image.url}
Product title: {this.title}
{#slot default}
{#slot default}
{#loop this.omewoo.attributes as attribute}
{/loop}
{/slot}
{/slot}
`}
## Step 1: Use Current Product Data
| Binding | Meaning |
| --- | --- |
| `{this.id}` | Current product ID. |
| `{this.title}` | Current product title. |
| `{this.omewoo.media.image.url}` | Main product image URL. |
| `{this.omewoo.media.image.alt}` | Main product image alt text. |
| `{this.omewoo.price.html}` | Server-formatted product price HTML for Product Price. |
| `{this.omewoo.product.sku}` | Base SKU for Product SKU. |
| `{this.omewoo.purchase.availabilityHtml}` | Woo availability HTML for Product Availability. |
| `{this.omewoo.description.html}` / `.shortHtml` | Full or short base content for Product Description. |
| `{this.omewoo.product.type}` | Product type passed into the form. |
| `{this.omewoo.attributes}` | Attribute objects used by variable product selectors. |
| `{this.omewoo.variants}` | Variation catalogue used by variable product forms. |
Use `{this.*}` only when the template is actually rendered in a product context. In loops, use `{item.*}` instead.
## Step 2: Build The Purchase Form
Bind `ProductProvider.product` to the complete `{this.omewoo}` object. The Provider is a structural shared-state container: choose its root element with `structure.tag` and style or lay it out through `styling.class`. It does not replace the form or render product UI by itself.
Place Product Price, SKU, Availability, and Description inside that structural container when they should follow the selected variation. Their content props keep SSR and editor preview useful; the Provider adds runtime synchronization. The readouts do not need to be inside `AddToCartForm`, because they are derived presentation rather than setters.
`AddToCartForm` should receive the current product ID and product type:
| Form value | Source |
| --- | --- |
| `product_id` | `{this.id}` |
| `product_type` | `{this.omewoo.product.type}` |
| `variants` | `{this.omewoo.variants}` for variable products. |
| `variation_id` | Usually empty; selectors resolve selected variation state. |
The add-to-cart button belongs inside the form and should use `trigger=form_submit`. That keeps simple products, variable products, quantity, add-to-cart, and buy-now behavior on the same payload. Existing standalone forms without `ProductProvider` remain supported.
## Step 3: Add Variation Selectors
For variable products, loop over `{this.omewoo.attributes}` and place `AttributeSelector` components inside the form. Each selector writes its selected value into the nearest form. When the product has more than one variation attribute, the form uses `{this.omewoo.variants}` to resolve the final variation after every required option is selected.
Choose `color-swatch` or `image-swatch` for attributes that benefit from a visual choice. Swatches still submit the same exact Woo attribute values and variation IDs as the released select/radio/button modes. Custom visual mappings use scoped CSS on `data-ome-value`; unresolved mappings keep honest option text. See [Color And Image Swatches](/woo/component-families/product-purchase#color-and-image-swatches).
Use `VariationResetButton` inside the same form when customers need a clear way to reset all attribute choices.
## Step 4: Add Quantity And Buy Now
`AddToCartButton` in `counter` mode renders a quantity control and submit button. Its default `input` presentation preserves the released number field. Set `behavior.counter_presentation=stepper` for decrement, read-only value, and increment controls.
Both presentations edit a local purchase draft; only Add to cart mutates Woo. Stepper presentation inside `ProductProvider` follows the resolved product or variation's Woo minimum, maximum, step, sold-individually rule, availability, and finite-stock limit. Authored quantity props may tighten those rules. A variation change preserves and normalizes the current stepper draft instead of resetting it, while an unresolved required selection keeps Add disabled. The default input presentation preserves its released integer normalization and authored-limit behavior. See [Purchase Draft Quantity](/woo/component-families/product-purchase#purchase-draft-quantity).
`BuyNowButton` also belongs inside `AddToCartForm`. It serializes the same form payload, adds the product to the cart, then redirects to the authored checkout URL or the localized Woo checkout URL.
Do not use `BuyNowButton` as a standalone checkout link. Its behavior depends on the parent form state, especially for variable products.
## Next References
- [Product Purchase](/woo/component-families/product-purchase) lists the purchase component props.
- [Data Context and Dynamic Sources](/woo/data-context-and-dynamic-sources) explains current-product bindings.
- [Woo Dynamic Data Tree](/woo/woo-dynamic-data-tree) lists every `this.omewoo` field.
- [Woo Template Integration Contract](/woo/flows/template-integration-contract) explains the `single-product` route.
---
## Cart Page
A cart page lets customers review products, change quantities, remove items, apply coupons, choose shipping, and move to checkout.
## Minimum Structure
```text
Cart page
CartNotices
CartItems
CartItemImage
CartItemTitle
CartAttributeList
CartAttributeName
CartAttributeValue
CartItemPrice
CartItemQuantity
CartItemSubtotal
CartItemRemove
Empty slot
CouponForm
CouponAppliedList
CouponRemoveButton
ShippingMethodSelector
CartTotalsList
CartAmount (items subtotal)
CartAmount (discount)
CartAmount (fees)
CartAmount (shipping)
CartAmount (tax)
CartAmount (final total)
Checkout link or button
```
{`
{#slot default}
{#slot default}
{/slot}
{/slot}
{#slot empty}
Your cart is empty.
{/slot}
{#slot default}
{/slot}
`}
## Step 1: Add Cart Rows
`CartItems` renders the current Store API cart items into the default slot. Cart item atom components do not query global cart state by themselves; they read the row context that `CartItems` hydrates.
This is why item atoms should be authored inside the `CartItems` default slot:
| Atom | Row value |
| --- | --- |
| `CartItemImage` | Current item image and alt fallback. |
| `CartItemTitle` | Current item title, optionally with attributes. |
| `CartAttributeList` | Current item variation/attribute list. |
| `CartItemPrice` | Current item unit price text. |
| `CartItemQuantity` | Current item quantity input and update action. |
| `CartItemSubtotal` | Current item subtotal text. |
| `CartItemRemove` | Current item remove action. |
If the cart becomes empty, `CartItems` swaps to the `empty` slot.
## Step 2: Let Row Actions Refresh The Cart
`CartItemQuantity` and `CartItemRemove` both send Store API cart mutation requests through the cart store. After a successful mutation, the normalized cart response updates:
- cart item rows,
- `CartCount`,
- coupon list,
- shipping rates,
- cart total atoms,
- notices.
Quantity edits are local drafts until Woo confirms them. Rapid same-row edits collapse to the newest absolute quantity, while different cart operations retain FIFO order. The quantity input stays editable during its short debounce; the shared count and totals do not change optimistically. Debounced-away and already-satisfied targets emit no events. Every real authoritative response emits `ome-woo:item-quantity-updated` followed by `ome-woo:cart-updated`, but the control shows and announces success only when the latest target is confirmed.
Set `configuration.counter_presentation="stepper"` on `CartItemQuantity` when the design needs decrease and increase buttons around a read-only count. The default remains the released number input. Both presentations use the same exact-line setter and Woo-provided minimum, maximum, multiple, editability, and sold-individually constraints; neither turns zero into removal.
Style local progress with `data-ome-woo-mutation-phase="debouncing|queued|pending|success|error|idle"`. Existing `data-ome-state="loading|success|error|idle"` selectors continue to work.
## Step 3: Add Coupons
`CouponForm` applies a coupon code. `CouponAppliedList` renders the current applied coupons, and `CouponRemoveButton` belongs inside each coupon row. The cart demo keeps `CartNotices` near the top of the page so cart errors share one cart-level feedback region. If a page omits Cart Notices, the runtime announces the final safe error through one visually hidden assertive fallback; it does not create duplicate feedback when Cart Notices is authored. Final confirmed quantity and removal results use one polite announcement; intermediate targets and internal scheduling phases are not narrated.
## Step 4: Add Shipping And Totals
`ShippingMethodSelector` uses the same UIChoice-backed modes as checkout selectors. Use it when the cart needs a selectable shipping rate before checkout. The selected Store API shipping rate refreshes total values.
`CartTotalsList` renders authored total rows. For new work, add one `CartAmount` per shopper measure and reorder or wrap those rows as needed. `tax_presentation="store"` follows the WooCommerce cart tax-display setting for subtotal, discount, fees, and shipping; explicit `including_tax` and `excluding_tax` presentations are also available for those four measures.
Shipping has two intentionally different zero-like cases. Calculated free shipping renders the formatted currency zero. Required shipping that has not been calculated renders `Not calculated` with `data-ome-state="pending"`; the direct final total remains visible with `data-ome-state="estimated"` until shipping resolves.
`TotalsSubtotal`, `TotalsDiscount`, `TotalsShipping`, `TotalsTax`, and `TotalsTotal` remain available as unchanged legacy atoms for existing designs. Do not silently replace saved atoms: their flat raw fields and compatibility formatting are not equivalent to Cart Amount's shopper-facing tax and pending-state behavior.
## Step 5: Link To Checkout
The checkout URL should point to the page assigned in WooCommerce as `woocommerce_checkout_page_id`. Read [Woo Template Integration Contract](/woo/flows/template-integration-contract) before building a starter that owns cart and checkout routes.
## Next References
- [Cart Items](/woo/component-families/cart-items) explains cart row atoms.
- [Coupons](/woo/component-families/coupons) explains coupon apply and remove components.
- [Shipping Selector](/woo/component-families/shipping-selector) explains shipping modes and package-aware values.
- [Cart Totals](/woo/component-families/cart-totals) explains total atoms.
---
## Checkout Page
A checkout page collects customer details, shipping, payment, terms acceptance, and order submission. Build it with one checkout scope and keep the order summary read-only.
## Minimum Structure
```text
CheckoutProvider
CheckoutForm
BillingAddressForm
ShippingAddressForm
ShippingMethodSelector
PaymentMethodSelector
TermsCheckbox
CheckoutNotices
PlaceOrderButton
OrderSummary
Product rows
Totals rows
```
{`
{#slot default}
{#slot default}
{/slot}
{/slot}
`}
## Step 1: Put Checkout On The Woo Checkout Page
The OME checkout must live on the configured Woo checkout page. Authors should use a dedicated Woo checkout page or template that contains an `OmeWooCheckoutProvider` or `OmeWooCheckoutForm` shell, not a generic page mixed with the native Woo checkout block.
When the configured checkout page contains an OME checkout shell, Etch disables Woo's empty-PHP-cart redirect for that page request. That lets a cart created with Store API `Cart-Token` and `Nonce` session headers survive hard navigation to checkout: the server renders the checkout shell, then the browser runtime restores cart and checkout state through Store API requests.
Classic checkout pages and non-checkout pages keep Woo's native empty-cart redirect. Order-pay and order-received endpoints also keep Woo's native routing behavior.
## Step 2: Add Provider And Form
`CheckoutProvider` creates the checkout scope. `CheckoutForm` owns the submit event and the final Store API checkout request.
Put address forms, selectors, terms, notices, and place-order controls inside `CheckoutForm`. `OrderSummary` can sit inside the provider but does not need to be inside the form.
## Step 3: Add Address Forms
`BillingAddressForm` and `ShippingAddressForm` share address form props and markup generation. They render fields from the checkout field schema, not from hard-coded field lists in the docs.
The checkout runtime handles:
- required billing fields,
- email validation,
- country and state selectors,
- state field visibility when the selected country has no state options,
- the shipping-address toggle and its embedded field group,
- local blocking before Store API submit when known-invalid fields are present.
## Step 4: Add Shipping And Payment Selectors
`ShippingMethodSelector` and `PaymentMethodSelector` use the shared UIChoice mode logic. Both support select and button-radio presentation. In checkout, selected values are written into checkout state before the form is submitted.
Shipping method options come from package-aware Store API rates. Payment options come from enabled supported Woo payment methods.
## Step 5: Add Terms, Notices, And Submit
`TermsCheckbox` blocks submit when it is required and unchecked. `CheckoutNotices` renders checkout-scoped error messages. `PlaceOrderButton` triggers the parent `CheckoutForm`.
The form sets `data-ome-state` during validation, pending submit, success, and error states so authors can style the visible state without replacing the native Woo order lifecycle.
## Step 6: Add An Order Summary
`OrderSummary` is read-only. It renders current cart products and totals inside checkout, but it does not submit or mutate checkout data. Use the default `propped` mode for a quick summary, or atom modes when you want to author product rows and totals yourself.
| Mode | Use it when |
| --- | --- |
| `propped` | You want the component to render its own summary structure. |
| `product_atoms` | You want to author product rows but keep totals managed by the summary. |
| `full_atoms` | You want to author product rows and totals with cart item and total atoms. |
This reuse keeps cart and checkout total display aligned with the same normalized cart data.
## Step 7: Keep Woo's Checkout Lifecycle
Checkout submission goes through Woo Store API checkout. Woo's native checkout hooks still run through that path, including order update and payment processing hooks.
That means Etch components can be authored visually while Woo plugins that rely on native checkout hooks still see the checkout lifecycle.
## Next References
- [Checkout Shell](/woo/component-families/checkout-shell) explains provider, form, notices, and place-order props.
- [Checkout Address Forms](/woo/component-families/checkout-address-forms) explains billing and shipping fields.
- [Shipping Selector](/woo/component-families/shipping-selector) and [Payment Selector](/woo/component-families/payment-selector) explain selector modes.
- [Order Summary](/woo/component-families/order-summary) explains summary modes.
- [Checkout Fields and Validation](/woo/checkout-fields-and-validation) explains Woo field schema and validation behavior.
- [Woo Template Integration Contract](/woo/flows/template-integration-contract) explains assigned checkout pages and route ownership.
---
## Data Context and Dynamic Sources
Most Woo authoring issues come from using the right component in the wrong data context. Start with the prefix, then choose the component.
## Product Data: `item` vs `this`
Product data is exposed under `omewoo` when the current post is a Woo product.
| Where you are | Use this prefix | Example |
| --- | --- |
| Product archive or product loop | `{item.*}` | `{item.id}`, `{item.title}`, `{item.omewoo.price.text}` |
| Single product template | `{this.*}` | `{this.id}`, `{this.title}`, `{this.omewoo.price.text}` |
Use the same field names in both contexts. Only the prefix changes.
`ProductProvider` is the one component that receives the complete object directly: use `{item.omewoo}` inside a product loop and `{this.omewoo}` on a single product template. Do not rebuild a partial object for it.
{`{#loop products as item}
Product title: {item.title}
Product price: {item.omewoo.price.text}
{#slot default}
{/slot}
{/loop}`}
{`Product title: {this.title}
Product price: {this.omewoo.price.text}
{#slot default}
{/slot}
`}
## Common Product Fields
| Expression | Use |
| --- | --- |
| `{item.id}` or `{this.id}` | Product ID for `AddToCartForm.product.product_id`. |
| `{item.omewoo.product.type}` or `{this.omewoo.product.type}` | Product type for `AddToCartForm.product.product_type`. |
| `{item.omewoo.price.text}` or `{this.omewoo.price.text}` | Formatted price text. |
| `{item.omewoo.media.image.url}` or `{this.omewoo.media.image.url}` | Main product image URL. |
| `{item.omewoo.media.image.alt}` or `{this.omewoo.media.image.alt}` | Main product image alt text. |
| `{item.omewoo.media.gallery}` or `{this.omewoo.media.gallery}` | Ordered base media collection for `ProductMedia.media`. |
| `{item.omewoo.media.variationGalleries}` or `{this.omewoo.media.variationGalleries}` | Selector-aware variation galleries consumed through the nearest `ProductProvider`. |
| `{item.omewoo.attributes}` or `{this.omewoo.attributes}` | Variable-product attributes for `AttributeSelector`. |
| `{item.omewoo.variants}` or `{this.omewoo.variants}` | Variation catalogue for `AddToCartForm` variation resolution. |
Keep gallery-aware UI and purchase UI on separate data paths. Bind `omewoo.media.image.id` to a hero `ProductImage`, `omewoo.media.gallery` to `ProductMedia`, and pass the complete `omewoo` object to the nearest `ProductProvider` so it can resolve `media.variationGalleries`. Continue using `omewoo.variants` only for `AddToCartForm` variation resolution.
See [Woo Dynamic Data Tree](/woo/woo-dynamic-data-tree) for the full field-by-field reference.
## Product Provider Scope
`OmeWooProductProvider` stores the base product and derived variable-product selection state for its nearest descendants. It is a real structural DOM container and supports only simple and variable products. Use `structure.tag` to choose the root tag and `styling.class` to control its layout and presentation.
```etch
{#slot default}
...
{/slot}
```
In a product loop, replace `this` with `item` and render one Provider per loop item. A nested Provider is an isolation boundary; descendants never read selection state from an outer Provider. The Provider exposes derived read-only state, while `AttributeSelector`, `VariationResetButton`, quantity, and cart mutation controls remain scoped to `AddToCartForm`.
`ProductImage` and `ProductMedia` also use the nearest Provider. Product Media selection changes the Provider's active image only; it does not change the current variation or submit anything. Both atoms preserve their authored server-rendered output when used without a valid Provider, with a development-only warning explaining how to enable synchronization.
Standalone `AddToCartForm` remains valid. It uses the same variation-selection controller internally and keeps its released DOM and submit contracts.
## Variation Post Context
When the queried post is Woo's native `product_variation`, `omewoo` describes that variation. Its `media.gallery` describes the current variation, while `media.variationGalleries`, `attributes`, and `variants` stay empty because selector maps belong to the parent variable product. Variation templates should use `parentProduct` for parent identity and `selectedAttributes` for displayable selected values.
| Expression | Use |
| --- | --- |
| `{this.omewoo.parentProduct}` | Parent product identity when the current post is a Woo variation. |
| `{this.omewoo.selectedAttributes}` | Displayable selected variation attributes. |
| `{this.omewoo.selectedAttributesMap}` | Normalized selected variation values keyed by Store API attribute key. |
## Cart Dynamic Sources
`CartItemsDynamicSource` registers four source keys when the block tree contains cart-aware components or expressions:
| Source | Shape |
| --- | --- |
| `cartItems` | Cart item rows with `key`, compatibility `productId`, additive exact `purchasableId`, title fields, attributes, quantity, additive `quantityLimits`, URL, price text, subtotal text, and image data. |
| `cartSummary` | `item_count`, `line_count`, and `state` where state is `has-items` or `empty`. |
| `cartTotals` | Released flat total fields plus the additive `cartAmount` lane for tax-aware shopper measures, nullable shipping state, and currency metadata. |
| `cartCoupons` | Applied coupon rows with `code`. |
The source registration is lazy. A page that does not render cart components does not register cart sources for that request.
For new total readouts, use `OmeWooCartAmount`. Its server-rendered source at `cartTotals.cartAmount` mirrors Store API minor-unit totals: split `total_items`/`total_items_tax`, `total_discount`/`total_discount_tax`, `total_fees`/`total_fees_tax`, nullable `total_shipping`/`total_shipping_tax`, direct `total_tax`, direct `total_price`, shipping calculation flags, normalized tax display, and currency metadata. The component keeps this server-rendered output until the Cart Store confirms hydration.
The existing flat `cartTotals` fields remain unchanged for the five released fixed total atoms. Those compatibility fields can expose a positive discount and missing-value-to-zero behavior, so they are not silently migrated into the shopper-tax-aware lane. See [Cart Totals](/woo/component-families/cart-totals) for the component choice and exact state rules.
## Cart Item Hydration
`CartItems` renders one authored row template. Server render and runtime both hydrate the row's atoms:
| Atom marker | Data field |
| --- | --- |
| `data-ome-woo-cart-item-field="image"` | Product image URL, srcset, and alt text with authored fallback. |
| `data-ome-woo-cart-item-field="title"` | Product title or composed variant title. |
| `data-ome-woo-cart-item-field="priceText"` | Unit price text. |
| `data-ome-woo-cart-item-field="subtotalText"` | Line subtotal text. |
| `data-ome-woo-cart-item-quantity` | Canonical quantity input value, exact cart item key, and Woo quantity limits. |
| `data-ome-woo-cart-item-quantity-stepper` | Opt-in decrease/value/increase presentation backed by the canonical exact-line input. |
| `data-ome-woo-cart-item-remove` | Remove button cart item key. |
| `data-ome-woo-cart-attribute-list` | Selected variation attributes cloned from the attribute template. |
This is why cart item atoms are meaningful only inside a cart item row or an order summary row.
`productId` keeps its released compatibility semantics unchanged. `purchasableId` is the explicit exact identity used for product-level cart matching: the variation ID for a variation line, otherwise the simple product ID. Existing consumers do not need to migrate, and standard lines may expose the same value in both fields. `ProductCartQuantity` uses the additive field conservatively and disables mutation when more than one line matches; it does not infer plugin-defined bundle, composite, add-on, or custom line identity.
## Selector Sources
`WooSelectorDynamicSource` registers selector rows while blocks render:
| Source | Used by |
| --- | --- |
| `shippingRates` | `ShippingMethodSelector` rows. |
| `paymentMethods` | `PaymentMethodSelector` rows and runtime config. |
Shipping rates use package-aware values. The row value is `{package_id}:{rate_id}`, while the hidden input keeps the raw Woo rate ID and package-specific input name. This lets Woo distinguish rates across packages.
Payment methods only include enabled simple gateways. Gateways with custom fields are skipped by `get_simple_payment_methods()`, because this selector renders simple radio/select choices rather than gateway-specific embedded forms.
## Checkout Field Schema
`CheckoutFieldSchema::build()` reads Woo countries, checkout fields, locale overrides, states, and store defaults. The runtime uses that schema to:
- Render country options.
- Switch state between select, text, and hidden modes.
- Apply Woo labels, required flags, hidden flags, field types, autocomplete, and priorities.
- Validate rendered fields before Store API submit.
Address forms still expose copy props, but `use_woo_defaults: true` keeps Woo's field copy as the default source.
## Dynamic Data Examples
Variable selector loop on a single product:
```etch
{#loop this.omewoo.attributes as attribute}
{/loop}
```
The same selector loop inside a product archive card uses `item`:
```etch
{#loop item.omewoo.attributes as attribute}
{/loop}
```
---
## Woo Recipes
Recipes are short examples for one job at a time. For complete page composition, start with [Product Archive](/woo/flows/product-archive), [Single Product](/woo/flows/single-product), [Cart Page](/woo/flows/cart-page), [Checkout Page](/woo/flows/checkout-page), [My Account Page](/woo/flows/my-account-page), or [Order Received Page](/woo/flows/order-received-page).
For complete starter route ownership, read
[Woo Template Integration Contract](/woo/flows/template-integration-contract)
before composing individual recipes. It covers the `archive-product`,
`single-product`, cart, checkout, order confirmation, taxonomy archive, and Woo
page option contract that these component recipes assume.
## Product Archive Card
Use a product loop and bind each card with `{item.*}`:
{`{#loop products as item}
{#slot default}
{/slot}
{/loop}`}
Why it works: the form owns product ID/type and form submission; the button is a submit control inside the form. Add `CartCount` above the loop when the archive should show a live cart count.
## Single Product Quantity
Use `{this.*}` on a single product template and set button quantity bounds:
{`
{#slot default}
{/slot}
`}
Why it works: `counter` mode renders a quantity input, and the form-submit trigger keeps quantity and product data on the parent form payload.
## Variable Product Selector
Loop over product attributes and bind each `AttributeSelector` to the current attribute object:
{`
{#slot default}
{#loop this.omewoo.attributes as attribute}
{/loop}
{/slot}
`}
Why it works: the selector writes selected variation attribute state into the purchase form. The form blocks submit until required variation options are selected, and unavailable options do not select. For products with more than one variation attribute, `product.variants` lets the runtime resolve the final `variation_id` from the complete selected combination, such as `Color = Blue` plus `Size = Small`.
## Color Swatch Selector
Switch only the appropriate attribute to swatches in Etch, then map exact option slugs in scoped CSS:
{` `}
{`[data-ome-woo-attribute-selector][data-ome-ui-choice-mode="color-swatch"]
[data-ome-value="forest"] {
--ome-woo-swatch-color: #234f32;
--ome-woo-swatch-fallback-display: none;
}`}
If `forest` is not mapped, its text remains visible. Do not hide the fallback globally. See [Product Purchase](/woo/component-families/product-purchase#color-and-image-swatches) for image mappings, light-color borders, keyboard behavior, and stable Woo variation-image rules.
## Cart Rows and Empty State
Place cart item atoms inside the `CartItems` default slot and empty content inside the `empty` slot:
{`
{#slot default}
{/slot}
{#slot empty}
Your cart is empty.
{/slot}
`}
Why it works: `CartItems` owns the repeated cart row. The item atoms read the current row that `CartItems` hydrates.
## Coupons
Use `CouponForm` to apply codes, `CouponAppliedList` to render current coupons, and `CouponRemoveButton` inside the coupon row:
{`
{#slot default}
{/slot}
`}
Why it works: `CouponRemoveButton` reads the coupon code from the row generated by `CouponAppliedList`.
## Shipping Methods
Use `ShippingMethodSelector` wherever cart shipping selection should be available:
{` `}
Why it works: the selector uses package-aware rate values, so Woo can distinguish shipping rates across packages.
## Checkout Shell
Use a provider, a form, address forms, selectors, terms, notices, and place order:
{`
{#slot default}
{#slot default}
{/slot}
{/slot}
`}
Why it works: `CheckoutProvider` creates the checkout scope, `CheckoutForm` owns serialization and submission, and `PlaceOrderButton` submits the parent form.
## Native Hook Compatibility
Use the same components as normal. The important point is that Store API requests still run Woo hooks:
- Add-to-cart validation can block the Etch form and render a Woo notice.
- Add-to-cart hooks can inject cart item data.
- Pricing hooks can change totals rendered by cart and order summary components.
- Checkout hooks can update Store API orders and payment context.
## Event Integrations
Use [Woo Custom Events](/woo/custom-events) for mini-cart drawers, analytics, cart refresh integrations, and checkout instrumentation. Keep event examples there so recipes stay focused on component composition.
---
## Woo Custom Events
Woo runtime events are browser `CustomEvent` objects. They bubble, so you can listen on a component, a nearby wrapper, or `document`.
Use events as the integration contract for work that happens after a Woo action. Do not use `data-ome-state="success"` as an integration contract; that state is visible UI feedback for the control that just finished an action.
## Which Event Should I Use?
| Goal | Event |
| --- | --- |
| Open a mini-cart, track an add-to-cart conversion, or inspect the product that was added. | `ome-woo:item-added` |
| Refresh any cart-related integration after add, quantity update, or item removal. | `ome-woo:cart-updated` |
| Track add-to-cart failures. | `ome-woo:add-to-cart-error` |
| React to quantity changes or item removal with row-level detail. | `ome-woo:item-quantity-updated` or `ome-woo:item-removed` |
| React to committed variable-product selection state inside a Product Provider. | `ome-woo:variation-selection-changed` |
| Track checkout start, completion, and checkout errors. | `ome-woo:checkout-started`, `ome-woo:checkout-complete`, `ome-woo:checkout-error` |
| Track a completed purchase (thank-you page) with full order totals and items. | `ome-woo:purchase` |
`ome-woo:item-added` fires first for successful add-to-cart and includes `product_id`, `quantity`, `cart_summary`, and — when the add response provides them — `variation_id`, `variation`, and `price`. `ome-woo:cart-updated` follows when the integration only needs to know that the cart changed.
Analytics integrations do not need to listen for add/remove at all: OME also dispatches the standard `wc-blocks_added_to_cart` / `wc-blocks_removed_from_cart` DOM events and the legacy jQuery `added_to_cart` / `removed_from_cart` events (when jQuery is present). See [Standard Analytics Bridge Events](#standard-analytics-bridge-events).
## Event Summary
| Area | Event | Dispatch target | Detail payload |
| --- | --- | --- | --- |
| Cart boot | `ome-woo:cart-loaded` | First cart display root found, or `document.body`. | `{ cart_summary }` |
| Product add | `ome-woo:item-added` | Standalone add button or submitted `AddToCartForm`. | `{ product_id, quantity, cart_summary, variation_id?, variation?, price? }` |
| Product add | `ome-woo:cart-updated` | Same target as the successful cart mutation. | `{ cart_summary }` |
| Product add | `ome-woo:add-to-cart-error` | Standalone add button or submitted `AddToCartForm`. | `{ product_id, quantity, error }` |
| Analytics bridge | `wc-blocks_added_to_cart` | `document.body`. | `{ preserveCartData }` |
| Analytics bridge | `wc-blocks_removed_from_cart` | `document.body`. | `{ preserveCartData }` |
| Order received | `ome-woo:purchase` | `document.body`. | `{ order }` |
| Product selection | `ome-woo:variation-selection-changed` | Nearest `ProductProvider` root. | `{ product_id, selection, selected_variation, current_product }` |
| Cart item mutation | `ome-woo:item-quantity-updated` | Cart item quantity input. | `{ key, quantity, cart_summary }` |
| Cart item mutation | `ome-woo:item-removed` | Cart item remove button, or `document.body` if the button was detached first. | `{ key, cart_summary }` |
| Cart item mutation | `ome-woo:cart-error` | Cart item quantity input or remove button. | `{ action, key, quantity?, error }` |
| Checkout | `ome-woo:checkout-loaded` | Checkout provider, checkout form, checkout notices, or `document.body`. | `{ checkout }` |
| Checkout | `ome-woo:checkout-started` | Checkout form. | `{}` |
| Checkout | `ome-woo:checkout-complete` | Checkout form. | `{ checkout }` |
| Checkout | `ome-woo:checkout-error` | Checkout form. | `{ errors?, phase?, source?, error?, diagnostic? }` |
## Shared Payload Shapes
`cart_summary` is the live cart summary after the mutation:
```ts
type WooCartSummary = {
item_count: number;
line_count: number;
};
```
`error` is a safe Woo error summary:
```ts
type WooErrorSummary = {
code: string;
message: string;
status: number;
field_keys?: string[];
};
```
`checkout` is the current Store API checkout response. It can include fields such as `order_id`, `status`, `order_key`, `payment_method`, `payment_result`, and `__experimentalCart`.
`diagnostic` is present on payment adapter failures when the adapter can provide a safe diagnostic object. It can include `methodId`, `adapterId`, `provider`, `paymentType`, `fieldMode`, `phase`, `code`, `message`, `details`, and `sequence`.
## Product Selection Event
### `ome-woo:variation-selection-changed`
| Contract | Value |
| --- | --- |
| Dispatch target | The nearest `OmeWooProductProvider` root. Standalone `AddToCartForm` does not emit this event. |
| Bubbles | Yes. |
| Composed | Yes. |
| Cancelable | No. |
| When it fires | After Provider datasets and form mirrors have committed a new semantic variable-product selection state. Initialization emits only the final settled state. Recommitting the same state does not emit again. Simple products do not emit it. |
| Detail payload | `{ product_id, selection: { phase, attributes }, selected_variation, current_product }` |
`selection.phase` is `base`, `partial`, `resolved`, or `invalid`. `selected_variation` is the complete resolved variation object or `null`. `current_product` is the complete base product until resolution succeeds, then the complete resolved variation. Availability remains a field of the product or variation object; it is not encoded in the phase.
```ts
document.addEventListener("ome-woo:variation-selection-changed", (event) => {
const detail = (event as CustomEvent).detail;
if (detail.selection.phase === "resolved") {
console.log(detail.selected_variation);
}
});
```
## Product Add Events
### `ome-woo:item-added`
| Contract | Value |
| --- | --- |
| Dispatch target | The standalone `AddToCartButton`, or the submitted `AddToCartForm` for form-submit buttons. |
| Bubbles | Yes. |
| When it fires | After Store API `POST /cart/add-item` succeeds and the runtime has a fresh cart summary. |
| Detail payload | `{ product_id, quantity, cart_summary: { item_count, line_count }, variation_id?, variation?, price? }` |
Use this event when the integration needs the product and quantity that were just added.
The analytics fields are additive and degrade gracefully:
- `variation_id` is the variation that was actually added, or `null` for simple products.
- `variation` maps variation attribute slugs to the selected value (for example `{ "pa_size": "large" }`).
- `price` is the unit price of the added line: `{ value, currency_code, currency_minor_unit }` where `value` is in minor units (for example grosze). It is present when the add-item response carries the line's price and currency.
### `ome-woo:cart-updated`
| Contract | Value |
| --- | --- |
| Dispatch target | The same element that dispatched the successful cart mutation event. |
| Bubbles | Yes. |
| When it fires | After add-to-cart, quantity update, or item removal succeeds. |
| Detail payload | `{ cart_summary: { item_count, line_count } }` |
Use this event when the integration only needs the latest cart count or line count.
Cart mutation scheduling is intentionally not a public event stream. There is no generic transaction-lifecycle event. For local visual progress, style `data-ome-woo-mutation-phase`; for business integrations, keep using the semantic events above.
### `ome-woo:add-to-cart-error`
| Contract | Value |
| --- | --- |
| Dispatch target | The standalone `AddToCartButton`, or the submitted `AddToCartForm` for form-submit buttons. |
| Bubbles | Yes. |
| When it fires | After Store API `POST /cart/add-item` fails. |
| Detail payload | `{ product_id, quantity, error: { code, message, status, field_keys? } }` |
## Standard Analytics Bridge Events
OME dispatches the events analytics plugins already listen for, so GA4 and friends receive `add_to_cart` / `remove_from_cart` without custom code:
| Event | Dispatch target | When it fires | Detail |
| --- | --- | --- | --- |
| `wc-blocks_added_to_cart` | `document.body` | After a successful add-to-cart. | `{ preserveCartData: true }` |
| `wc-blocks_removed_from_cart` | `document.body` | After a successful item removal. | `{ preserveCartData: true }` |
| jQuery `added_to_cart` | `document.body` (via `jQuery(document.body).trigger`) | After a successful add-to-cart, only when `window.jQuery` exists. | `[fragments, cart_hash, $button]` |
| jQuery `removed_from_cart` | `document.body` (via `jQuery(document.body).trigger`) | After a successful item removal, only when `window.jQuery` exists. | `[fragments, cart_hash]` |
Notes:
- The `wc-blocks_*` events follow the WooCommerce Blocks contract: `bubbles: true`, `cancelable: true`, `detail: { preserveCartData: true }`. Like Woo Blocks itself, they carry no product payload — use `ome-woo:item-added` for product data.
- The jQuery bridge is a strict no-op on jQuery-less sites (common with Etch); the DOM events above always fire.
## Purchase Event
### `ome-woo:purchase`
| Contract | Value |
| --- | --- |
| Dispatch target | `document.body`. |
| Bubbles | Yes. |
| When it fires | Once at Woo runtime boot on the order-received (thank-you) page, when an authorized order is present. |
| Detail payload | `{ order }` |
This is the most robust purchase signal: it works across payment redirects and gateways because it fires on the thank-you page, and it carries everything a `purchase` event needs — without customer PII beyond order identifiers.
```ts
type WooPurchaseItem = {
product_id: number;
variation_id: number | null;
name: string;
quantity: number;
price: number; // unit price, major units
total: number; // line total, major units
};
type WooPurchaseOrder = {
id: number;
number: string;
status: string;
currency: string;
subtotal?: number;
shipping?: number;
tax?: number;
discount?: number;
total: number;
coupons?: string[];
items: WooPurchaseItem[];
};
```
## Cart Item Events
### `ome-woo:cart-loaded`
| Contract | Value |
| --- | --- |
| Dispatch target | First matching cart display root: `[data-ome-woo-cart-count]`, `[data-ome-woo-cart-total-field]`, `[data-ome-woo-cart-items]`, `[data-ome-woo-cart-notices]`, or `document.body`. |
| Bubbles | Yes. |
| When it fires | After Woo cart boot loads and cart display components are bound. |
| Detail payload | `{ cart_summary: { item_count, line_count } }` |
### `ome-woo:item-quantity-updated`
| Contract | Value |
| --- | --- |
| Dispatch target | The cart item quantity input. |
| Bubbles | Yes. |
| When it fires | After each real Store API quantity response is committed. Debounced-away, cancelled, and already-satisfied no-op targets do not emit it. An intermediate response still emits this semantic event, while control-local success waits for the latest target. |
| Detail payload | `{ key, quantity, cart_summary: { item_count, line_count } }` |
### `ome-woo:item-removed`
| Contract | Value |
| --- | --- |
| Dispatch target | The cart item remove button. If that button was detached before the request finished, the event is dispatched from `document.body`. |
| Bubbles | Yes. |
| When it fires | After Store API `POST /cart/remove-item` succeeds. |
| Detail payload | `{ key, cart_summary: { item_count, line_count } }` |
### `ome-woo:cart-error`
| Contract | Value |
| --- | --- |
| Dispatch target | The cart item quantity input for quantity failures, or the remove button for removal failures. |
| Bubbles | Yes. |
| When it fires | After Store API quantity update or item removal fails. |
| Detail payload | `{ action, key, quantity?, error: { code, message, status, field_keys? } }`, where `action` is `"update-item"` or `"remove-item"`. |
## Checkout Events
### `ome-woo:checkout-loaded`
| Contract | Value |
| --- | --- |
| Dispatch target | First matching checkout root: `[data-ome-woo-checkout-provider]`, `form[data-ome-woo-checkout-form]`, `[data-ome-woo-checkout-notices]`, or `document.body`. |
| Bubbles | Yes. |
| When it fires | After checkout boot loads and checkout components are bound. |
| Detail payload | `{ checkout }` |
### `ome-woo:checkout-started`
| Contract | Value |
| --- | --- |
| Dispatch target | The checkout form. |
| Bubbles | Yes. |
| When it fires | After local submit validation passes and before payment preparation or Store API checkout submission. |
| Detail payload | `{}` |
### `ome-woo:checkout-complete`
| Contract | Value |
| --- | --- |
| Dispatch target | The checkout form. |
| Bubbles | Yes. |
| When it fires | After Store API checkout succeeds. Redirect handling can happen after this event. |
| Detail payload | `{ checkout }` |
### `ome-woo:checkout-error`
| Contract | Value |
| --- | --- |
| Dispatch target | The checkout form. |
| Bubbles | Yes. |
| When it fires | After local validation, payment preparation, payment result handling, or Store API checkout fails. |
| Detail payload | Local validation: `{ errors, phase, source: "local-validation" }`. Runtime/payment failure: `{ error, diagnostic? }`. |
`errors` is an array of checkout field errors:
```ts
type WooCheckoutFieldError = {
field_key: string;
code: "required" | "invalid_email" | "invalid_country" | "invalid_state";
message: string;
};
```
`phase` is `"submit"` or `"update"`. `source` is currently `"local-validation"` when the checkout form blocks submission before Store API checkout.
## Example: Open A Mini-Cart Drawer After Add To Cart
Author the drawer and trigger normally:
{`
{#slot default}
Shopping bag
{#slot default}
{/slot}
{#slot empty}
Your cart is empty.
{/slot}
Close
{/slot}
`}
Then click the real trigger when `ome-woo:item-added` bubbles:
{`document.addEventListener("ome-woo:item-added", () => {
const trigger = document.querySelector(
'[data-ome-drawer-trigger][data-ome-target-drawer-id="store-mini-cart"]',
);
if (trigger instanceof HTMLButtonElement) {
trigger.click();
}
});`}
This keeps `OmeDrawerTrigger` and `OmeDrawer` as the drawer owners. The Woo event only decides when to open it.
## Example: Track Add-To-Cart Analytics
{`document.addEventListener("ome-woo:item-added", (event) => {
if (!(event instanceof CustomEvent)) {
return;
}
const { product_id, quantity, variation_id, variation, price, cart_summary } = event.detail;
window.dataLayer?.push({
event: "add_to_cart",
ecommerce: {
currency: price?.currency_code,
value: price ? (price.value / 10 ** price.currency_minor_unit) * quantity : undefined,
items: [
{
item_id: variation_id ?? product_id,
item_name: undefined, // enrich from your own product feed if needed
quantity,
...(variation ? { item_variant: Object.values(variation).join(", ") } : {}),
...(price ? { price: price.value / 10 ** price.currency_minor_unit } : {}),
},
],
},
cart_items: cart_summary.item_count,
});
});`}
If you only need the conversion signal, prefer the automatic bridges above — most GA4 plugins pick up `wc-blocks_added_to_cart` or the jQuery `added_to_cart` event on their own.
{`document.addEventListener("ome-woo:item-removed", (event) => {
if (!(event instanceof CustomEvent)) {
return;
}
window.dataLayer?.push({ event: "remove_from_cart" });
});`}
{`document.addEventListener("ome-woo:purchase", (event) => {
if (!(event instanceof CustomEvent)) {
return;
}
const { order } = event.detail;
window.dataLayer?.push({
event: "purchase",
ecommerce: {
transaction_id: order.number,
currency: order.currency,
value: order.total,
tax: order.tax,
shipping: order.shipping,
coupon: order.coupons?.join(","),
items: order.items.map((item) => ({
item_id: item.variation_id ?? item.product_id,
item_name: item.name,
quantity: item.quantity,
price: item.price,
})),
},
});
});`}
Use `ome-woo:purchase` here because the thank-you page is the most reliable purchase surface: it fires across payment redirects and gateways. Use `order.number` as `transaction_id` so GA4 deduplicates reloads.
## Example: Refresh Cart Integrations
{`document.addEventListener("ome-woo:cart-updated", (event) => {
if (!(event instanceof CustomEvent)) {
return;
}
const { cart_summary } = event.detail;
document.documentElement.dataset.cartItems = String(cart_summary.item_count);
});`}
Use `ome-woo:cart-updated` when the integration does not care whether the cart changed because of add, quantity, or removal.
## Example: Capture Checkout Errors
{`document.addEventListener("ome-woo:checkout-error", (event) => {
if (!(event instanceof CustomEvent)) {
return;
}
const { errors, error, diagnostic } = event.detail;
console.warn("Checkout failed", {
fieldErrors: errors,
error,
diagnostic,
});
});`}
Use this for logging, support tooling, or checkout instrumentation. Let `CheckoutNotices` remain responsible for visible customer messages.
---
## Woo Template Integration Contract
Woo components are not enough by themselves. A starter also has to own the Woo
routes that WordPress and WooCommerce resolve: product archive, single product,
cart, checkout, order confirmation, and any product taxonomy archives the
starter exposes.
This page is the public contract for that ownership.
## Required Route Ownership
| Route surface | Starter-owned content | Required slug or option | Notes |
| --- | --- | --- | --- |
| Product archive | Active-theme block template | `archive-product` | Use `Template::new()` and render a product loop. The default Woo shop route is usually `/shop/`. |
| Single product | Active-theme block template | `single-product` | Use `Template::new()` and current-product dynamic data such as `{this.id}` and `{this.omewoo.*}`. |
| Cart | Page content plus optional page template | `woocommerce_cart_page_id`, optionally `page-cart` | Assign a real cart page. A `page-cart` template should pass through page content or render the Woo cart block. |
| Checkout | Page content plus optional page template | `woocommerce_checkout_page_id`, optionally `page-checkout` | Assign a real checkout page. A `page-checkout` template should pass through page content or render the Woo checkout block. |
| Order confirmation | Active-theme block template or Woo-owned page content | `order-confirmation` and `order-received` flow | Keep Woo's order received lifecycle intact. Render Woo core order confirmation output for completed orders. |
| Product taxonomies | Active-theme taxonomy templates when customized | `taxonomy-product_cat`, `taxonomy-product_tag` | Use product-loop-aware markup. Do not let taxonomy archives fall back to a non-product post layout if the starter presents them as store routes. |
## Builder Shape
The minimum code-owned content shape is:
{`Template::new()
->slug( 'archive-product' )
->title( 'Product Archive' )
->overwrite()
->blocks_markup( product_archive_blocks() )
->register();
Template::new()
->slug( 'single-product' )
->title( 'Single Product' )
->overwrite()
->blocks_markup( single_product_blocks() )
->register();
$cart_page_id = Page::new()
->slug( 'cart' )
->title( 'Cart' )
->overwrite()
->blocks_markup( cart_page_blocks() )
->register();
$checkout_page_id = Page::new()
->slug( 'checkout' )
->title( 'Checkout' )
->overwrite()
->blocks_markup( checkout_page_blocks() )
->register();
if ( is_int( $cart_page_id ) ) {
update_option( 'woocommerce_cart_page_id', $cart_page_id, false );
}
if ( is_int( $checkout_page_id ) ) {
update_option( 'woocommerce_checkout_page_id', $checkout_page_id, false );
}`}
Use `Page::new()` for cart and checkout because those are Woo page
settings. A starter can additionally own `page-cart` and `page-checkout`
templates, but those templates must not hide the assigned page content.
## Product Archive And Single Product
Use `Template::new()` for `archive-product` and `single-product` so the active
theme owns those Woo block templates.
Archive templates should render a product loop. Inside each loop item, use
`{item.*}` and `{item.omewoo.*}` values. Single product templates should use
`{this.*}` and `{this.omewoo.*}` values from the current product.
Read [Product Archive Flow](/woo/flows/product-archive) and
[Single Product Flow](/woo/flows/single-product) for component composition.
## Cart And Checkout Page Assignment
Woo still needs assigned pages. The starter must create or update page content
and write the Woo options:
| Option | Meaning |
| --- | --- |
| `woocommerce_cart_page_id` | Page Woo uses for `/cart/`, cart links, and cart redirects. |
| `woocommerce_checkout_page_id` | Page Woo uses for `/checkout/`, checkout redirects, and payment return fallbacks. |
The page slug can be `cart` and `checkout` for public starter sites.
If the starter also registers block templates for `page-cart` or
`page-checkout`, those templates should preserve page content:
{`Template::new()
->slug( 'page-cart' )
->title( 'Cart Page Template' )
->overwrite()
->blocks_markup( '' )
->register();
Template::new()
->slug( 'page-checkout' )
->title( 'Checkout Page Template' )
->overwrite()
->blocks_markup( '' )
->register();`}
If your starter has a helper such as `CoreBlock::post_content()`, use that for
the same pass-through behavior. If it does not, the raw core block markup is:
``.
## Woo Core Block Fallbacks
When a starter is not composing the cart or checkout with OhMyEtch Woo
components, use Woo core blocks inside the assigned page content:
{`$cart_blocks = '';
$checkout_blocks = '';
$order_confirmation_blocks = '';`}
Do not mix a full OhMyEtch checkout form and the Woo checkout block in the same
visible checkout surface. Pick one owner for the checkout UI.
## Order Confirmation
The checkout Store API success path redirects into Woo's order received flow.
The route can include `order-received`, and payment gateways may also use
Woo-owned return URLs.
If the starter owns `order-confirmation`, render the Woo core order confirmation
block or pass through Woo-managed page content:
{`Template::new()
->slug( 'order-confirmation' )
->title( 'Order Confirmation' )
->overwrite()
->blocks_markup( '' )
->register();`}
Do not replace this route with a generic static thank-you page. The customer
must land on a Woo-aware surface that can read the completed order context.
## Taxonomy Archive Considerations
Product taxonomy routes are store routes too. If the starter links to product
categories or tags, add product-aware taxonomy templates for `product_cat` and
`product_tag`.
The normal WordPress block template slugs are:
| Taxonomy | Template slug |
| --- | --- |
| Product categories | `taxonomy-product_cat` |
| Product tags | `taxonomy-product_tag` |
The template content should reuse the product archive loop shape rather than a
generic post archive card. It should render product purchase components only
inside a product loop context where `{item.omewoo.*}` is available.
## Starter Skill Smoke Recipe
A starter-building skill or generated recipe should explicitly mention every
required ownership slug before it claims Woo route integration is complete:
```text
Required starter route slugs:
- archive-product
- single-product
- page-cart
- page-checkout
- order-confirmation
Required assigned Woo page options:
- woocommerce_cart_page_id
- woocommerce_checkout_page_id
```
The smoke should fail if any slug is missing from the generated starter plan or
if cart and checkout pages are not assigned to Woo options.
## Route Smoke Checklist
After building a starter, run browser smoke checks against all customer-facing
routes:
| Route | What to verify |
| --- | --- |
| `/shop/` | Product archive renders product cards and add-to-cart controls. |
| `/product/.../` | Single product renders current product data, variation selectors when needed, and purchase controls. |
| `/cart/` | Cart page is the page stored in `woocommerce_cart_page_id`; cart rows and empty state render. |
| `/checkout/` | Checkout page is the page stored in `woocommerce_checkout_page_id`; checkout fields, payment selector, notices, order summary, and place-order flow render. |
| `order-received` | A completed checkout reaches a Woo order received or order confirmation surface with order-aware content. |
A production starter should expose equivalent route checks through its own smoke workflow.
---
## Complete Store Preview
Use this page as the big-picture map after you have read the individual view guides. A complete Woo storefront usually needs four customer-facing surfaces:
| Surface | What it owns |
| --- | --- |
| Product archive | Product loop, product cards, add-to-cart forms, cart count, cart notices. |
| Single product | Current product data, variation selectors, quantity, add-to-cart, buy-now. |
| Cart page | Editable cart rows, coupons, shipping, totals, empty state. |
| Checkout page | Checkout form, address fields, shipping, payment, terms, notices, order summary, place order. |
## How The Views Connect
```text
Product archive or single product
AddToCartForm / AddToCartButton
CartCount and CartNotices update
Cart page
reads the same Store API cart
updates rows, coupons, shipping, and totals
Checkout page
reads the same cart
collects checkout fields
submits the order through Woo Store API
```
The product views add items into cart state. The cart page mutates that same cart. The checkout page consumes the cart and submits the order.
## Route Ownership Checklist
| Route | Required owner |
| --- | --- |
| Shop archive | `archive-product` template. |
| Product page | `single-product` template. |
| Cart | Page assigned to `woocommerce_cart_page_id`. |
| Checkout | Page assigned to `woocommerce_checkout_page_id`. |
| Order received | Woo-aware order confirmation route or block. |
| Product categories/tags | Product-aware taxonomy templates when the starter exposes those routes. |
Read [Woo Template Integration Contract](/woo/flows/template-integration-contract) before publishing a starter that owns those routes.
## Shared Data Rules
- Product archives use `{item.*}` and `{item.omewoo.*}` inside the product loop.
- Single product templates use `{this.*}` and `{this.omewoo.*}`.
- Cart rows use cart item atoms inside `CartItems`.
- Checkout fields and selectors live inside `CheckoutProvider` / `CheckoutForm`.
- Order summary can reuse cart item and totals atoms in a read-only checkout context.
## Shared Feedback Rules
Use cart-level feedback outside repeated product cards:
- `CartCount` shows current item quantity.
- `CartNotices` shows cart action messages.
- `CheckoutNotices` shows checkout validation and submit messages.
- Woo custom events are the integration hook for drawers, analytics, and checkout instrumentation.
## Build Order
1. Build the [Product Archive](/woo/flows/product-archive).
2. Build the [Single Product](/woo/flows/single-product) template.
3. Build the [Cart Page](/woo/flows/cart-page).
4. Build the [Checkout Page](/woo/flows/checkout-page).
5. Wire route ownership with [Woo Template Integration Contract](/woo/flows/template-integration-contract).
6. Add focused [Recipes](/woo/recipes) and [Woo Custom Events](/woo/custom-events) integrations as needed.
That order keeps the first usable storefront visible while the deeper checkout and route details are added.
---
## Cart Items
This family renders the editable cart line-item list. `CartItems` owns the row loop. The atoms inside the default slot read the current row.
## When To Use This Family
Use this family when you need cart rows: a cart page, a mini-cart drawer, or a checkout order summary that uses cart item atoms.
## Quick Start
{`
{#slot default}
{/slot}
{#slot empty}
Your cart is empty.
{/slot}
`}
## Components
| Component key | Role |
| --- | --- |
| `OmeWooCartItems` | Renders cart rows and an authored empty slot. |
| `OmeWooCartItemImage` | Displays line product image. |
| `OmeWooCartItemTitle` | Displays product title or composed variant title. |
| `OmeWooCartItemPrice` | Displays unit price. |
| `OmeWooCartItemSubtotal` | Displays line subtotal. |
| `OmeWooCartItemQuantity` | Interactive quantity input or display quantity. |
| `OmeWooCartItemRemove` | Removes the current cart item. |
| `OmeWooCartAttributeList` | Loops the selected variation attributes for the current line. |
| `OmeWooCartAttributeName` | Displays attribute name inside `CartAttributeList`. |
| `OmeWooCartAttributeValue` | Displays attribute value inside `CartAttributeList`. |
## Authoring Structure
```text
CartItems
default slot
CartItemImage
CartItemTitle
CartAttributeList
CartAttributeName
CartAttributeValue
CartItemPrice
CartItemQuantity
CartItemSubtotal
CartItemRemove
empty slot
authored empty-cart content
```
## CartItems Props
| Prop | Meaning |
| --- | --- |
| `structure.root_tag` | Root wrapper tag. |
| `structure.item_tag` | Row tag. |
| `structure.empty_tag` | Empty state wrapper tag. |
| `preview.rows` | Number of builder preview rows. |
| `preview.empty_state` | Shows the empty slot in builder preview. |
The runtime sets `data-ome-state` to `has-items` or `empty`.
## Cart Item Atom Props
| Component | Important props |
| --- | --- |
| `CartItemImage` | `content.alt_fallback` is used when Woo image alt text is empty. |
| `CartItemTitle` | `content.include_attributes` and `content.variant_separator` control composed variant title text. |
| `CartItemQuantity` | `configuration.mode` is `interactive` or `preview`; `configuration.counter_presentation` is `input` or `stepper`; content, accessibility, and styling props control the rendered control. |
| `CartItemRemove` | `content.label` and `accessibility.aria_label` control button text and accessible name. |
`CartItemPrice` and `CartItemSubtotal` display Store API formatted price text from the current row.
Interactive quantity and remove controls dispatch Woo custom events after Store API mutations. See [Woo Custom Events](/woo/custom-events) for `ome-woo:item-quantity-updated`, `ome-woo:item-removed`, `ome-woo:cart-updated`, and `ome-woo:cart-error` payloads.
`CartItemQuantity` accepts absolute quantities and keeps its current draft editable during a short internal debounce. Rapid same-line drafts collapse to the latest target; they do not optimistically rewrite the shared cart. `CartItemRemove` cancels an unstarted quantity draft for the same exact line. Both controls preserve `data-ome-state` and additionally expose `data-ome-woo-mutation-phase` for styling `idle`, `debouncing`, `queued`, `pending`, `success`, and `error`.
### Cart Item Quantity Presentations
The default `input` presentation preserves the released number-input markup and behavior. Opt into the button-based presentation per component:
{` `}
The `stepper` renders a real decrease button, a read-only value, and a real increase button. It is a presentation of the same exact-line quantity setter: clicks update the hidden canonical quantity input, and the existing mutation coordinator sends the latest absolute target to Woo. Zero is never treated as removal; use `CartItemRemove` for that action.
Do not author `min`, `max`, or `step`. Each row receives Woo-authoritative `quantityLimits`: `minimum`, finite `maximum` or `null`, `multiple`, `editable`, and `soldIndividually`. Both presentations use those limits, including decimal quantities. Non-editable and sold-individually lines remain truthful read-only controls.
Use `content.decrease_label` and `content.increase_label` for optional visible button text. Accessible names come from `accessibility.decrease_aria_label`, `accessibility.increase_aria_label`, and `accessibility.value_aria_label`. Style the parts with `styling.wrapper_class`, `styling.decrease_button_class`, `styling.value_class`, and `styling.increase_button_class`.
Stable hooks are available on every stepper: `data-ome-woo-quantity-control`, `data-ome-woo-quantity-presentation="stepper"`, `data-ome-woo-quantity-decrease`, `data-ome-woo-quantity-value`, and `data-ome-woo-quantity-increase`. Mutation state remains separate on `data-ome-woo-mutation-phase`.
## Attribute Props
`CartAttributeList` exposes:
| Prop | Meaning |
| --- | --- |
| `structure.root_tag` | Attribute list wrapper tag. |
| `structure.item_tag` | Attribute row tag. |
| `preview.rows` | Number of builder preview attributes. |
`CartAttributeName` and `CartAttributeValue` are row atoms; they need the current attribute row from `CartAttributeList`.
## Hydration Rules
Server render uses `CartItemAtomHydrator` when current cart data exists. Runtime uses `cart-items.ts` after Store API responses. Both update:
- Row keys and indexes.
- Text fields.
- Image attributes.
- Quantity input or stepper values, exact cart item keys, and Woo quantity limits.
- Remove button cart item keys.
- Attribute rows cloned from the attribute row template.
Rows inside `` elements are ignored until cloned.
## Related Guides
- [Cart Page](/woo/flows/cart-page)
- [Order Summary](/woo/component-families/order-summary)
- [Woo Custom Events](/woo/custom-events)
---
## Cart State and Notices
This family renders global cart feedback: item count and cart notices. Both can be used outside a cart page.
## When To Use This Family
Use `CartCount` and `CartNotices` anywhere cart actions need shared feedback: archive headers, product pages, cart pages, mini-carts, and checkout-adjacent layouts.
## Quick Start
{`Store header cart count:
`}
## Components
| Component key | Role |
| --- | --- |
| `OmeWooCartCount` | Displays the current cart item quantity and state. |
| `OmeWooCartNotices` | Renders Store API and Woo cart notices as safe text. |
## CartCount
`CartCount` subscribes to `WooCartStore` and displays `cartSummary.item_count`. It sets:
| State | Meaning |
| --- | --- |
| `empty` | Cart has no lines. |
| `has-items` | Cart has one or more lines. |
It is useful in product archive headers, single product templates, mini-cart indicators, and cart pages.
## CartNotices
`CartNotices` is a runtime notice region. It renders notices from cart actions:
| Source | Typical action |
| --- | --- |
| `add-to-cart` | Product add failed. |
| `quantity` | Quantity update failed. |
| `remove` | Remove item failed. |
| `coupon` | Apply or remove coupon failed. |
| `shipping` | Shipping rate selection failed. |
| `stock` or `variation` | Woo Store API product constraints. |
Messages are normalized and rendered as text, so Woo error content is not injected as HTML.
## Props
| Component | Prop | Meaning |
| --- | --- | --- |
| Cart notices | `preview.show_in_builder` | Shows a sample notice in Etch builder preview. |
| Cart notices | `preview.notice_type` | Preview notice type: `error`, `success`, `info`, or `warning`. |
| Cart notices | `accessibility.aria_label` | Accessible label for the notice region. |
| Cart notices | `accessibility.live_region` | Live region politeness, defaulting to `polite`. |
`CartCount` is mostly display and styling; its runtime content comes from the cart store.
## Related Guides
- [Product Archive](/woo/flows/product-archive)
- [Cart Page](/woo/flows/cart-page)
- [Woo Custom Events](/woo/custom-events)
---
## Cart Totals
Use `OmeWooCartAmount` for new cart total interfaces. It renders one explicitly selected shopper-facing amount, follows WooCommerce tax display rules by default, and distinguishes a calculated zero from a value that WooCommerce has not calculated yet.
## Quick Start
Place one Cart Amount component in `OmeWooCartTotalsList` for each row you want to show. An empty `content.label` uses the automatic label for the selected measure and current state.
{`
`}
`final_total` is the default measure, so a bare ` ` is a valid compact final-total readout.
## Shopper Measures
`amount.measure` offers exactly six measures:
| Measure | What the shopper sees |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `items_subtotal` | Product subtotal before discounts, fees, and shipping. |
| `discount` | Discount magnitude rendered as a negative amount. Non-zero discounts always have a minus sign; formatted zero stays unsigned. |
| `fees` | Cart fees. |
| `shipping` | Calculated shipping, or the pending text while required shipping is unresolved. |
| `tax` | WooCommerce's direct tax total. Its automatic label is `Included tax` when the store displays cart prices including tax, and `Tax` otherwise. |
| `final_total` | WooCommerce's direct final total. Its automatic label becomes `Estimated total` while required shipping is unresolved. |
The first four measures are net/tax pairs. For those measures only, `amount.tax_presentation` controls whether the displayed amount includes tax:
| Value | Behavior |
| --------------- | ------------------------------------------------------------------------------ |
| `store` | Follows the store's WooCommerce cart tax-display setting. This is the default. |
| `including_tax` | Adds the matching direct tax field to the measure's direct net field. |
| `excluding_tax` | Uses the measure's direct net field. |
`tax` and `final_total` do not expose this choice. Cart Amount uses `total_tax` and `total_price` directly and never reconstructs either value. In particular, Store API `total_price` already contains any applicable tax; adding `total_tax` again would overstate the shopper's total.
## Shipping And Public States
A resolved shipping amount of zero is free shipping and renders as the correctly formatted currency zero, such as `$0.00`. When the cart needs shipping but WooCommerce has not calculated it, the canonical shipping value remains `null`: the shipping measure renders `amount.pending_text` (default `Not calculated`) and exposes `data-ome-state="pending"`.
The final total still renders WooCommerce's direct `total_price` while shipping is unresolved, but exposes `data-ome-state="estimated"` and uses the automatic label `Estimated total`. It does not guess a shipping cost.
The public states are exactly:
| State | Meaning |
| ----------- | ------------------------------------------------------------------------------- |
| `resolved` | The selected measure is available, including a genuine zero. |
| `pending` | Required shipping has not been calculated; used by the shipping measure. |
| `estimated` | The direct final total is available, but required shipping is still unresolved. |
An empty cart resolves its available measures as a correctly formatted currency zero rather than an empty string.
Server-rendered text remains in place until the Cart Store has a confirmed hydrated snapshot. Cart Amount does not optimistically rewrite totals, mutate the cart, emit custom events, or create an `aria-live` region.
## Props
### Content
| Prop | Default | Meaning |
| ------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------- |
| `content.show_label` | `false` | Shows a visible label and value row. When false, a visually hidden label still provides the amount's accessible name. |
| `content.label` | empty | Empty uses the automatic measure/state label. A non-empty authored value overrides that label. |
| `content.label_position` | `prefix` | Places the visible label before (`prefix`) or after (`suffix`) the value. Available when `show_label` is true. |
With `show_label=false`, the hidden accessible text combines the active label and value, for example `Shipping: Not calculated`. The visible value is hidden from assistive technology to avoid duplicate announcements. A non-empty authored label is still respected in this mode.
### Amount
| Prop | Default | Meaning |
| ------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------- |
| `amount.measure` | `final_total` | Selects `items_subtotal`, `discount`, `fees`, `shipping`, `tax`, or `final_total`. |
| `amount.tax_presentation` | `store` | Selects `store`, `including_tax`, or `excluding_tax`. Available only for subtotal, discount, fees, and shipping. |
| `amount.pending_text` | `Not calculated` | Copy shown for unresolved shipping. Available only when `measure=shipping`. |
### Structure And Styling
| Prop | Meaning |
| --------------------- | ------------------------------------------------------ |
| `structure.html_tag` | Wrapper tag used when `content.show_label` is true. |
| `styling.value_class` | Class prop for the amount value. |
| `styling.class` | Wrapper class when the visible label is enabled. |
| `styling.label_class` | Visible label class when the visible label is enabled. |
`OmeWooCartTotalsList` keeps its existing `structure.root_tag` wrapper prop and `styling.list_class` class prop.
## DOM And CSS Contract
The amount root exposes:
- `data-ome-woo-cart-amount`
- `data-ome-woo-cart-amount-measure`
- `data-ome-woo-tax-presentation`
- `data-ome-state` with `resolved`, `pending`, or `estimated`
The value exposes `data-ome-woo-cart-amount-value`; the visible or visually hidden label exposes `data-ome-woo-cart-amount-label`.
Stable classes include `ome-woo-cart-amount` on the root, `ome-woo-cart-amount__value` on the value, and `ome-woo-cart-amount__label` on a visible label. Labeled rows also retain the shared `ome-woo-cart-total`, `ome-woo-cart-totals__row`, `ome-woo-cart-totals__label`, and `ome-woo-cart-totals__value` classes.
```css
[data-ome-woo-cart-amount-measure="discount"]
[data-ome-woo-cart-amount-value] {
color: var(--accent);
}
[data-ome-woo-cart-amount-measure="final_total"][data-ome-state="estimated"] {
opacity: 0.75;
}
[data-ome-woo-cart-amount-measure="shipping"][data-ome-state="pending"]
.ome-woo-cart-amount__value {
font-style: italic;
}
```
## Canonical Dynamic Data
`cartTotals.cartAmount` is the additive canonical lane used for Cart Amount's server-rendered values. Monetary values use Store API minor units and keep split net/tax fields rather than pre-combining them:
| Expression | Meaning |
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| `{cartTotals.cartAmount.total_items}` / `{cartTotals.cartAmount.total_items_tax}` | Items subtotal net and matching tax. |
| `{cartTotals.cartAmount.total_discount}` / `{cartTotals.cartAmount.total_discount_tax}` | Discount net and matching tax. |
| `{cartTotals.cartAmount.total_fees}` / `{cartTotals.cartAmount.total_fees_tax}` | Fees net and matching tax. |
| `{cartTotals.cartAmount.total_shipping}` / `{cartTotals.cartAmount.total_shipping_tax}` | Shipping net and matching tax; both remain nullable while required shipping is unresolved. |
| `{cartTotals.cartAmount.total_tax}` | Direct tax total. |
| `{cartTotals.cartAmount.total_price}` | Direct final total, already including applicable tax. |
| `{cartTotals.cartAmount.needs_shipping}` | Whether the cart requires shipping. |
| `{cartTotals.cartAmount.has_calculated_shipping}` | Whether WooCommerce has calculated shipping. |
| `{cartTotals.cartAmount.tax_display}` | Normalized `including_tax` or `excluding_tax` store presentation. |
| `{cartTotals.cartAmount.currency_*}` | Store API-compatible currency code, symbol, minor unit, separators, prefix, and suffix. |
Use the component rather than binding these fields manually when you want tax-presentation logic, discount signs, pending states, automatic labels, and confirmed Cart Store hydration.
## Released Legacy Total Atoms
`OmeWooTotalsSubtotal`, `OmeWooTotalsDiscount`, `OmeWooTotalsShipping`, `OmeWooTotalsTax`, and `OmeWooTotalsTotal` are released legacy atoms. They remain registered and behave exactly as before for saved components and existing integrations.
| Legacy component | Flat field |
| ---------------------- | --------------------------- |
| `OmeWooTotalsSubtotal` | `cartTotals.total_items` |
| `OmeWooTotalsDiscount` | `cartTotals.total_discount` |
| `OmeWooTotalsShipping` | `cartTotals.total_shipping` |
| `OmeWooTotalsTax` | `cartTotals.total_tax` |
| `OmeWooTotalsTotal` | `cartTotals.total_price` |
Those flat raw fields, a positive discount value, and missing-value-to-zero behavior are compatibility semantics. Depending on store tax settings, they may not describe the shopper-facing tax presentation you intend. Existing atoms are not silently migrated or reinterpreted. Keep them when preserving an existing design; choose `OmeWooCartAmount` for new work.
The same released legacy atoms remain usable in `OmeWooOrderSummaryTotalsList` on checkout pages. Cart Amount is currently documented for cart-page readouts.
## Related Guides
- [Cart Page](/woo/flows/cart-page)
- [Woo Dynamic Data Tree](/woo/woo-dynamic-data-tree)
- [Order Summary](/woo/component-families/order-summary)
---
## Checkout Address Forms
This family renders Woo billing and shipping fields. Field definitions are authored in components, but runtime field rules come from Woo's checkout schema.
## When To Use This Family
Use these forms inside `CheckoutForm` when you want Etch-authored billing and shipping fields that still follow Woo's field schema.
## Quick Start
{`
{#slot default}
{/slot}
`}
## Components
| Component key | Role |
| --- | --- |
| `OmeWooBillingAddressForm` | Renders billing address fields. |
| `OmeWooShippingAddressForm` | Renders shipping address fields plus the different-shipping toggle. |
## Shared Field Props
Both address forms expose the same field-copy pattern:
| Prop | Meaning |
| --- | --- |
| `content.legend` | Fieldset legend text. |
| `content.show_legend` | Renders or hides the legend. |
| `{field}.use_woo_defaults` | Uses Woo label, hint text, and validation copy. |
| `{field}.label` | Custom label when Woo defaults are disabled. |
| Field hint copy | Custom input hint copy when Woo defaults are disabled. |
| `{field}.error_message` | Custom local validation copy when Woo defaults are disabled. |
| `accessibility.aria_label` | Fieldset accessible label. |
| `preview.state` | Builder preview state. |
Billing includes email and phone. Shipping does not.
## Shipping Toggle Props
`ShippingAddressForm` adds:
| Prop | Meaning |
| --- | --- |
| `shipping_toggle.label` | Visible toggle label. |
| `shipping_toggle.use_aria_label` | Uses a separate ARIA label when true. |
| `shipping_toggle.aria_label` | Accessible toggle label when enabled. |
| `shipping_toggle.preview_checked` | Builder preview checked state. |
Runtime hides shipping fields until the toggle is checked.
## Runtime Field Rules
Runtime applies the Woo schema:
| Rule | Runtime result |
| --- | --- |
| `hidden` | Field root becomes hidden and controls are disabled. |
| `required` | Field gets `data-ome-required`, and checkout validation uses it. |
| `label` | Label text is updated unless custom copy is enabled. |
| Field hint copy | Input hint copy is updated unless custom copy is enabled. |
| `type` | Native input type is updated. |
| `priority` | Field roots are sorted by Woo priority. |
| `autocomplete` | Autocomplete token is applied. |
Country and state controls are UIChoice-backed. State can become select, text, or hidden depending on the selected country.
When country or state renders as a select control, the visible trigger stays in the address form and the listbox content may be portaled into the shared UIChoice host. Style the portaled listbox with `styling.select_content_class` and each option row with `styling.select_item_class`; fixed host positioning and keyboard behavior remain component-owned runtime CSS.
## Related Guides
- [Checkout Page](/woo/flows/checkout-page)
- [Checkout Fields and Validation](/woo/checkout-fields-and-validation)
- [Shared Controls and Props](/woo/shared-controls-and-props)
---
## Checkout Shell
The checkout shell owns checkout scope, form serialization, notices, and order submission.
## When To Use This Family
Use this family for the main checkout surface. It provides the checkout state scope, owns checkout form submission, renders checkout notices, and provides the submit button.
## Quick Start
{`
{#slot default}
{#slot default}
{/slot}
{/slot}
`}
## Components
| Component key | Role |
| --- | --- |
| `OmeWooCheckoutProvider` | Layout and state scope for checkout components. It does not submit data. |
| `OmeWooCheckoutForm` | Real checkout form shell. Serializes authored checkout fields and submits Store API checkout. |
| `OmeWooCheckoutNotices` | Checkout notice region. |
| `OmeWooPlaceOrderButton` | Submit button for the checkout form. |
## Authoring Structure
```text
CheckoutProvider
CheckoutForm
BillingAddressForm
ShippingAddressForm
ShippingMethodSelector
PaymentMethodSelector
TermsCheckbox
CheckoutNotices
PlaceOrderButton
OrderSummary
```
`OrderSummary` can sit inside the provider but does not have to be inside the `