Package com.vaadin.ui

Interface HasStyleNames

    • Method Detail

      • getStyleName

        String getStyleName()
        Gets all user-defined CSS style names of a component. If the component has multiple style names defined, the return string is a space-separated list of style names. Built-in style names defined in Vaadin or GWT are not returned.

        The style names are returned only in the basic form in which they were added.

        Returns:
        the style name or a space-separated list of user-defined style names of the component
        Since:
        8.7
        See Also:
        setStyleName(String), addStyleName(String), removeStyleName(String)
      • setStyleName

        void setStyleName​(String style)
        Sets one or more user-defined style names of the component, replacing any previous user-defined styles. Multiple styles can be specified as a space-separated list of style names. The style names must be valid CSS class names.

        It is normally a good practice to use addStyleName() rather than this setter, as different software abstraction layers can then add their own styles without accidentally removing those defined in other layers.

        Parameters:
        style - the new style or styles of the component as a space-separated list
        Since:
        8.7
        See Also:
        getStyleName(), addStyleName(String), removeStyleName(String)
      • setStyleName

        default void setStyleName​(String style,
                                  boolean add)
        Adds or removes a style name. Multiple styles can be specified as a space-separated list of style names. If the add parameter is true, the style name is added to the component. If the add parameter is false, the style name is removed from the component.

        Functionally this is equivalent to using addStyleName(String) or removeStyleName(String)

        Parameters:
        style - the style name to be added or removed
        add - true to add the given style, false to remove it
        Since:
        8.7
        See Also:
        addStyleName(String), removeStyleName(String)
      • addStyleName

        void addStyleName​(String style)
        Adds one or more style names to this component. Multiple styles can be specified as a space-separated list of style names. The style name will be rendered as a HTML class name, which can be used in a CSS definition.
        Parameters:
        style - the new style to be added to the component
        Since:
        8.7
        See Also:
        getStyleName(), setStyleName(String), removeStyleName(String)
      • removeStyleName

        void removeStyleName​(String style)
        Removes one or more style names from component. Multiple styles can be specified as a space-separated list of style names.

        The parameter must be a valid CSS style name. Only user-defined style names added with addStyleName() or setStyleName() can be removed; built-in style names defined in Vaadin or GWT can not be removed.

        Parameters:
        style - the style name or style names to be removed
        Since:
        8.7
        See Also:
        getStyleName(), setStyleName(String), addStyleName(String)
      • removeStyleNames

        default void removeStyleNames​(String... styles)
        Removes one or more style names from component. Multiple styles can be specified by using multiple parameters.

        The parameter must be a valid CSS style name. Only user-defined style names added with addStyleName() or setStyleName() can be removed; built-in style names defined in Vaadin or GWT can not be removed.

        Parameters:
        styles - the style name or style names to be removed
        Since:
        8.7
        See Also:
        removeStyleName(String), setStyleName(String), addStyleName(String)