Select Field Component
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
Types
Functions
Property to manage the severity value of the component.
This function manages the task to map a value of the Severity enumeration to a corresponding style defined within the SeverityStyles interface. The severity itself is taken from the severity property, so only the styling interface's implementation has to be injected: