Skip to main content
2.0.0Next2.0.92.0.82.0.72.0.62.0.52.0.42.0.32.0.22.0.12.0.01.0.0
Version: 2.0.0

Select

The Select component is an input field where the user can select between multiple predefined options, instead of manually typing. This is useful to restrict the user's options to valid values. The options will display in a dropdown bellow the input field on click. A default value can be preselected for the user, in cases where this is useful.

Basic Usage

<triton-select label="Normal select" placeholder="Select Country">
<triton-option value="norway">Norway</triton-option>
<triton-option value="sweden">Sweden</triton-option>
</triton-select>
<TritonSelect label="Normal select" placeholder="Select Country">
<TritonOption value="norway">Norway</TritonOption>
<TritonOption value="sweden">Sweden</TritonOption>
</TritonSelect>
<html> 
<head>
<script type="module">
import { defineCustomElements } from '~node_modules/@kognifai/triton-cl-core/loader/index.es2017.js';
defineCustomElements();
</script>
</head>
<body>
<triton-select label="Normal select" placeholder="Select Country">
<triton-option value="norway">Norway</triton-option>
<triton-option value="sweden">Sweden</triton-option>
</triton-select>
</body>
</html>
NorwaySweden

Appearance

Custom Options

The selectable options can be customized, for example by using a TritonIcon element.

GaugeAccessTableBorder TypeBoxBroadcast
<triton-select label="Select icon">
<triton-option><triton-icon symbol="gauge"></triton-icon>Gauge</triton-option>
<triton-option><triton-icon symbol="access"></triton-icon>Access</triton-option>
...
</triton-select>

Playground

Feedbacktothisdocumentationiswelcome!
GaugeAccessTable

API

Properties

triton-select

PropertyDescriptionTypeDefault
autocompleteA DOMString providing a hint for a users autocomplete feature. See the HTML autocomplete attribute for a complete list of values and detailsbooleanfalse
disabledThis Boolean attribute indicates that the user cannot interact with the control. If this attribute is not specified, the control inherits its setting from the containing element, for example fieldset if there is no containing element with the disabled attribute set, then the control is enabled.boolean-
errorIf true, the select element will display as errorbooleanfalse
error-textError text displayed at the bottom of the field, if error is truestring-
formA string specifying the form element with which the input is associated that is, its form owner. This strings value, if present, must match the id of a form element in the same document. If this attribute isnt specified, the input element is associated with the nearest containing form, if any.string-
helper-textA brief text for the user, at the bottom of the fieldstring-
labelThe label displayed for the fieldstring-
nameThis attribute is used to specify the name of the control.stringthis.inputId
placeholderInstructional text that shows before the input has a value.string-
requiredA Boolean attribute indicating that an option with a non-empty string value must be selected.boolean-
autofocusIf true the form control should has focus when the page loads. Only one form element in a document can have the autofocus attribute.booleanfalse
sizeSet the size of the componentbase body large medium small tiny xlarge xxlarge xxxlargedefaultOptions.baseSize
valueThe selected valuestring-

triton-option

PropertyDescriptionTypeDefault
border-colorIf present, this attribute will fill the border color of the select option. This will only work with a parent select with multiple attribute as truestring-
disabledIf this Boolean attribute is set, this option is not checkable. Often browsers grey out such control and it wont receive any browsing event, like mouse clicks or focus-related ones.boolean-
labelThis attribute is text for the label indicating the meaning of the option. If the label attribute isnt defined, its value is that of the element text content.string-
idEMPTYstringtriton-select-option-${componentNumber++}
selectedIf present, this Boolean attribute indicates that the option is initially selected. If the triton-option element is the descendant of a triton-select element whose multiple attribute is not set, only one single triton-option of this triton-select element may have the selected attribute.boolean-
valueThe content of this attribute represents the value to be submitted with the form, should this option be selected. If this attribute is omitted, the value is taken from the text content of the option element.string-

Events

NameTypeDescriptionExtra
atBlurCustomEvent<void>Emitted when the input loses focus-
atChangeCustomEvent<InputValue>Fires when the user selects an option.-
atFocusCustomEvent<void>Emitted when the input has focus-
atInputCustomEvent<void>Fires when the value of an select element has been changed.-

Slots

This slot can only be passed TritonSelectOption elements

<triton-select>
<div slot="This slot can only be passed TritonSelectOption elements"></div>
</triton-select>

Details

Depends on