# Dropdown - Single Select

The Dropdown - Single Select lets users pick one option from a predefined list. It is ideal for forms and filters where only one choice is valid, offering a compact and user-friendly way to streamline selections.

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FXZPKSaxmYSbIKynE9hJn%2Fimage.png?alt=media&#x26;token=12c18aff-fad9-4b53-bcba-58ef91ba6d42" alt=""><figcaption></figcaption></figure>

{% tabs %}
{% tab title="Component React" %}

```
// Sample code

    <Dropdown
                  style={}
                  variant={error ? "error" : ""}
                  t={t}
                  option={projectType?.["HCM-PROJECT-TYPES"]?.projectTypes}
                  optionKey={"code"}
                  selected={type}
                  select={(value) => {
                    handleChange(value);
                  }}
                  disabled = {false}
                />
```

{% endtab %}

{% tab title="Component Flutter" %}

```
// Sample code

DigitDropdown<int>(
            isDisabled: false,
            onSelect: (item) => {},
            dropdownController: TextEditingController(),
            isSearchable: false,
            items: [
              'one',
              'two',
              'three',
              'four',
            ]
                .asMap()
                .entries
                .map(
                  (item) => DropdownItem(
                    name: item.value,
                    code: item.key.toString(),
                  ),
                )
                .toList(),
          ),
```

{% endtab %}

{% tab title="Component Design" %}

{% endtab %}
{% endtabs %}

## Anatomy

***

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FK549ZGr734NVQh2Mz6IB%2Fimage.png?alt=media&#x26;token=ca372469-55fc-410d-968b-159c67a828ef" alt=""><figcaption></figcaption></figure>

## Variants

***

<table data-header-hidden><thead><tr><th width="321"></th><th></th></tr></thead><tbody><tr><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FHF9AZ6qcq3M6msr0d3Sd%2Fimage.png?alt=media&#x26;token=f5008a41-5937-45eb-82f1-bee34abaac3e" alt=""><figcaption></figcaption></figure></div></td><td><p><strong>Basic Dropdown</strong></p><p>The Basic Dropdown serves as a standard selection tool, displaying a list of options when triggered. It is ideal for simple use cases such as selecting a city, category, or value from a list. This variant focuses on clarity and ease of interaction, offering a clean and accessible way to choose a single option.</p></td></tr><tr><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FD52bGzZi0QpBXfq70EQR%2Fimage.png?alt=media&#x26;token=c7b8a8d2-2a09-4a72-bdf4-ee31c7b9d089" alt=""><figcaption></figcaption></figure></div></td><td><strong>Categorical Dropdown</strong><br>The Categorical Dropdown introduces grouped options within the dropdown menu. This structure is suitable for cases where options belong to distinct categories, such as departments, regions, or job types. Each category acts as a label, visually separating options to enhance scannability and reduce cognitive load.</td></tr><tr><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2F88jtU5gkdtWcchBR05Fp%2Fimage.png?alt=media&#x26;token=ecb6844b-d96c-4a5d-8896-4578aaf2df08" alt=""><figcaption></figcaption></figure></div></td><td><p><strong>Nested Text Dropdown</strong></p><p>This enables sub-options to be embedded within a main option, providing an expandable hierarchy of selections. This is useful when each primary option leads to further granularity, such as a parent category leading to subcategories. It keeps the UI clean while supporting detailed selection paths.</p></td></tr><tr><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FGOCapjrFKpwcWBdb2jCK%2Fimage.png?alt=media&#x26;token=0b4f665b-bc1a-4b58-ac42-1561c6ea8d91" alt=""><figcaption></figcaption></figure></div></td><td><p><strong>Profile Dropdown</strong></p><p>The Profile Dropdown is designed to display user-related actions and information, typically accessed via an avatar or username. It includes quick links such as account settings, profile view, and logout. This variant is focused on user personalization and session management in an application.</p></td></tr><tr><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FGcbd1MmRGgIjonxYlouc%2Fimage.png?alt=media&#x26;token=35cbc0b2-b7a0-45e7-89e9-a4acafa21b02" alt=""><figcaption></figcaption></figure></div></td><td><p><strong>Profile with Nested Text Dropdown</strong></p><p>This variant extends the Profile Dropdown by incorporating nested items for more structured user options. Sub-options can be organized under primary sections, enabling users to access layered account controls efficiently.</p></td></tr><tr><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FTbLIFq2IOdagfHrLZx8P%2Fimage.png?alt=media&#x26;token=079d68a6-9e6d-41d0-933d-8c5631424030" alt=""><figcaption></figcaption></figure></div></td><td><p><strong>Tree Dropdown</strong></p><p>The Tree Dropdown supports multi-level branching, allowing users to drill down into deeply nested structures. It is ideal for navigating hierarchical datasets such as file systems, organisational structures, or nested location data. Each node can expand independently, helping users locate items without overwhelming the interface.</p></td></tr><tr><td></td><td></td></tr></tbody></table>

## Properties

