<cs-option>
StableFormsSince 0.1

Options represent the individual choices inside a select or similar form control. Each option holds a value and the label shown to the user.

This component must be used as a child of <cs-select>. Please see the Select docs to see examples of this component in action.

Espresso Cortado Cappuccino

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/option/option.js';
import './cornerstone/components/option/option.js';
import CsOption from '@cruglobal/cornerstone-components/react/option/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The option's label.
endAn element, such as <cs-icon>, placed after the label.
startAn element, such as <cs-icon>, placed before the label.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
defaultLabelThe default label, generated from the element contents. Will be equal to label in most cases.string
defaultSelectedselectedSelects an option initially.booleanfalse
disableddisabledDraws the option in a disabled state, preventing selection.booleanfalse
labellabelThe option’s plain text label. Usually automatically generated, but can be useful to provide manually for cases involving complex content.string
valuevalueThe option's value. When selected, the containing form control will receive this value. The value must be unique from other options in the same group. Values may not contain spaces, as spaces are used as delimiters when listing multiple values.string''Yes

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--current-text-colorThe text color of the current (highlighted) option, paired with --cs-form-control-activated-color.

Custom States

Learn more about custom states.

NameDescriptionCSS selector
currentThe user has keyed into the option, but hasn't selected it yet (shows a highlight):state(current)
disabledApplied when the option is disabled:state(disabled)
hoverLike :hover but works while dragging in Safari:state(hover)
selectedThe option is selected and has aria-selected="true":state(selected)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
checked-iconThe checked icon, a <cs-icon> element.::part(checked-icon)
endThe container that wraps the end slot.::part(end)
labelThe option's label.::part(label)
startThe container that wraps the start slot.::part(start)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.