FluentBootstrap provides extensions, helper classes, model binding, and other goodies to help you use the Bootstrap CSS framework from .NET code.

Free & Open Source Forever Current and future versions will always be free and open source. Developed in the open on GitHub. Fork, contribute, discuss. Designed For The Server Focus on your code and not complex markup. Deep integration with ASP.NET MVC. Model binding, routing support, automatic navigation generation*, and more. * Coming soon :) Production Ready Well over 100 tests and counting. In production use on large-scale applications. Supports a variety of different frameworks. Developer Friendly Bring your own Bootstrap: CSS, LESS, Sass, it's up to you. Well documented. Easily extensible.

What Is FluentBootstrap?

The Bootstrap CSS framework is great. It provides a whole lot of useful components that can be leveraged on any web page. However, as with any complex CSS framework it requires you to specify particular CSS classes on specific HTML elements. FluentBootstrap abstracts most of this detail behind code so that you can think about what you want to present rather than how to present it.

Put simply, FluentBootstrap lets you output this HTML: <nav class="navbar-static-top navbar-default navbar" id="navbar" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">FluentBootstrap</a> <button class="collapsed navbar-toggle" data-target="#navbar-collapse" data-toggle="collapse" type="button"> <span class="sr-only">Toggle Navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="collapse navbar-collapse" id="navbar-collapse"> <div class="navbar-left navbar-nav nav"> <li><a href="/">Introduction</a></li> <li><a href="/Installation">Installation</a></li> <li><a href="/Usage">Usage</a></li> <li><a href="/Development">Development</a></li> </div> </div> </div> </nav> By writing this code instead: @using (var navbar = Html.Bootstrap().Navbar("FluentBootstrap") .SetPosition(NavbarPosition.StaticTop).Begin()) { @navbar.NavbarLink("Introduction", "/") @navbar.NavbarLink("Installation", "/Installation") @navbar.NavbarLink("Usage", "/Usage") @navbar.NavbarLink("Development", "/Development") }

I'm Not Convinced. Why Is This Better Than Raw HTML?

"Better" is such a subjective term. FluentBootstrap may not be for you if you prefer writing raw HTML or need the control the markup gives you. However, FluentBootstrap does offer the following advantages that may make generating Bootstrap HTML code easier in many situations:

By leveraging extension methods, helper classes, enums, etc., FluentBootstrap helps provide complete Intellisense when writing Bootstrap code.

Integrated helpers to bind Bootstrap structures to code objects.

The structures in FluentBootstrap are intended to be logic representations of the content as opposed to the (sometimes) complex HTML nesting imposed by CSS limitations in Bootstrap.

FluentBootstrap makes upgrading the Bootstrap library easier because missing structures, changes, etc. will be presented as compile-time errors (if precompilation is enabled). You also won't have to worry about subtle changes in the CSS (for example, Bootstrap 3.3.0 made some small changes to the CSS classes you should use for media objects, which was handled transparently by the corresponding FluentBootstrap update).

Proper start and end tag conventions are enforced through run-time checks and the disposable object model.

All FluentBootstrap components have a flexible fluent interface that can be used to adjust HTML attributes, classes, etc. prior to output.

Using code makes automatic refactoring and other static analysis possible on your Bootstrap code.

Content can be output to alternate destinations, such as a string (this is helpful when rendering templates for JavaScript consumption).

Component properties, such as whether a form should be horizontal or vertical, are transparently maintained for all child components, including those in partial views.

Additional extensions can be written to create custom composite components that are easy to use within your views.

Versioning

The Bootstrap library follows SemVer which generally uses three version numbers to represent major, minor, and patch versions. Since a given version of FluentBootstrap works in tandem with a specific version of Bootstrap, FluentBootstrap uses four version numbers. The first three numbers track the version of Bootstrap that the library was developed against (that's not to say it won't work with other similar versions of Bootstrap, but there may be problems). The fourth version number is a build number that gets incremented on every build of FluentBootstrap (and is reset for each new Bootstrap version). All the FluentBootstrap libraries get updated at the same time for consistency, even if there weren't any changes. This helps ensure that the core FluentBootstrap library is always matched to the version of the extension libraries (like FluentBootstrap.Mvc).

Release Notes

Roadmap

Right now, the entire set of standard Bootstrap components are implemented, but none of the JavaScript ones are (such as modals). There are also a number of other near-term goals:

Implement all Bootstrap JavaScript components.

Support for NancyFx.

More complex data binding support.

Support for Font Awesome in addition to the built-in icons.

Consider creating an independent core library to contain all HTML5 elements.

Better documentation, more tests, yadda, yadda, yadda.

Background

FluentBootstrap started from a need for a Bootstrap 3 compatible wrapper for the Bootstrap framework within a large enterprise line of business application. We had a lot of view code and maintaining it during Bootstrap upgrades was getting cumbersome. This was especially true when dealing with sections that included Bootstrap styled HTML for model-bound data. The initial internal versions of FluentBootstrap were designed to provide strongly-typed wrappers around HTML form elements to style model-bound data with the appropriate elements and CSS. From there it grew to encompass the entire Bootstrap framework (with the JavaScript components coming soon). It's been in production use internally for over a year and I'm happy to release it to the public now that it's shown to be stable.

Help!

The best way to get help is to post a question on StackOverflow with the FluentBootstrap tag. If you find a bug, open an issue on GitHub. You can also tweet or follow @daveaglick with questions or for announcements.