<table data-header-hidden data-full-width="false"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>Disabled</strong><br>A greyed-out, inactive selector showing unavailable options while maintaining visibility of potential choices.<br></td><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FASI4tN6JFE5BMKBajgnZ%2Fimage.png?alt=media&#x26;token=c3785f94-6c33-4f2b-8f1e-19a3e7838632" alt=""><figcaption></figcaption></figure></div></td></tr><tr><td><strong>Error</strong><br>Visually highlights invalid selections with warning colours and messages to prompt user correction.</td><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FP05m3KCZO70AXmeDEQyz%2Fimage.png?alt=media&#x26;token=894dc145-1b02-4a46-ace9-417a0b6ad25a" alt=""><figcaption></figcaption></figure></div></td></tr><tr><td><p><strong>Icon</strong></p><p>An optional visual cue inside the dropdown that represents the selection type, improving recognition and UI scannability at a glance.</p></td><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FZ9uZa3KEZZee6ufx3t0r%2Fimage.png?alt=media&#x26;token=5344c331-15d7-4912-bb9d-eca7ba46df47" alt=""><figcaption></figcaption></figure></div></td></tr><tr><td><p><strong>Label</strong></p><p>A clear, short identifier placed consistently near the selector to indicate its purpose.</p></td><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FtnaR00RA9kMAhBGqwPCd%2Fimage.png?alt=media&#x26;token=ff2fff6c-fb2c-4ce0-afa4-1214577835e0" alt=""><figcaption></figcaption></figure></div></td></tr><tr><td><p><strong>Help Text</strong></p><p>Optional guidance below the dropdown that explains requirements or provides examples without crowding the UI.</p></td><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FqOF4oHPLrsUDByN4V5OQ%2Fimage.png?alt=media&#x26;token=697dbf9b-3c85-4cfd-875e-f502d71305ec" alt=""><figcaption></figcaption></figure></div></td></tr></tbody></table>

## Property Configuration Table

Each design component offers a range of configurable options. These options are intentionally platform-agnostic, allowing implementations to adapt and tailor them to align with the specific requirements of the chosen framework.

{% tabs %}
{% tab title="React" %}

<table><thead><tr><th width="257">Property</th><th>Value</th><th>Default</th></tr></thead><tbody><tr><td>option</td><td>text</td><td>-</td></tr><tr><td>variant</td><td>text</td><td>no</td></tr><tr><td>id</td><td>yes/no</td><td>no</td></tr><tr><td>placeholder</td><td>yes/no</td><td>-</td></tr><tr><td>onBlur</td><td>number</td><td>-</td></tr><tr><td>optionKey</td><td>yes/no</td><td>-</td></tr><tr><td>showIcon</td><td>yes/no</td><td>no</td></tr><tr><td>className</td><td>yes/no</td><td>no</td></tr><tr><td>style</td><td>yes/no</td><td>no</td></tr><tr><td>profilePic</td><td>number</td><td>no</td></tr><tr><td>theme</td><td>yes/no</td><td>no</td></tr><tr><td>customSelector</td><td></td><td>no</td></tr><tr><td>showArrow</td><td>yes/no</td><td>no</td></tr><tr><td>isSearchable</td><td>yes/no</td><td></td></tr><tr><td>disabled</td><td>yes/no</td><td></td></tr><tr><td>keepNull</td><td>yes/no</td><td></td></tr><tr><td>freeze</td><td>yes/no</td><td></td></tr><tr><td>ref</td><td>yes/no</td><td></td></tr><tr><td>showTooltip</td><td>yes/no</td><td></td></tr><tr><td>showBottom</td><td>yes/no</td><td></td></tr><tr><td>menuStyles</td><td>yes/no</td><td></td></tr><tr><td>optionCardStyles</td><td>yes/no</td><td></td></tr><tr><td>selected</td><td>yes/no</td><td></td></tr><tr><td>autoFocus</td><td>yes/no</td><td></td></tr><tr><td>select</td><td>yes/no</td><td></td></tr></tbody></table>
{% endtab %}

{% tab title="Flutter" %}

<table><thead><tr><th>Property</th><th width="209">Value</th><th>Default</th></tr></thead><tbody><tr><td>dropdownController</td><td>TextEditingController</td><td>-</td></tr><tr><td>onSelect</td><td>void Function(DropdownItem)</td><td>-</td></tr><tr><td>onTap</td><td>void Function()</td><td>-</td></tr><tr><td>onChange</td><td>void Function(String)</td><td>-</td></tr><tr><td>items</td><td>List</td><td>required</td></tr><tr><td>suffixIcon</td><td>IconData</td><td>-</td></tr><tr><td>selectionType</td><td>SelectionType</td><td></td></tr><tr><td>emptyItemText</td><td>String</td><td>-</td></tr><tr><td>isSearchable</td><td>bool</td><td>-</td></tr><tr><td>selectedOption</td><td>DropdownItem</td><td>-</td></tr><tr><td>readOnly</td><td>bool</td><td>false</td></tr><tr><td>isDisabled</td><td>bool</td><td>false</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

## Interaction State

***

