# Enumerated types

An enumerated type, or *enum*, is a set of key-value pairs used to define constant values in a solution. Enums can be added as [object class properties](https://docs.appfarm.io/reference/object-classes#object-class-properties) and referenced directly from within [apps](https://docs.appfarm.io/reference/apps) and [services](https://docs.appfarm.io/reference/services). As well as defining your own enums, you can access a number of [built-in enums](#undefined).

## Usage

To add an enum to your data model:

* Hover over the **+** icon in the bottom-right of the data model designer.
* Click **Create Enumerated Type**.

A typical use case for an enum is to store possible *State* values for an object, such as *Planned, In Progress*, and *Complete*.

As an example, an `Event` object class might need a property to track if an event has occurred or not. The value of this property can be one of a set of fixed values.

To store these values you can create an enum called `Event State` with three enum values. The values can be given the display names `Planned`, `In Progress` and `Complete`. Once the Event State enum is created, you can add a  `State` property to the Event object class, with the data type `Event State`, tying the enum to the object class.

Enums are suitable for properties where you want to retain full control of the possible values. Within your apps, you can build [conditions](https://docs.appfarm.io/reference/platform-concepts/conditions) and [filters](https://docs.appfarm.io/reference/platform-concepts/filters) bound to such properties, for example a Text Edit component that is visible if `Event.State EQUALS Planned`. You can also see [examples](https://docs.appfarm.io/platform-concepts/functions#examples) of how to use enums in functions.

Enum values are often exposed in the UI using the Select component, enabling the user to view the available options and make a selection.&#x20;

{% hint style="info" %}
**Example**

An enumerated type example is available under [UI Templates](https://showroom-dev.appfarm.app/ui-templates/) in our [Showroom](https://showroom-dev.appfarm.app/). Click on **Dialog - New Issue**. In the dialog that opens, **Category** is populated by an enum. Don't have access? [Register](https://showroom.appfarm.app/sign-up).
{% endhint %}

## Properties

<table><thead><tr><th width="196">Property</th><th>Description</th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>A descriptive name for the enum.</td></tr><tr><td><strong>Data Type</strong></td><td><p>The data type of the <a href="#enum-values">enum values</a>. This property becomes read only after enum values are added. The options are:</p><ul><li><code>Auto</code>: Each enum value is assigned an automatically generated value. This option should be selected in most cases.</li><li><code>String</code>: Each enum value can be assigned a custom string.</li><li><code>Integer</code>: Each enum value can be assigned a custom integer. </li></ul><p>The string and integer types are useful if the values should be readable, or if you are integrating towards external systems with existing values that the solution needs to understand.</p></td></tr><tr><td><strong>Description</strong></td><td>A longer description of the enum. For your own reference.</td></tr><tr><td><strong>Tags</strong></td><td>Add <a href="..#tags">tags</a>.</td></tr><tr><td><strong>Enum Values</strong></td><td>Add <a href="#enum-values">enum values</a>.</td></tr></tbody></table>

### Enum values

Enum values are the key-value pairs, or available options, within an enum.&#x20;

<table><thead><tr><th width="201">Property</th><th>Description</th></tr></thead><tbody><tr><td><strong>Display Name</strong></td><td>The label to display in the UI. This name is also used to refer to the enum value throughout Appfarm Create.</td></tr><tr><td><strong>Value</strong></td><td>The value to store in the database when this enum value is chosen, in the format selected under <strong>Data Type</strong>. If the data type is <code>Auto</code>, this value will be automatically generated and read-only.</td></tr><tr><td><strong>Icon</strong></td><td>An icon from the built-in icon library to represent the enum value. The icon can be displayed in the UI, such as in a <a href="../../library/ui-components/list">List</a>, <a href="../../library/ui-components/table">Table</a> or <a href="../../library/ui-components/map">Map</a>.</td></tr><tr><td><strong>Color</strong></td><td>A color to represent the enum value. The color can be used to style the color of the Icon (see setting above) or it may be used for defining the color or the (grouping) category of Charts. <br><em>Example: Product Category is an Enumerated Type with different color for each Enum value. A graph displaying sales per product category may have the color of each data series in the graph controlled by the Enum color of each Product Category.</em></td></tr><tr><td><strong>Dark Theme Color</strong></td><td>A color to represent the enum value when a dark theme is applied. If not specified, <strong>Color</strong> will be used.</td></tr><tr><td><strong>Description</strong></td><td>A longer description of the enum value that can be displayed in the UI.</td></tr></tbody></table>

## Built-in enums

Appfarm has a set of built-in enumerated types. These can be referenced in the same way as a normal enum, but the values can not be changed. The built-in enums are used for [app variables](https://docs.appfarm.io/reference/apps/data/app-variables) and [service variables](https://docs.appfarm.io/services#data).

<table><thead><tr><th width="221">Enum</th><th>Description</th></tr></thead><tbody><tr><td><strong>Appfarm Environment</strong></td><td>The four environments: <code>Develop</code>, <code>Test</code>, <code>Staging</code>, and <code>Production</code>.</td></tr><tr><td><strong>Device Orientation</strong></td><td>The two possible device orientations: <code>Portrait</code> and <code>Landscape</code>.</td></tr><tr><td><strong>Device OS</strong></td><td>A set of possible operating systems: <code>Android</code>, <code>iOS</code>, <code>iPad OS</code>, <code>Mac OS</code>, <code>Windows</code> and <code>Other</code>.</td></tr><tr><td><strong>Language</strong></td><td>The languages added to the solution under <a href="../resources/internationalization">Internationalization</a>. For example, <code>English</code> and <code>Norwegian</code>.</td></tr><tr><td><strong>Object State</strong></td><td>The synchronization state of an object: <code>New</code>, <code>Updated</code>, and <code>Synchronized</code>.</td></tr><tr><td><strong>Screen Size</strong></td><td>The four possible screen sizes: <code>Large</code>, <code>Medium</code>, <code>Small</code>, and <code>Extra Small</code>.</td></tr><tr><td><strong>Theme</strong></td><td>The themes added to the solution under <a href="../resources/themes">Themes</a>.</td></tr><tr><td><strong>Time Zone</strong></td><td>World timezones. For example, <code>Australia/Melbourne</code>.</td></tr><tr><td><strong>View</strong></td><td>The <a href="../apps/ui/views">views</a> in the active app.</td></tr></tbody></table>
