Interface Style

All Superinterfaces:
Serializable
All Known Implementing Classes:
BasicElementStyle, ImmutableEmptyStyle

public interface Style extends Serializable
Provides inline styles for Elements.
Since:
1.0
Author:
Vaadin Ltd
  • Method Details

    • get

      String get(String name)
      Gets the value of the given style property.

      Note that the name should be in camelCase and not dash-separated, i.e., use "fontFamily" and not "font-family".

      When a style property is bound to a signal with bind(String, Signal), this method returns the value of the latest signal applied for the given style property name while the element was in the attached state.

      Parameters:
      name - the style property name as camelCase, not null
      Returns:
      the style property value, or null if the style property has not been set
      See Also:
    • set

      Style set(String name, String value)
      Sets the given style property to the given value.

      Both camelCased (e.g. fontFamily) and dash-separated (e.g. font-family versions are supported.

      While a signal binding for a specific style name is active, any attempt to manually set that same style throws a BindingActiveException.

      Parameters:
      name - the style property name as camelCase, not null
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      See Also:
    • remove

      Style remove(String name)
      Removes the given style property if it has been set.

      Both camelCased (e.g. fontFamily) and dash-separated (e.g. font-family versions are supported.

      While a signal binding for a specific style name is active, any attempt to manually remove that same style throws a BindingActiveException.

      Parameters:
      name - the style property name as camelCase, not null
      Returns:
      this style instance
      See Also:
    • clear

      Style clear()
      Removes all set style properties.

      Throws a BindingActiveException if any style signal binding is active.

      Returns:
      this style instance
      Throws:
      BindingActiveException - if any style signal binding is active
      See Also:
    • has

      boolean has(String name)
      Checks if the given style property has been set.

      Both camelCased (e.g. fontFamily) and dash-separated (e.g. font-family versions are supported.

      Parameters:
      name - the style property name as camelCase, not null
      Returns:
      true if the style property has been set, false otherwise
    • getNames

      Stream<String> getNames()
      Gets the defined style property names.

      Note that this always returns the name as camelCased, e.g. fontFamily even if it has been set as dash-separated (font-family).

      Includes names of the style properties bound with the signals while the element was in the attached state.

      Returns:
      a stream of defined style property names
      See Also:
    • bind

      default SignalBinding<String> bind(String name, Signal<String> signal)
      Binds the given style property to the provided string signal. The style property is set immediately with the current signal value when the binding is created, and is kept synchronized with any subsequent signal value changes.

      When a binding is in place, the style signal mirrors signal.get(). If the signal value is null, the style property is removed; otherwise it is set to the string value.

      After the initial application, the binding is active only while the owner element is in the attached state. While the owner is in the detached state, updates from the signal have no effect.

      While a binding for a specific style name is active, any attempt to bind another signal for the same name throws a BindingActiveException.

      Name handling follows the same rules as set(String, String): both camelCase and dash-separated names are supported and normalized in the same way.

      Parameters:
      name - the style property name, not null
      signal - the signal that provides the style value, not null
      Returns:
      a SignalBinding that can be used to register change callbacks
      Throws:
      BindingActiveException - thrown when there is already an existing binding
      Since:
      25.0
      See Also:
    • setBackground

      default Style setBackground(String value)
      Sets the background property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setBackgroundColor

      default Style setBackgroundColor(String value)
      Sets the background-color property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setBackgroundPosition

      default Style setBackgroundPosition(String value)
      Sets the background-position property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.9
    • setBackgroundSize

      default Style setBackgroundSize(String value)
      Sets the background-size property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.9
    • setBorder

      default Style setBorder(String value)
      Sets the border property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setBorderLeft

      default Style setBorderLeft(String value)
      Sets the border-left property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setBorderRight

      default Style setBorderRight(String value)
      Sets the border-right property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setBorderTop

      default Style setBorderTop(String value)
      Sets the border-top property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setBorderBottom

      default Style setBorderBottom(String value)
      Sets the border-bottom property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setBorderRadius

      default Style setBorderRadius(String value)
      Sets the border-radius property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setBoxSizing

      default Style setBoxSizing(Style.BoxSizing value)
      Sets the box-sizing property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setBoxShadow

      default Style setBoxShadow(String value)
      Sets the box-shadow property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setClear

      default Style setClear(Style.Clear value)
      Sets the clear property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setCursor

      default Style setCursor(String value)
      Sets the cursor property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setColor

      default Style setColor(String value)
      Sets the color property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setColorScheme

      default Style setColorScheme(ColorScheme.Value value)
      Sets the color-scheme property.

      The color scheme affects how the browser renders UI elements and allows the component to adapt to system color scheme preferences.

      Parameters:
      value - the color scheme value (if null or NORMAL, the property will be removed)
      Returns:
      this style instance
      Since:
      25.0
    • getColorScheme

      default ColorScheme.Value getColorScheme()
      Gets the color-scheme property.
      Returns:
      the color scheme value, or NORMAL if not set
      Since:
      25.0
    • setFilter

      default Style setFilter(String value)
      Sets the filter property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.9
    • setDisplay

      default Style setDisplay(Style.Display value)
      Sets the display property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setFloat

      default Style setFloat(Style.FloatCss value)
      Sets the float property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setFont

      default Style setFont(String value)
      Sets the font property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setGap

      default Style setGap(String value)
      Sets the gap property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.9
    • setHeight

      default Style setHeight(String value)
      Sets the height property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setMinHeight

      default Style setMinHeight(String value)
      Sets the min-height property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setMaxHeight

      default Style setMaxHeight(String value)
      Sets the max-height property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setMargin

      default Style setMargin(String value)
      Sets the margin property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setMarginLeft

      default Style setMarginLeft(String value)
      Sets the margin-left property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setMarginRight

      default Style setMarginRight(String value)
      Sets the margin-right property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setMarginTop

      default Style setMarginTop(String value)
      Sets the margin-top property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setMarginBottom

      default Style setMarginBottom(String value)
      Sets the margin-bottom property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setMarginInlineStart

      default Style setMarginInlineStart(String value)
      Sets the margin-inline-start property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setMarginInlineEnd

      default Style setMarginInlineEnd(String value)
      Sets the margin-inline-end property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setOutline

      default Style setOutline(String value)
      Sets the outline property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setOpacity

      default Style setOpacity(String value)
      Sets the opacity property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setOverflow

      default Style setOverflow(Style.Overflow value)
      Sets the overflow property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setPadding

      default Style setPadding(String value)
      Sets the padding property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setPaddingLeft

      default Style setPaddingLeft(String value)
      Sets the padding-left property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setPaddingRight

      default Style setPaddingRight(String value)
      Sets the padding-right property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setPaddingTop

      default Style setPaddingTop(String value)
      Sets the padding-top property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setPaddingBottom

      default Style setPaddingBottom(String value)
      Sets the padding-bottom property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setPosition

      default Style setPosition(Style.Position value)
      Sets the position property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setRotate

      default Style setRotate(String value)
      Sets the rotate property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.9
    • setScale

      default Style setScale(String value)
      Sets the scale property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setTextAlign

      default Style setTextAlign(Style.TextAlign value)
      Sets the text-align property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setTextDecoration

      default Style setTextDecoration(String value)
      Sets the text-decoration property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setTransform

      default Style setTransform(String value)
      Sets the transform property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setTransformOrigin

      default Style setTransformOrigin(String value)
      Sets the transform-origin property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.4
    • setTransition

      default Style setTransition(String value)
      Sets the transition property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setVisibility

      default Style setVisibility(Style.Visibility value)
      Sets the visibility property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setWidth

      default Style setWidth(String value)
      Sets the width property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setMinWidth

      default Style setMinWidth(String value)
      Sets the min-width property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setMaxWidth

      default Style setMaxWidth(String value)
      Sets the max-width property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setWhiteSpace

      default Style setWhiteSpace(Style.WhiteSpace value)
      Sets the white-space property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setLeft

      default Style setLeft(String value)
      Sets the left property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setRight

      default Style setRight(String value)
      Sets the right property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setTop

      default Style setTop(String value)
      Sets the top property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setBottom

      default Style setBottom(String value)
      Sets the bottom property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setZIndex

      default Style setZIndex(Integer value)
      Sets the z-index property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.1
    • setFontWeight

      default Style setFontWeight(Style.FontWeight value)
      Sets the font-weight property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setFontWeight

      default Style setFontWeight(Integer value)
      Sets the font-weight property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setFontWeight

      default Style setFontWeight(String value)
      Sets the font-weight property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setFontSize

      default Style setFontSize(String value)
      Sets the font-size property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setLineHeight

      default Style setLineHeight(String value)
      Sets the line-height property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setAlignItems

      default Style setAlignItems(Style.AlignItems value)
      Sets the align-items property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setAlignSelf

      default Style setAlignSelf(Style.AlignSelf value)
      Sets the align-self property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setFlexWrap

      default Style setFlexWrap(Style.FlexWrap value)
      Sets the flex-wrap property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setFlexGrow

      default Style setFlexGrow(String value)
      Sets the flex-grow property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setFlexShrink

      default Style setFlexShrink(String value)
      Sets the flex-shrink property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setJustifyContent

      default Style setJustifyContent(Style.JustifyContent value)
      Sets the justify-content property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setFlexDirection

      default Style setFlexDirection(Style.FlexDirection value)
      Sets the flex-direction property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setFlexBasis

      default Style setFlexBasis(Style.FlexBasis value)
      Sets the flex-basis property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3
    • setFlexBasis

      default Style setFlexBasis(String value)
      Sets the flex-basis property.
      Parameters:
      value - the style property value (if null, the property will be removed)
      Returns:
      this style instance
      Since:
      24.3