Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alejandro-du/bc2758a51af1d029442894e7ddfe6811 to your computer and use it in GitHub Desktop.
Save alejandro-du/bc2758a51af1d029442894e7ddfe6811 to your computer and use it in GitHub Desktop.
Customizing the background of a ComboBox component in Vaadin Flow apps
ComboBox<Object> comboBox = new ComboBox<>();
comboBox.addClassName("red-combo-box");
<dom-module id="custom-combo-box-styles" theme-for="vaadin-combo-box">
    <template>
        <style>
            :host(.red-combo-box) [part="text-field"] {
                --custom-text-field-background-color: red;
            }
        </style>
    </template>
</dom-module>

<dom-module id="custom-text-field-styles" theme-for="vaadin-text-field">
    <template>
        <style>
            [part="input-field"] {
                background-color: var(--custom-text-field-background-color, var(--lumo-contrast-10pct));
            }
        </style>
    </template>
</dom-module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment