TwitterBootstrapMvc icon indicating copy to clipboard operation
TwitterBootstrapMvc copied to clipboard

How to customize TwitterBootstrap MVC HTML Helpers with additional css classes?

Open kfinke70 opened this issue 8 years ago • 3 comments

We're working on a project with TwitterBootstrapMVC and we wish to incorporate Google's material design. We've found a nice bootstrap / material implementation: http://fezvrasta.github.io/bootstrap-material-design/.

However, in order to harness the power of this material framework we'd like to add css classes to certain things. For example, a FormGroup() might need to be extended with label-floating and has-warning. We would like to extend or customize some of the default behavior of the TwitterBootstrapMVC extensions.

How should we go about that?

kfinke70 avatar Dec 05 '16 16:12 kfinke70

The .FormGroup() has an extension method .Class() so you can apply any class to the wrapping <div class="form-group"...

As far as extensions go, you can extend things in BMVC to a certain degree. See #436 for an example. It might or might not be sufficient for you.

If you require more involved changes, purchasing BMVC's source code might be an option. Some companies have done that. If that option interests you, please contact me via email.

DmitryEfimenko avatar Dec 05 '16 17:12 DmitryEfimenko

Sorry, I should have mentioned that I know about the .Class() method.

This is the beginning of a port of a huge application to the web. There will be literally thousands of fields. Tens of thousands! For maintainability, brevity, and consistency I would love to make the default behavior of each control the way we want it.

I really don't want to fork the code. You seem to be actively maintaining it and extending it. However, I also don't see any good ways to simply extend it. If I subclass something, say BootstrapControlGroupBase, I would then have to start adding duplicate extension methods, etc. It could get ugly quickly.

Perhaps we could customize it from within? Say for example a way to provide you with default css classes?

kfinke70 avatar Dec 06 '16 13:12 kfinke70

We could try add this via adding keys to appSettings similar to how it's done for label position. Something like:

<add key="BMVC.Globals.FormGroup.ExtraCssClass" value="label-floating" />

If you like this approach, please let me know all use cases which you'd require (anything besides FormGroup?)

DmitryEfimenko avatar Dec 06 '16 16:12 DmitryEfimenko