withStyle
infix fun <C : BuildableComponent<C, B>, B : ComponentBuilder<C, B>> ComponentBuilder<C, B>.withStyle(consumer: Style.Builder.() -> Unit): @NotNull B
Applies a style to this component builder using a builder consumer.
Return
The component builder with the applied style
Parameters
consumer
The style builder consumer
infix fun <C : BuildableComponent<C, B>, B : ComponentBuilder<C, B>> ComponentBuilder<C, B>.withStyle(style: Style): @NotNull B
Applies a style to this component builder.
Return
The component builder with the applied style
Parameters
style
The style to apply
infix inline fun ComponentBuilder.withStyle(crossinline consumer: Styler.() -> Unit): ComponentBuilder
Applies a style to the last component added to this ComponentBuilder using a DSL builder pattern.
This infix function provides a convenient way to style the most recently added component in the builder chain. The consumer lambda receives a Styler instance that allows configuring style properties.
Return
This ComponentBuilder instance for method chaining
Example usage:
component {
text("Hello")
text("World") withStyle {
color(NamedTextColor.RED)
decoration(TextDecoration.BOLD, true)
}
}Content copied to clipboard
Parameters
consumer
A lambda with receiver that configures the style builder