Subchapter 2.67
references/editor-react-component/REACT-GUIDELINES.mdMarkdown8 KBView on GitHub
This guide defines rules and guidance on how to implement production-quality Editor React components for Wix CLI applications. Editor React components are React components that integrate with the Wix Editor, allowing site owners to customize content, styling, and behavior through a visual interface.
Topic reference files:
PARTS.md — What qualifies as a named part (mandatory filter)DESIGN-STATES.md — Which design states a part supports, and how to author themACCESSIBILITY.md — ARIA/a11y rules and patternsDIRECTIONALITY.md — RTL/LTR rules and patternsPROPS-VS-CSS.md — What should be a React prop vs CSSCOMPONENT-API.md — Props structure, elementProps, data types, file splitting, containers, array propsANIMATED-COMPONENTS.md — Play/pause control and autoplay for animated/playable componentsREACT-PATTERNS.md — SSR-safe patterns, CSS rules, common mistakesThe Wix runtime does not currently support React 18 features. Stick to React 17-compatible APIs and avoid libraries that depend on React 18 features.
Understand the component and infer its behavior. Extract what is provided; use reasonable defaults for anything not specified.
PARTS.md Step 0, then identify named inner parts by applying the mandatory filter in PARTS.md to every candidate element before accepting it as a part. Include content/data props (labels, items, types, required vs optional) and configuration (toggles, choices, ranges, modes).ANIMATED-COMPONENTS.md.hover/focus/disabled/invalid; custom: selected/active/open/… ) by applying the heuristic in DESIGN-STATES.md, and record them in the plan. These become the editor’s per-element state styling controls.Understanding → implementation (checklist): For every part, decide elementProps vs CSS-only and which design states it supports (DESIGN-STATES.md); build the props interface (data + behavior); wire interaction in React (useState, useEffect, refs, native event handlers); give every named inner element an elementProps entry and spread it + merge its className (COMPONENT-API.md); generate TS + CSS. Infer reasonable defaults where anything is unspecified.
These are the mandatory patterns and conventions for all components.
Every component MUST include:
Direction support is mandatory — see DIRECTIONALITY.md.
See ACCESSIBILITY.md for full rules and patterns.
any typesReact.FC, React.ReactNode, etc.)Array<T> instead of T[] (e.g., Array<Item> not Item[])T must be an object with named keys — Array<{ key: ValueType, ... }> or a named interface that is itself a keyed object. Never Array<string>, Array<number>, Array<boolean>, or Array<DataType> (Image, Link, Video, Audio, VectorArt, RichText, etc.). See COMPONENT-API.md for full rules.export constprops as the argument (do NOT destructure in function signature)See COMPONENT-API.md for full elementProps rules and the decision tree.
All components MUST follow these patterns:
1. SSR-Safe Implementation
See REACT-PATTERNS.md §1.1 for code examples.
2. Clean Code
3. Data-Driven Components (NO children in exported props)
See COMPONENT-API.md for full rules and patterns.
4. Breakpoint-Responsive Properties (NO props for visual variations)
See PROPS-VS-CSS.md for full rules and patterns.
5. Reactive to Prop Changes
useEffect with prop dependencies6. Event Handler Scope (Internal by Default)
Unless explicitly specified as a component capability/API in the specification, all event handlers are internal and NOT exposed as props.
Internal handlers (default):
External handlers (only when specified):
onClick?: () => void to propsChild component handlers:
For each part of the component, decide:
CSS class only if:
Use elementProps if:
For the same part, also decide which design states it supports (native + custom) per DESIGN-STATES.md.
See COMPONENT-API.md and PROPS-VS-CSS.md for the decision trees.
Combine:
Follow Part 2 templates with mandatory patterns applied. For each part’s supported design states, author the interactive markup / class toggles and the state CSS per DESIGN-STATES.md.
All CSS authoring rules — root layout, naming, RTL, state styles,
transitions, etc. — live in CSS-GUIDELINES.md.
See PROPS-VS-CSS.md and COMPONENT-API.md for the prop vs CSS vs elementProps decision trees.
Phase 1: Analysis — Parse information, map component structure and supported design states (see Part 0)
Phase 2: Component File — Apply all §1.1 mandatory features and §1.2 implementation standards; toggle custom-state classes from data (DESIGN-STATES.md)
Phase 3: Styles — Apply Part 2 SCSS rules, including state styles (DESIGN-STATES.md). If the request uses the words branded, themed, or brand-aware, also apply BRANDED-COMPONENTS.md before writing CSS.