> Portal Navigation:
>
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt
## Resource: States
## Article: States
## Article Link: https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/editor-react-components/manifest-reference/editor-element/states.md
## Article Content:
import { Property, PropertyList, ExpandableSection } from "@wix/docs-ui/content";
# States
__Alpha:__
Editor React Components are currently in alpha. This feature is subject to change and may have bugs, issues, and limitations. We're actively improving it based on your feedback.
The `states` property lets you define conditions that Wix users can style independently in the editor, such as hover, disabled, and loading. Each key in the `states` map is the **state key**, and you use it to reference the state in `statesDefaultValues`, [display filters](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/editor-react-components/manifest-reference/editor-element/display-filters.md), and [style overrides](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/editor-react-components/manifest-reference/editor-element/presets.md).
## Where to define
{/* TODO: when refElements are supported, add here */}
You can define `states` in [`editorElement`](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/editor-react-components/manifest-reference/editor-element/editor-element.md) and in [`elements`](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/editor-react-components/manifest-reference/editor-element/elements.md) of type `inlineElement`.
**Tip:** You can filter which states appear in the editor using [`displayFilters`](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/editor-react-components/manifest-reference/editor-element/display-filters.md) at the preset or element level.
## CSS style defaults for states
To set default CSS values that the design panel shows when a state is active, use `statesDefaultValues` on your `cssProperties` or `cssCustomProperties` items. The key names must match state keys defined in the `states` map. See the [`statesDefaultValues` example](#statesdefaultvalues) below.
## State item properties
Each item in the `states` map accepts the following properties:
Applied when a user's pointer is over the element. Maps to CSS :hover.>}
/>
Applied when the element has received focus. Maps to CSS :focus.>}
/>
Applied when the element is disabled. Maps to CSS :disabled.>}
/>
Applied when the element's value fails validation. Maps to CSS :invalid.>}
/>
DisplayFilters>}.md
description="Controls which CSS properties, elements, data items, and custom actions are visible in the editor when this state is active. Applied last, after element and preset filters."
/>
## Visible state
The `visibleState` property is defined on elements to control an element's visibility based on a state defined on another element. When used, both fields are required.
## Examples
### statesDefaultValues
Setting default CSS values per state. When a Wix user selects the hover state in the design panel, `backgroundColor` shows `#f0f0f0` instead of `#ffffff`.
```typescript
editorElement: {
cssProperties: {
backgroundColor: {
defaultValue: '#ffffff',
statesDefaultValues: {
hover: '#f0f0f0',
},
},
},
states: {
hover: { displayName: 'Hover' },
},
}
```
### Open dropdown state
The following defines a state that opens a dropdown so that its inner elements are visible on stage.
```typescript
editorElement: {
states: {
openDropDown: {
displayName: 'Open Drop Down',
props: {
open: true,
},
},
},
}
```
### Loading state with className
The following defines a loading state with a `className` for styling and `props` to activate it on stage.
```typescript
editorElement: {
states: {
loadingState: {
displayName: 'Loading Data',
className: 'loading',
props: {
loading: true,
},
},
},
}
```
### Hover state with pseudoClass
The following defines a hover state. The `pseudoClass` handles `:hover` on the live site, while the `props` field allows the component to apply hover styles on the editor stage. Your CSS must target both.
```typescript
editorElement: {
states: {
hover: {
displayName: 'Hover',
className: 'elementHover',
pseudoClass: 'hover',
props: {
hovered: true,
},
},
},
}
```
```css
.element.elementHover,
.element:hover {
/** YOUR CSS FOR HOVER STATE */
}
```
### Display filters
The following defines a button hover state that only shows specific CSS properties and hides certain data items when the state is selected.
```typescript
editorElement: {
states: {
buttonHover: {
displayName: 'Button Hover',
className: 'btn-hover-state',
pseudoClass: 'hover',
props: {
variant: 'primary',
size: 'large',
disabled: false,
loading: false,
},
displayFilters: {
cssProperties: {
show: ['backgroundColor', 'borderColor', 'color', 'transform'],
},
data: {
hide: ['advancedOptions', 'debugSettings'],
},
},
},
},
}
```
### Visible state
The following shows a `visibleState` configuration on an inner element, making it visible only when the `showAdvanced` state is active on the element at `/settingsPanel/advancedOptions`.
```typescript
editorElement: {
elements: {
myElement: {
elementType: 'inlineElement',
inlineElement: {
selector: '.my-element',
displayName: 'My Element',
visibleState: {
stateKey: 'showAdvanced',
elementPath: '/settingsPanel/advancedOptions',
},
},
},
},
}
```
### States with CSS style defaults
The following defines a `border` property with a dashed green default and a solid red override for the error state.
```typescript
editorElement: {
cssProperties: {
border: {
displayName: 'Main component Border',
defaultValue: 'dashed 2px green',
statesDefaultValues: {
error: 'solid 2px red',
},
},
},
states: {
error: {
displayName: 'Error',
},
},
}
```
## See also
- [States](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/editor-react-components/manifest-reference/editor-element/states.md)