Stephane Grenier
Stephane Grenier

Reputation: 15927

How to set a caption for a Checkbox in a FormLayout in Vaadin Flow

In FormLayout all my components have a caption label just above the component except for the Checkbox. So for example if I have a row with just a single Checkbox (the other column is empty or the Checkbox question spans two columns) then it's very disproportionally close to the row above. Is there a way to add a caption like the other components? In my case the Checkbox is a question whereas the caption is just a simple title of what the Checkbox represents.

Upvotes: 1

Views: 482

Answers (1)

Hawk
Hawk

Reputation: 2142

// configure to your liking responsively
formLayout.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 2, FormLayout.ResponsiveStep.LabelsPosition.TOP));

formLayout.addFormItem(new Checkbox(), "Any label you want aligned with other labels");

Upvotes: 4

Related Questions