SubMenuComponent

open class SubMenuComponent(styling: Style<BoxParams>, value: Store<Boolean>?, baseClass: StyleClass, id: String?, prefix: String) : MenuContext, MenuChild, EventProperties<HTMLButtonElement> , FormProperties

This class combines the configuration and the core rendering of a submenu inside a menu.

A submenu consists of different types of children that are aligned vertically. By default the following types can be added to the menu:

It is also possible to add any other fritz2 component via the custom context. All menu items are created directly within the SubMenuComponent's build context.

Example usage:

menu {
entry {
icon { add }
text("Item")
}
divider()
submenu {
entry {
icon { add }
text("Item")
}
}
divider()
header("A subsection starts here")
custom {
// custom content
spinner { }
}
}

The menu-entry-DSL can be extended via standard Kotlin extension methods. Custom entries must implement the Component<Unit> interface and are added to the Menu via the MenuComponent.addChild method which is accessible from within the extension method.

The following example adds an instance of MyMenuEntry to the Menu. Notice that addChild is invoked in the end; the entry wouldn't be added otherwise!

fun MenuComponent.example(build: MyMenuEntry.() -> Unit) = MyMenuEntry()
.apply(build)
.run(::addChild)

Constructors

SubMenuComponent
Link copied to clipboard
js
fun SubMenuComponent(styling: Style<BoxParams>, value: Store<Boolean>? = null, baseClass: StyleClass, id: String?, prefix: String)

Types

Companion
Link copied to clipboard
js
object Companion

Functions

addChild
Link copied to clipboard
js
fun addChild(child: MenuChild): Boolean
custom
Link copied to clipboard
js
fun custom(build: RenderContext.() -> Unit)
Adds a custom fritz2-component to the menu.
fun custom(styling: Style<BoxParams>, build: RenderContext.() -> Unit)
Adds a custom fritz2-component to the menu.
divider
Link copied to clipboard
js
fun divider(styling: Style<BoxParams> = {})
Adds a MenuDivider to the menu.
enabled
Link copied to clipboard
js
open override fun enabled(value: Boolean)
open override fun enabled(value: Flow<Boolean>)
entry
Link copied to clipboard
js
fun entry(build: MenuEntry.() -> Unit)
Configures and adds a MenuEntry to the menu.
fun entry(styling: Style<BoxParams>, build: MenuEntry.() -> Unit)
Configures and adds a MenuEntry to the menu.
header
Link copied to clipboard
js
fun header(text: String)
Configures and adds a MenuHeader to the menu.
fun header(styling: Style<BoxParams>, text: String)
Configures and adds a MenuHeader to the menu.
icon
Link copied to clipboard
js
fun icon(def: Icons.() -> IconDefinition)
fun icon(def: Flow<IconDefinition>)
link
Link copied to clipboard
js
fun link(build: MenuLink.() -> Unit)
Configures and adds a MenuLink to the menu.
fun link(styling: Style<BoxParams>, build: MenuLink.() -> Unit)
Configures and adds a MenuLink to the menu.
render
Link copied to clipboard
js
open override fun render(context: RenderContext, styles: MenuStyles)
submenu
Link copied to clipboard
js
fun submenu(styling: BoxParams.() -> Unit = {}, value: Store<Boolean>? = null, baseClass: StyleClass = StyleClass.None, id: String? = null, prefix: String = "submenu", build: SubMenuComponent.() -> Unit): Boolean
Creates a submenu.

Properties

baseClass
Link copied to clipboard
js
val baseClass: StyleClass
disabled
Link copied to clipboard
js
open override val disabled: DynamicComponentProperty<Boolean>
events
Link copied to clipboard
js
open override val events: ComponentProperty<EventContext<HTMLButtonElement>.() -> Unit>
This property enables the client to access all events offered by the underlying HTML element.
icon
Link copied to clipboard
js
var icon: Flow<IconDefinition>? = null
id
Link copied to clipboard
js
val id: String?
prefix
Link copied to clipboard
js
val prefix: String
styling
Link copied to clipboard
js
val styling: Style<BoxParams>
text
Link copied to clipboard
js
val text: ComponentProperty<String?>
value
Link copied to clipboard
js
val value: Store<Boolean>? = null