Install in your Rails project
Requirements
- Ruby >= 3.4
- Rails >= 7.1
- ViewComponent >= 3.20.0 (installed automatically as a dependency)
Installation
Add to Gemfile:
gem "midwest", github: "unabridged/midwest", branch: "main"Run installer:
bin/rails midwest:installThe installer handles the following automatically:
- Adds the Midwest stylesheet to your application layout
- Adds
midwest_body_stylesto your<body>tag for CSS custom property support - Pins
midwest-view-componentsvia importmap (or adds it via yarn for esbuild/webpack setups) - Includes
Midwest::ViewHelperandMidwest::UrlHelperinApplicationHelper - Registers Midwest Stimulus controllers
Development
To get started contributing to the library:
- Run:
bundle install - Run:
yarn install - Run:
bin/dev
This opens the demo app with component previews at localhost:4000. Component previews are in demo/app/previews.
To run tests:
bin/test # all appraisals on the current Ruby versionbin/test --all # full matrix: Ruby 3.3, 3.4, 4.0 × Rails 7 & 8bin/test --rails 8 # Rails 8 only, current Rubybin/test --rails 8 --ruby 4.0 # Rails 8 on Ruby 4.0 onlyTo generate new components:
bin/rails midwest:generate:component YourComponent