> ## Documentation Index
> Fetch the complete documentation index at: https://rive-transitions-2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Enums

> Use enums to control states, modes, and variants by selecting from a predefined set of options.

export const YouTube = ({id, timestamp}) => {
  const videoSrc = timestamp ? `https://www.youtube.com/embed/${id}?start=${timestamp}` : `https://www.youtube.com/embed/${id}`;
  return <iframe width="100%" height="400" src={videoSrc} title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerPolicy="strict-origin-when-cross-origin" allowFullScreen />;
};

export const Marketplace = ({href, children}) => {
  const hrefWithTracking = `${href}?utm_source=docs&utm_medium=docs_link_card&utm_campaign=docs_to_marketplace_links`;
  return <Card title="Learn by remixing" icon="external-link" href={hrefWithTracking} arrow="true" horizontal>
      {children ? children : "Open this file on Marketplace, then click Remix to experiment in the Rive Editor."}

    </Card>;
};

<YouTube id="DgDBjxWl8Aw" />

An enum lets you choose one value from a predefined set of options.

Use enums when a property should only ever be one of a few known values—like modes, states, or variants—instead of allowing any arbitrary value like a string.

For example, instead of using a string like "left", "center", or "right", an enum guarantees the value is always one of those valid options.

<img src="https://mintcdn.com/rive-transitions-2/RVzTL3yYggO5OStL/images/editor/data-binding/property-types/enum-preview.gif?s=b0ce528c0affc6ddd67808ab3ca4ec41" alt="Enums" width="640" height="172" data-path="images/editor/data-binding/property-types/enum-preview.gif" />

Enums can be:

* System enums — built-in sets of options used by the editor (for example, Horizontal Align)
* [Custom enums](#custom-enums) — your own defined sets of options for your specific use case

<Marketplace href="https://rive.app/community/files/27312-control-editor-properties-with-enums" />

<Note>
  **Why not use strings or numbers?**

  Imagine a calendar app that shows different backgrounds based on the day of the week.

  You could use a string like "Monday", but it breaks if someone sets it to "Mon".

  You could use a number, but it’s unclear whether the week starts on Sunday or Monday—or whether the index starts at 0 or 1.

  With an enum, the value must be one of the defined options, so it’s always valid and unambiguous.
</Note>

## Adding an enum property

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/property-types/add-enum.gif?s=a52d2efcee3ca9cf39e9253eb484c90f" alt="Enums" width="640" height="298" data-path="images/editor/data-binding/property-types/add-enum.gif" />

<Steps>
  <Step title="Create a new enum property">
    Create a new enum view model property inside your view model.
  </Step>

  <Step title="Set the enum type">
    Click the dropdown next to the property name and select an enum type.
  </Step>

  <Step title="Set the default enum value">
    Select your enum view model property and in the right sidebar, select the default value.
  </Step>
</Steps>

## Binding enums

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/property-types/binding-enums.gif?s=b88758bd0a9fecf49f7d7714008b7cdc" alt="Bind an enum" width="640" height="246" data-path="images/editor/data-binding/property-types/binding-enums.gif" />

Enums can be bound to editor properties that use the same set of options. For example, an enum named “Layout Direction” can be bound to a layout’s Direction property.

When binding enums, the System Enum to Uint converter is required and is applied automatically.

## Custom enums

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/property-types/custom-enum.gif?s=617012d18cb5cc469a6999a97589828c" alt="Create custom enum" width="640" height="307" data-path="images/editor/data-binding/property-types/custom-enum.gif" />

<Steps>
  <Step title="Create a new enum">
    Open the Data panel, click the `+` icon and select enum.
  </Step>

  <Step title="Add enum options">
    With your enum selected, click the `+` icon in the right sidebar.
  </Step>

  <Step title="Assign the enum to a property">
    Assign your custom enum to your enum view model property.
  </Step>
</Steps>

## Controlling Solos with enums

Use an enum to control which Solo is active by mapping each enum value to a Solo.

<img src="https://mintcdn.com/rive-transitions-2/pUWAhxU9qubdBvIR/images/editor/data-binding/property-types/bind-enum-to-solo.gif?s=942fdb6805fd7a6cd26366c195e5e09a" alt="Bind enum to solo" width="640" height="223" data-path="images/editor/data-binding/property-types/bind-enum-to-solo.gif" />

<Steps>
  <Step title="Create a matching enum"> Create a [custom enum](#custom-enums) with values that match the **names and order** of your Solos. </Step>

  <Step title="Export names">
    [Export the names](/editor/exporting/exporting-names) of the objects used by the Solo so they are accessible at runtime.
  </Step>

  <Step title="Bind the enum"> Bind the enum to the Solo’s **Active** property and apply a **Convert to Number** converter. </Step>
</Steps>
