Select Field Component
open class SelectFieldComponent<T>(items: List<T>, value: Store<T>?) : Component<Label> , InputFormProperties, SeverityProperties, TooltipProperties
Content copied to clipboard
This class manages the configuration and rendering of a selectField.
This class offers the following configuration aspects:
element size
placeholder text
icon
predefined styling variants
the text which is shown -> label
disabling the element
The functional expression build, which is the last parameter of the factory function, offers an initialized instance of this SelectFieldComponent class as receiver, so every mutating method can be called for configuring the desired state for rendering the selectField.
Example usage
val myOptions = listOf("black", "red", "yellow")
val selectedItem = storeOf(myOptions[0]) // preselect "red"
selectField (items = myOptions, value = selectedItem) {
}Preselect nothing and set a placeholder text:
val myOptions = listOf("black", "red", "yellow")
val selectedItem = storeOf<String?>(null)
selectField (items = myOptions, value = selectedItem) {
placeholder("My Placeholder") // will be shown until some item is selected!
}Customize the appearance:
selectField (items = myOptions, value = selectedItem) {
icon { fromTheme { circleAdd } }
size { large }
variant { flushed }
}Set a specific label:
val persons = listOf(Person("John Doe", 37), Person("Jane Doe", 35))
val selectedItem = storeOf(persons[0])
selectField(items = persons, value = selectedItem) {
label { it.name } // pass a lambda expression to create a label string of an specific type
}Constructors
SelectFieldComponent
Link copied to clipboard
Types
EventsContext
Link copied to clipboard
class EventsContext<T>(element: Tag<HTMLElement>, selected: Flow<T>) : EventContext<HTMLElement>
Content copied to clipboard
Functions
severity
Link copied to clipboard
open override fun severity(value: SeverityProperties.SeverityContext.() -> Severity)
Content copied to clipboard
severityClassOf
Link copied to clipboard
open override fun severityClassOf(severityStyle: SeverityStyles): Flow<StyleClass>
Content copied to clipboard
tooltip
Link copied to clipboard
Properties
disabled
Link copied to clipboard
events
Link copied to clipboard
val events: ComponentProperty<SelectFieldComponent.EventsContext<T>.() -> Unit>
Content copied to clipboard
icon
Link copied to clipboard
iconWrapperStyle
Link copied to clipboard
label
Link copied to clipboard
placeholder
Link copied to clipboard
readonly
Link copied to clipboard
renderTooltip
Link copied to clipboard
open override val renderTooltip: ComponentProperty<Tag<HTMLElement>.() -> Unit>
Content copied to clipboard
selectedItem
Link copied to clipboard
severity
Link copied to clipboard
size
Link copied to clipboard
variant
Link copied to clipboard
val variant: ComponentProperty<SelectFieldVariants.() -> Style<BasicParams>>
Content copied to clipboard