# twitter-bootstrap-rails: Bootstrap 5 Integration for Rails via Generators

> twitter-bootstrap-rails is a Ruby gem that wires Bootstrap 5.3.8 into Rails 5 through 8 applications via a set of generators. It handles both Sprockets and Propshaft pipelines, ships 62 Bootstrap UI snippet generators, and manages Bootstrap version metadata in one place inside the gem.

**seyhunak/twitter-bootstrap-rails** — Twitter Bootstrap for Rails 8

- Repository: https://github.com/seyhunak/twitter-bootstrap-rails
- Website: https://github.com/seyhunak/twitter-bootstrap-rails
- Stars: 4,464 · Forks: 972
- Language: HTML
- License: not declared
- Published: 2026-09-23 · Updated: 2026-09-23 · Language: en
- Canonical page: https://hysenlabs.com/projects/seyhunak-twitter-bootstrap-rails

## What twitter-bootstrap-rails Does for a Rails Project

Adding Bootstrap to a Rails application by hand involves downloading or referencing Bootstrap's CSS and JavaScript files, adding them to the asset pipeline manifests, writing a layout file with the correct DOCTYPE and viewport meta tag, and copying the initial HTML structure. twitter-bootstrap-rails automates all of that through Rails generators.

The gem integrates Bootstrap 5.3.8 into Rails applications and supports Rails 5, 6, 7, and 8. Its generators cover the full setup path: installing Bootstrap assets into the pipeline, generating a layout file, writing the starter template, and generating any of 62 UI snippets drawn directly from the Bootstrap documentation.

The Bootstrap version and its associated CDN URLs and integrity hashes live in a single constant: Twitter::Bootstrap::Rails::BOOTSTRAP_CDN. No generated template hardcodes version strings, which means a gem update propagates the Bootstrap version change everywhere without manual search and replace.

The gem supports both Sprockets and Propshaft. Sprockets is the older Rails asset pipeline. Propshaft is the Rails 8 default. Both get correct Bootstrap wiring from the same generator commands, though the underlying mechanism differs between the two.

## Static Assets Versus the CDN Installation Mode

The bootstrap:install generator accepts two modes: static and cdn. The static mode copies Bootstrap assets into the application's asset pipeline, so they are served from the same origin as the application. The cdn mode generates link and script tags that load Bootstrap from jsDelivr.

The cdn mode records the choice in config/initializers/bootstrap.rb. After that, the bootstrap:layout generator emits CDN tags by default. The choice can be overridden per run with --cdn or --no-cdn flags.

For Sprockets, the static mode adds require directives to the asset manifests. For Propshaft, which has no manifest directives, the generated layout links the vendored files directly. The README notes that running bootstrap:layout after bootstrap:install static is the correct sequence regardless of which pipeline is active.

The distinction matters for deployment. Static mode bundles Bootstrap into the application's asset fingerprinting and CDN cache strategy. CDN mode depends on jsDelivr availability at page load time and relies on Subresource Integrity hashes for security when used with the --cdn flag.

## From a New Rails App to a Styled Layout

The README provides a complete quick start sequence. Starting from a new application:

```bash
rails new myapp
cd myapp
echo 'gem "twitter-bootstrap-rails"' >> Gemfile
bundle install
rails generate bootstrap:install static
rails generate scaffold Task title:string description:text completed:boolean
rails db:migrate
rails generate bootstrap:themed Tasks
rails generate bootstrap:layout application
rails server
```

The bootstrap:install static step wires Bootstrap into the asset pipeline. The scaffold creates a Task resource. The bootstrap:themed generator applies Bootstrap table and form styles to the scaffold views. The bootstrap:layout generator writes the application layout with Bootstrap CSS and JS in the correct positions.

The README is explicit about the bootstrap:layout step: it is what puts Bootstrap's CSS and JavaScript on the page. Running bootstrap:install without running bootstrap:layout leaves the application without Bootstrap in the rendered HTML. The layout generator produces an HTML file with the correct DOCTYPE, lang attribute, and viewport meta tag.

## 62 Snippet Generators Drawn from the Bootstrap Documentation

Every snippet published at getbootstrap.com/docs/5.3/examples, 62 in total across 12 categories, is available as a generator command. Each command writes an .html.erb partial into app/views/shared/:

```bash
rails g bootstrap:header
rails g bootstrap:header dark_search
rails g bootstrap:header --list
```

The categories include header, hero, features, sidebar, footer, dropdown, list_group, modal, badge, breadcrumb, button, and jumbotron. Each category has multiple variants. The full variant list is in the README's generator table. The --list flag on any snippet command prints the variants with descriptions without writing any file, which is a fast way to check options before committing.

All snippet commands share three options. The --as flag sets the partial filename (default: the generator name). The --path flag sets the destination directory (default: app/views/shared). The --no-icons flag skips installing the icon sprite. For example:

```bash
rails g bootstrap:footer columns --as=site_footer --path=app/views/layouts
```

This writes app/views/layouts/_site_footer.html.erb rather than app/views/shared/_footer.html.erb.

## Known Gaps: Placeholder Images and the Icon Sprite Requirement

