4

I know there is a way like this

listBox.addThemeVariants(CheckboxGroupVariant.LUMO_HELPER_ABOVE_FIELD);

But ComboBox does not have addThemeVariants. So How we can set the helper text above the field.

enter image description here

egemenakturk
  • 365
  • 1
  • 17

1 Answers1

5

Like this:

ComboBox<String> combo = new ComboBox<>();
combo.setItems("foo", "bar");
combo.setHelperText("Oh no");
combo.getElement().getThemeList().add(CheckboxGroupVariant.LUMO_HELPER_ABOVE_FIELD.getVariantName());
ollitietavainen
  • 3,900
  • 13
  • 30
  • 2
    Basically you can use any "LUMO_HELPER_ABOVE_FIELD" enum value, since they all convert to the same string value in the browser. And ComboBox will propagate that theme attribute value to the internal TextField component. – Jouni Jul 01 '21 at 08:09