Making Dropdowns Required like inputs

Is there a way to make dropdowns required like you can with inputs? So if the dropdown is blank it’ll be outlined in red automatically? Or is there a way to style dropdowns based on callbacks?

(don’t see this option available for dropdowns?)

required ( a value equal to: ‘required’ or ‘REQUIRED’ | boolean ; optional): This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate. required is an HTML boolean attribute - it is enabled by a boolean or ‘required’. Alternative capitalizations REQUIRED are also accepted.

I had a similar thought, how i did it was to suppress the initial callback with prevent_initial_call=True inside the decorator and then used one of the solutions in to decide what to do with the callback.

Past that i just returned a style in the callback like style={'border-color': 'red'}

1 Like