get ComboBox smaller

For TextField the size can be changed with addThemeVariants(TextFieldVariant.LUMO_SMALL);

For ComboBox this method doesn’t exist. What can I do to get the ComboBox smaller?

Peter,

If the method doesn’t exist, you can set the “theme” attribute directly. Example from docs below:

Button button = new Button("Themed button");
String themeAttributeName = "theme";
String oldValue = button.getElement()
        .getAttribute(themeAttributeName);
String variantsToAdd = "contrast primary";
button.getElement().setAttribute(themeAttributeName,
        oldValue == null || oldValue.isEmpty() ?
            variantsToAdd
            : ' ' + variantsToAdd);

Whether the component supports the theme is a different matter though.

The solution proposed by @Martin Israelsen works (tested with ComboBox / V14.2). For me it remains a mystery why ComboBox does not implement HasTheme.

Secondly, the ComboBox looks good now, only the list with items has its original size :frowning: