Documentation versions (currently viewingVaadin 24)

Sharing Styles among Component Types

The same block of CSS can be applied in a number of ways to multiple component types. For instance, you might want the same CSS for all text input fields like Text Fields, Number Fields and Combo Boxes.

Multiple separate selectors can be specified for the same CSS by separating them with commas, like so:

vaadin-text-field::part(input-field), vaadin-number-field::part(input-field) {
  background: white;
  border: 1px solid gray;

To avoid repeating the same part or state selector for each root element, you can wrap the element types in a :where and apply the part or state selectors to that, instead:

:where(vaadin-text-field, vaadin-number-field)::part(input-field) {
  background: white;
  border: 1px solid gray;

If you know that all components with a particular part or state should get the same CSS, you can even omit the root element entirely:

::part(input-field) {
  background: white;
  border: 1px solid gray;

The above example applies the CSS to input-field parts in all components that have one.

Common to All Input Fields

The following CSS selectors can be used to target common features in all Vaadin input field components, simultaneously.






Keyboard focused






Not empty



Field surface (background, border)


Clear button


Clear button icon



Field with label




Required indicator


Helper & Validation Error

Field with helper




Invalid field


Error message


Universal Selector is Optional

The universal selector * can be omitted in the above selectors. It’s used here only to make the shadow part selectors easier to understand.