Skip to main content
Version: v4

Single Select

Overview

The CometChatSingleSelect component is a customizable Single Select component that allows you to choose one option from a list of box-structured options. It extends from the LitElement's base class.

While this design allows an intuitive interaction similar to radio buttons, its unique box-style presentation provides a distinctive user experience. If only two options are provided, they are displayed side-by-side. For more than two options, they are displayed vertically.

Attributes

NameTypeDescription
namestringUnique identifier for the Single Select component.
optionsArray<string>An array of strings providing the options available to select.
selectedOptionstringA string representing the currently selected option.
selectStyleSingleSelectStyleAn instance of the SingleSelectStyle class for customizing the Single Select component's style.

SingleSelectStyle

The appearance of the CometChatSingleSelect component is controlled via the selectStyle attribute, which takes an instance of the SingleSelectStyle class.

NameDescription
textFontThe font of the text.
textColorThe color of the text.
optionBackgroundThe background color of an option.
optionBorderThe border of an option.
optionBorderRadiusThe border radius of an option.
hoverTextFontThe font of the text when an option is hovered.
hoverTextColorThe color of the text when an option is hovered.
hoverTextBackgroundThe background of an option when hovered.
activeTextBackgroundThe background of the selected option.
activeTextColorThe color of the selected option.
activeTextFontThe font of the selected option.

Events

NameDescription
cc-single-select-changedThis event is dispatched when an option is selected. The event's detail property will contain an object with a value property representing the selected option.

Usage

<cometchat-single-select
[name]="'mySingleSelect'"
[options]="['Option 1', 'Option 2', 'Option 3']"
[selectedOption]="'Option 1'"
[selectStyle]="selectStyle"
(cc-single-select-changed)="changeHandler($event)"
></cometchat-single-select>