Select

Select a value from a list of options.

Installation

ng g @spartan-ng/cli:ui select

Usage

import { HlmSelectImports } from '@spartan-ng/helm/select';
<hlm-select>
	<hlm-select-trigger>
		<hlm-select-value placeholder="Select a fruit" />
	</hlm-select-trigger>
	<hlm-select-content *hlmSelectPortal>
		<hlm-select-group>
			<hlm-select-label>Fruits</hlm-select-label>
			@for (item of items; track item.value) {
				<hlm-select-item [value]="item.value">{{ item.label }}</hlm-select-item>
			}
		</hlm-select-group>
	</hlm-select-content>
</hlm-select>
@import '@angular/cdk/overlay-prebuilt.css';

Examples

Groups

Multiple

Scrollable

Disabled

Object values

Placeholder

Use hlm-select-placeholder to display a custom placeholder when no value is selected. If you only display a text as placeholder, you can also use the placeholder input on hlm-select-value .

Form

Brain API

BrnSelectContent

Selector: [brnSelectContent]

BrnSelectGroup

Selector: [brnSelectGroup]

BrnSelectItem

Selector: [brnSelectItem]

Inputs

PropTypeDefaultDescription
id string `brn-select-item-${++BrnSelectItem._id}` A unique id for the item
value* (required) T - The value this item represents.
disabled boolean false -

BrnSelectLabel

Selector: [brnSelectLabel]

Inputs

PropTypeDefaultDescription
id string `brn-select-label-${++BrnSelectLabel._id}` -

BrnSelectList

Selector: [brnSelectList]

BrnSelectMultiple

Selector: [brnSelectMultiple]

Inputs

PropTypeDefaultDescription
disabled boolean false Whether the combobox is disabled
isItemEqualToValue SelectItemEqualToValue<T> this._config.isItemEqualToValue A function to compare an item with the selected value.
itemToString SelectItemToString<T> | undefined this._config.itemToString A function to convert an item to a string for display.
value T[] | null null The selected value of the select.

Outputs

PropTypeDefaultDescription
valueChange T[] | null null The selected value of the select.

BrnSelectPlaceholder

Selector: [brnSelectPlaceholder]

BrnSelectScrollDown

Selector: [brnSelectScrollDown]

BrnSelectScrollUp

Selector: [brnSelectScrollUp]

BrnSelectSeparator

Selector: [brnSelectSeparator]

Inputs

PropTypeDefaultDescription
orientation 'horizontal' | 'vertical' horizontal -

BrnSelectTriggerWrapper

Selector: [brnSelectTriggerWrapper]

BrnSelectTrigger

Selector: button[brnSelectTrigger]

Inputs

PropTypeDefaultDescription
id string `brn-select-trigger-${++BrnSelectTrigger._id}` -

BrnSelectValueTemplate

Selector: [brnSelectValueTemplate]

BrnSelectValue

Selector: [brnSelectValue]

Inputs

PropTypeDefaultDescription
placeholder string --

BrnSelectValues

Selector: [brnSelectValues]

BrnSelect

Selector: [brnSelect]

Inputs

PropTypeDefaultDescription
disabled boolean false Whether the select is disabled
isItemEqualToValue SelectItemEqualToValue<T> this._config.isItemEqualToValue A function to compare an item with the selected value.
itemToString SelectItemToString<T> | undefined this._config.itemToString A function to convert an item to a string for display.
value T | null null The selected value of the select.

Outputs

PropTypeDefaultDescription
valueChange T | null null The selected value of the select.

Helm API

HlmSelectContent

Selector: hlm-select-content

Inputs

PropTypeDefaultDescription
showScroll boolean false -

HlmSelectGroup

Selector: [hlmSelectGroup],hlm-select-group

HlmSelectItem

Selector: hlm-select-item

HlmSelectLabel

Selector: [hlmSelectLabel],hlm-select-label

HlmSelectMultiple

Selector: [hlmSelectMultiple],hlm-select-multiple

HlmSelectPlaceholder

Selector: [hlmSelectPlaceholder],hlm-select-placeholder

HlmSelectPortal

Selector: [hlmSelectPortal]

HlmSelectScrollDown

Selector: hlm-select-scroll-down

HlmSelectScrollUp

Selector: hlm-select-scroll-up

HlmSelectSeparator

Selector: [hlmSelectSeparator],hlm-select-separator

HlmSelectTrigger

Selector: hlm-select-trigger

Inputs

PropTypeDefaultDescription
class ClassValue --
buttonId string `hlm-select-trigger-${HlmSelectTrigger._id++}` -
size 'default' | 'sm' default -

HlmSelectValueTemplate

Selector: [hlmSelectValueTemplate]

HlmSelectValue

Selector: [hlmSelectValue],hlm-select-value

HlmSelectValuesContent

Selector: [hlmSelectValuesContent],hlm-select-values-content

HlmSelectValues

Selector: [hlmSelectValues]

HlmSelect

Selector: [hlmSelect],hlm-select

Separator Scroll Area