Skip to main content

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

Gets the raw class attribute value from the component. Returns: The value of the class attribute as a string, or null if not present

assertCssClass

Asserts that the component has exactly the provided class names. When null is passed, asserts that no classes are present.
String...
The expected class names, or null to assert no classes are present

Implementation Details

This interface extends HasLocatorElement and provides default implementations for all methods. The assertCssClass() method behavior:
  • When class names are provided: asserts the component has exactly those classes
  • When null is 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

  • AccordionElement
  • CardElement
  • DetailsElement
  • SplitLayoutElement
  • MenuBarElement
  • MenuElement
  • MenuItemElement
  • ContextMenuElement

Data Display Components

  • GridElement
  • ListBoxElement
  • MessageListElement
  • VirtualListElement

Feedback Components

  • DialogElement
  • NotificationElement
  • PopoverElement
  • ProgressBarElement

Input Components

  • MessageInputElement
  • All components implementing HasInputFieldElement (via inheritance)

Other Components

  • AvatarElement

Usage Example

Usage with Custom Styling

See Also