Interface HasStyleNames
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
CheckBox.CheckBoxInputElement,CheckBox.CheckBoxLabelElement
public interface HasStyleNames extends Serializable
Implemented by components which support style names.Each style name will occur only once as specified and it is not prefixed with the style name of the component.
- Since:
- 8.7
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddStyleName(String style)Adds one or more style names to this component.default voidaddStyleNames(String... styles)Adds one or more style names to this component by using one or multiple parameters.StringgetStyleName()Gets all user-defined CSS style names of a component.voidremoveStyleName(String style)Removes one or more style names from component.default voidremoveStyleNames(String... styles)Removes one or more style names from component.voidsetStyleName(String style)Sets one or more user-defined style names of the component, replacing any previous user-defined styles.default voidsetStyleName(String style, boolean add)Adds or removes a style name.
-
-
-
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 theaddparameter is true, the style name is added to the component. If theaddparameter is false, the style name is removed from the component.Functionally this is equivalent to using
addStyleName(String)orremoveStyleName(String)- Parameters:
style- the style name to be added or removedadd-trueto add the given style,falseto 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)
-
addStyleNames
default void addStyleNames(String... styles)
Adds one or more style names to this component by using one or multiple parameters.- Parameters:
styles- the style name or style names to be added to the component- Since:
- 8.7
- See Also:
addStyleName(String),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()orsetStyleName()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()orsetStyleName()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)
-
-