Blazor EnumInput
The Blazor Bootstrap EnumInput component renders a dropdown list from an enumeration (enum), enabling users to select from a predefined set of options. It simplifies data entry by binding directly to enum types and supports customization with sizes.
How it works #
How to use:
- Define an
enumrepresenting your options. - Add the
EnumInputcomponent to your page, specifying theTEnumtype parameter. - Bind the selected value using
@bind-Valueor@bind-Textas needed. - Use the selected value or text in your logic as shown in the demo.
Sizes #
How to use:
- Set the
Sizeparameter to one of theEnumInputSizevalues (Small,Normal,Large). - Bind the selected value as needed.
Disabled #
How to use:
- Set the
Disabledparameter totrueto make the dropdown non-interactive. - Bind the value as usual; the user will not be able to change it.
Events #
How to use (ValueChanged):
- Set the
Valueparameter and handle theValueChangedevent to respond to selection changes. - Update your logic based on the new value in the event handler.
- Set the
Textparameter and handle theTextChangedevent to respond to text changes. - Update your logic based on the new text in the event handler.
Mehods #
How to use:
- Bind the
Disabledparameter to a boolean property in your component. - Update the property in your code (e.g., via button click) to enable or disable the EnumInput as needed.