Install in your Bridgetown project
Requirements
- Ruby >= 3.4
- Bridgetown v1 or v2
Midwest components are built on ViewComponent. In a Bridgetown project, component classes and helpers are available without a running Rails application — Midwest's engine constants and class definitions load on require "midwest". Rendering components requires additional setup depending on which Bridgetown version you use.
Installation
Bridgetown v1
Add to your Gemfile:
gem "midwest", github: "unabridged/midwest", branch: "main"gem "bridgetown-view-component"Run bundle install.
The bridgetown-view-component gem provides the ActionView rendering context that ViewComponent needs to render templates. Bridgetown v1 already carries Rails as a transitive dependency, so no extra configuration is required to load Midwest's constants and component classes.
Bridgetown v2
Add to your Gemfile:
gem "midwest", github: "unabridged/midwest", branch: "main"Run bundle install.
Midwest's rails runtime dependency brings Rails into the bundle transitively, so component classes and helpers load correctly. Bridgetown v2 dropped Rails from its own dependencies, and bridgetown-view-component does not yet support Bridgetown 2.x — full ViewComponent rendering support is pending a compatible shim for v2.
What works today
In both Bridgetown v1 and v2, the following are fully supported:
- All component class definitions and instantiation
- ViewComponent::Base inheritance and interface
- Midwest helper methods (
Midwest::ViewHelper,Midwest::UrlHelper) - Access to component ERB templates, CSS, JS, and SVG icon assets
- Engine guard behavior (asset and importmap initializers are no-ops without a running app)
Rendering via render requires bridgetown-view-component (v1) or a custom ActionView shim (v2).
Assets
Midwest ships a stylesheet and JavaScript bundle as part of its Rails engine. To locate the asset files from within your Bridgetown project:
require "midwest"puts Midwest::Engine.root.join("app/assets/stylesheets/midwest.css")puts Midwest::Engine.root.join("app/assets/javascripts/midwest_view_components.js")Copy or symlink those files into your Bridgetown source tree, or configure your build tool to resolve them from the gem path.