Two categories of partial require attention after generation. Five snippets reference placeholder images from Bootstrap's own documentation site: hero centered, hero centered_screenshot, hero with_image, hero cropped_image, and features custom_cards. Those images live only on Bootstrap's docs server and will return 404 responses in any application. The generator warns when you pick one of these variants, but the fix is on the developer: replace the placeholder src attributes with assets from your own project.

36 of the 62 snippets use Bootstrap Icons through an SVG sprite. Those generators also write a _bootstrap_icons.html.erb partial alongside the UI partial. The README states that this icon partial must be rendered exactly once, near the top of the body element in the application layout:

```erb
<%= render "shared/bootstrap_icons" %>
```

Omitting this render call causes those 36 snippets to display empty boxes where icons should appear. The layout generated by bootstrap:layout includes this render call automatically. Applications that already have a custom layout must add it manually.

The 5.4.0 release dropped Less compilation support entirely. Applications that previously relied on rails g bootstrap:install less must migrate to the static or cdn modes. Glyphicons were removed in the same release, as Bootstrap 5 dropped them.

## How It Compares to cssbundling-rails

cssbundling-rails is an official Rails gem that delegates CSS to npm-based bundlers such as Sass, PostCSS, or esbuild. It does not manage Bootstrap directly; instead, it provides the bundler hook and leaves Bootstrap installation to npm or yarn. Developers add Bootstrap via npm, configure their CSS entry point, and write their own layout.

twitter-bootstrap-rails takes the opposite approach: it manages Bootstrap assets inside the Ruby gem, provides generators for every setup step, and keeps Bootstrap's version metadata inside the gem's constant. A developer who wants a Rails-native workflow (Gemfile, Bundler, generators) without touching a Node.js toolchain will find twitter-bootstrap-rails practical.

cssbundling-rails is appropriate for teams already using Node tooling for JavaScript. It integrates Bootstrap into the same npm pipeline and lets teams manage Bootstrap updates via npm. The two are not competing in an identical space: twitter-bootstrap-rails is a complete solution for an asset-pipeline workflow, while cssbundling-rails is an integration layer for npm-managed CSS in any Rails application.

## Maintenance and the 5.4.0 Breaking Release

The last push to the repository was on 2026-08-02. The repository has no GitHub releases published; version history is tracked in the CHANGELOG.md file at the repository root. The CHANGELOG documents a 5.4.0 release as a breaking one.

The 5.4.0 changes removed four things: Less compilation support (rails g bootstrap:install less no longer exists), Glyphicons and the glyph helper, CoffeeScript support including the --no-coffeescript flag, and the practice of tracking the gem version in sync with the Bootstrap version. The Twitter::Bootstrap::Rails::BOOTSTRAP_VERSION constant reports which Bootstrap version ships in the gem, replacing the old version-number alignment.

The README notes a specific Propshaft fix in 5.4.0: the static installation mode previously left Propshaft apps without any Bootstrap assets at all. That is resolved in this release.

The license field in the repository metadata is listed as unknown. The gemspec file at the repository root governs what is shipped to RubyGems.org; check that file or the RubyGems page for the definitive license statement before commercial deployment.

## Conclusion

Teams using Rails 5 through 8 who want Bootstrap in their asset pipeline with minimal manual configuration will find twitter-bootstrap-rails practical. The generator approach means Bootstrap layouts and UI snippets can be written with a command rather than hand-copied from the Bootstrap documentation. Propshaft users on Rails 8 should confirm they are on gem version 5.4.0 or later, since earlier versions did not correctly wire Bootstrap assets for Propshaft. Applications that manage their JavaScript and CSS entirely through npm and a bundler like esbuild may find cssbundling-rails a better fit, since twitter-bootstrap-rails targets the Rails asset pipeline rather than a Node-managed build step. The unknown license status in the repository metadata is worth verifying against the gem before commercial deployment.

## FAQ

### How do I add twitter-bootstrap-rails to a Rails 8 project?

Add gem "twitter-bootstrap-rails" to your Gemfile, run bundle install, then run rails generate bootstrap:install static and rails generate bootstrap:layout application. Rails 8 uses Propshaft, and the static install mode correctly wires Bootstrap assets for Propshaft as of gem version 5.4.0.

### What is the difference between bootstrap:install static and bootstrap:install cdn?

The static mode copies Bootstrap assets into your application's asset pipeline so they are served from your own origin. The cdn mode generates link and script tags that load Bootstrap from jsDelivr, recording the choice in config/initializers/bootstrap.rb so later generator commands emit CDN tags by default.

### Does twitter-bootstrap-rails support Propshaft?

Yes, as of version 5.4.0. Earlier versions left Propshaft applications without Bootstrap assets when using the static install mode. On Propshaft, the generated layout links vendored files directly rather than using manifest directives, which Propshaft does not use.

## Sources

- [Issues](https://github.com/seyhunak/twitter-bootstrap-rails/issues)
- [Project website](https://github.com/seyhunak/twitter-bootstrap-rails)
- [README](https://github.com/seyhunak/twitter-bootstrap-rails/blob/main/README.md)
- [seyhunak/twitter-bootstrap-rails on GitHub](https://github.com/seyhunak/twitter-bootstrap-rails)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/seyhunak-twitter-bootstrap-rails
