Option
<afp-option>
An option component to be used within an AfpSelect.
Examples #
Value #
The value attribute can be used to identify the option when it is clicked.
Checked #
Use the checked attribute to indicate the checked state of the option.
Closeable #
Use the closeable attribute to add a close button to the option.
Disabled #
Use the disabled attribute to disable the option.
Custom Icons #
Use the check-icon and close-icon slots to provide custom icons for the checked and close states.
Properties
Learn more about properties.
| Name | Description | Reflects | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
value
|
The value associated with the option. This is emitted with the afp-click event.
Type
string
|
|||||||||
checked
|
Indicates whether the option is checked.
Type
boolean
Default
false |
|
||||||||
disabled
|
Indicates whether the option is disabled.
Type
boolean
Default
false |
|
||||||||
closeable
|
Indicates whether the option is closeable.
Type
boolean
Default
false |
|||||||||
size
|
Size of the option.
Type
AfpSize
Default
AfpSize.MEDIUM |
|
Methods
Learn more about using methods.
| Name | Description | Arguments |
|---|---|---|
focus
|
Sets focus on the option component.
|
options<FocusOptions>
— Focus options.
|
getClonedContentNodes
|
Returns cloned content nodes of the option component, excluding empty text nodes.
Return
Node[] |
- |
Events
Learn more about events.
| Name | Return | Description |
|---|---|---|
afp-click
|
string
|
Emitted when the option is clicked.
|
afp-close
|
void
|
Emitted when the option's close icon is clicked. Only emitted if the option is closeable.
|
Slots
Learn more about slots.
| Name | Description |
|---|---|
default
|
The default slot.
|
check-icon
|
Slot to replace the default check icon.
|
close-icon
|
Slot to replace the default close icon.
|
Internationalization
Learn more about internationalization.
| Key | Description |
|---|---|
option.close-button.aria-label
|
The default `aria-label` text for the option close icon.
|
CSS Parts
Learn more about CSS Parts.
| Name | Description | Selector |
|---|---|---|
base
|
The component's base wrapper.
|
::part(base)
|
content
|
The content wrapper.
|
::part(content)
|
checked
|
The checked icon wrapper.
|
::part(checked)
|
check-icon
|
The check icon.
|
::part(check-icon)
|
label
|
The label wrapper.
|
::part(label)
|
close-button
|
The close icon wrapper.
|
::part(close-button)
|
close-icon
|
The close icon.
|
::part(close-icon)
|
actions
|
The wrapper for the checked and close icons.
|
::part(actions)
|
CSS Custom Properties
| Name | Description | Default |
|---|---|---|
--afp-option-checked-min-width
|
The minimum width of the checked icon area.
|
1.125rem
|
--afp-option-disabled-opacity
|
The opacity of a disabled option.
|
0.5
|
Dependencies
The component automatically brings in the listed items, including any nested dependencies that may exist.
| Component | CSS Part Prefix |
|---|---|
|
|
check-icon
- The check icon.
close-icon
- The close icon.
|
|
|
close-button
- The close icon wrapper.
|
Importing
Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.
import '@afp-design-system/core/dist/components/option/option.js';