Option
<ahi-option> | AhiOption
Options define the selectable items within various form controls such as select.
<ahi-select label="Select one">
<ahi-option value="option-1">Option 1</ahi-option>
<ahi-option value="option-2">Option 2</ahi-option>
<ahi-option value="option-3">Option 3</ahi-option>
</ahi-select>
Examples
Disabled
Use the disabled attribute to disable an option and prevent it from being selected.
<ahi-select label="Select one">
<ahi-option value="option-1">Option 1</ahi-option>
<ahi-option value="option-2" disabled>Option 2</ahi-option>
<ahi-option value="option-3">Option 3</ahi-option>
</ahi-select>
Prefix and suffix
Add icons to the start and end of menu items using the prefix and suffix slots.
<ahi-select label="Select one">
<ahi-option value="email">
<ahi-icon slot="prefix" name="mail"></ahi-icon>
Email
<ahi-icon slot="suffix" name="circle-check"></ahi-icon>
</ahi-option>
<ahi-option value="phone">
<ahi-icon slot="prefix" name="phone"></ahi-icon>
Phone
<ahi-icon slot="suffix" name="circle-check"></ahi-icon>
</ahi-option>
<ahi-option value="chat">
<ahi-icon slot="prefix" name="message"></ahi-icon>
Chat
<ahi-icon slot="suffix" name="circle-check"></ahi-icon>
</ahi-option>
</ahi-select>
Importing
To import this component using a script tag:
<script type="module" src="/path/to/azalea-kit-ui/dist/components/option/option.js"></script>
To import this component using a bundler:
import '@azaleahealth/azalea-kit-ui/dist/components/option/option.js';
Slots
| Name | Description |
|---|---|
| (default) | The option’s label. |
prefix
|
Used to prepend an icon or similar element to the menu item. |
suffix
|
Used to append an icon or similar element to the menu item. |
Learn more about using slots.
Properties
| Name | Description | Type | Default | |
|---|---|---|---|---|
value
|
The option’s value. When selected, the containing form control will receive this value. The value
must be unique from other options in the same control. Values may contain any characters, including
spaces — but a value with spaces can’t be targeted by the control’s space-delimited
value attribute (assign an array to the value
property instead).
|
string
|
''
|
|
disabled
|
Draws the option in a disabled state, preventing selection. |
boolean
|
false
|
|
updateComplete |
A read-only promise that resolves when the component has finished updating. |
Learn more about properties and attributes.
Methods
| Name | Description | Arguments |
|---|---|---|
getTextLabel() |
Returns a plain text label based on the option’s content. | - |
Learn more about methods.
CSS Parts
| Name | Description |
|---|---|
base |
Deprecated. Use the option part instead. |
option |
The component’s outer wrapper. |
checked-icon |
The checked icon, an <ahi-icon> element. |
label |
The option’s label. |
prefix |
The container that wraps the prefix. |
suffix |
The container that wraps the suffix. |
Learn more about customizing CSS parts.
Dependencies
This component automatically imports the following dependencies.
<ahi-icon>