<table data-header-hidden data-full-width="false"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>Hover State</strong><br>When a user hovers over the dropdown trigger, a visual cue such as a border highlight is introduced to indicate interactivity. This subtle shift in appearance signals that the component is actionable. The hover state improves discoverability and helps users distinguish interactive elements from static content.<br></td><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FAdttvIdsaLiCfxJBLzdU%2Fimage.png?alt=media&#x26;token=fac9850b-6cf3-4328-b402-7e923ae5face" alt=""><figcaption></figcaption></figure></div></td></tr><tr><td><p><strong>Selected State</strong></p><p>When an option within the dropdown is selected, it is visually highlighted through a background colour fill and bold text style. This state communicates the user’s current choice clearly and supports actions such as re-selection or change. The selected state ensures clarity and reinforces decision-making within the interface.</p></td><td><div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FzbhpPvSRzn15yQFkzXob%2Fimage.png?alt=media&#x26;token=08dbef76-21fa-4835-902a-2a0cadccaf70" alt=""><figcaption></figcaption></figure></div></td></tr></tbody></table>

## Behaviours

|                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fxmy98MVQT7s1copV2nqR%2Fimage.png?alt=media&#x26;token=0f6911e1-bd7d-42a7-b2b9-2165113b9ed3" alt=""><figcaption></figcaption></figure></div> | <p><strong>Expanded State</strong></p><p>When a user clicks or taps on the dropdown, it expands to reveal a list of options. The dropdown remains open until an option is selected or the user clicks outside the dropdown. The selected option is highlighted to indicate the current choice.</p> |
| <div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FphduwhJrUeNUzo2CalbM%2Fimage.png?alt=media&#x26;token=1c40d94d-36c1-49de-a0af-d90ea597b72a" alt=""><figcaption></figcaption></figure></div> | <p><strong>Animation</strong></p><p>The dropdown opens and closes with a smooth "ease-in" animation, enhancing the user experience.</p>                                                                                                                                                            |

***

## Usage Guide

***

| <div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FOTrlAyEUbqUfKiV4kafP%2Fimage.png?alt=media&#x26;token=5e466556-e672-47c7-b960-a03569dbcaae" alt=""><figcaption></figcaption></figure></div> | <p><strong>Use Clear and Concise Labels</strong></p><p>Use descriptive and straightforward labels for the dropdown and its options. This helps users quickly understand the purpose and make informed choices.</p> |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <div><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2FShVrWd3uCJnIxNv0IBMi%2Fimage.png?alt=media&#x26;token=35307022-5252-42e0-8bfd-9d2a0964a37c" alt=""><figcaption></figcaption></figure></div> |                                                                                                                                                                                                                    |

## Changelog

***

| Date         | Number  | Notes                                                                                           |
| ------------ | ------- | ----------------------------------------------------------------------------------------------- |
| Dec 15, 2024 | v-0.0.2 | <p>This component is added to the website.<br>This component is now individually versioned.</p> |

## Design Checklist

***

<table data-header-hidden><thead><tr><th width="129" data-type="checkbox"></th><th></th></tr></thead><tbody><tr><td>true</td><td><strong>All interactive states</strong> - Includes all interactive states that are applicable (hover, down, focus, keyboard focus, disabled).</td></tr><tr><td>true</td><td><strong>Accessible use of colours</strong> - Colour is not used as the only visual means of conveying information (WCAG 2.1 1.4.1)</td></tr><tr><td>true</td><td><strong>Accessible contrast for text</strong> - Text has a contrast ratio of at least 4.5:1 for small text and at least 3:1 for large text (WCAG 2.0 1.4.3).</td></tr><tr><td>true</td><td><strong>Accessible contrast for UI components</strong> - Visual information required to identify components and states (except inactive components) has a contrast ratio of at least 3:1 (WCAG 2.1 1.4.11).</td></tr><tr><td>true</td><td><strong>Keyboard interactions</strong> - Includes all interactive states that are applicable (hover, down, focus, keyboard focus, disabled).</td></tr><tr><td>false</td><td><strong>Screen reader accessible</strong> - All content, including headings, labels, and descriptions, is meaningful, concise, contextual and accessible by screen readers.</td></tr><tr><td>true</td><td><strong>Responsive for all breakpoints</strong> - Responsiveness for 3 breakpoints - Mobile, Tablet and Desktop</td></tr><tr><td>true</td><td><strong>Usage guidelines</strong> - Includes a list of dos and don'ts that highlight best practices and common mistakes.</td></tr><tr><td>false</td><td><strong>Content guidelines</strong> - Content standards and usage guidelines for writing and formatting in-product content for the component.</td></tr><tr><td>true</td><td><strong>Defined variants and properties</strong> - Includes relevant variants and properties (style, size, orientation, optional iconography, decorative elements, selection states, error states, etc.)</td></tr><tr><td>true</td><td><strong>Defined behaviours</strong> - Guidelines for keyboard navigation and focus, layout management (including wrapping, truncation, and overflow), animations, and user interactions.</td></tr><tr><td>true</td><td><strong>Design Kit</strong> - Access to the design file for the component in Figma, multiple options, states, colour themes, and platform scales.</td></tr></tbody></table>
