Overview
HasStyleElement is a mixin interface for Vaadin components that expose styling through CSS classes. This interface provides methods to retrieve and assert CSS class attributes.
Methods
getCssClass
class attribute value from the component.
Returns: The value of the class attribute as a string, or null if not present
assertCssClass
null is passed, asserts that no classes are present.
The expected class names, or null to assert no classes are present
Implementation Details
This interface extendsHasLocatorElement and provides default implementations for all methods.
The assertCssClass() method behavior:
- When class names are provided: asserts the component has exactly those classes
- When
nullis passed: asserts the component has no classes by checking that the class attribute doesn’t match any pattern
Implementing Classes
This interface is implemented by many Vaadin component wrappers, including:Layout Components
AccordionElementCardElementDetailsElementSplitLayoutElement
Navigation & Menu Components
MenuBarElementMenuElementMenuItemElementContextMenuElement
Data Display Components
GridElementListBoxElementMessageListElementVirtualListElement
Feedback Components
DialogElementNotificationElementPopoverElementProgressBarElement
Input Components
MessageInputElement- All components implementing
HasInputFieldElement(via inheritance)
Other Components
AvatarElement
Usage Example
Usage with Custom Styling
See Also
- HasInputFieldElement - Includes HasStyleElement for input components
- HasThemeElement - For theme variant styling