The goal of this project is to share common ViewComponent patterns and practices which we found useful while working on different projects (and which haven’t been or couldn’t be proposed to the upstream).
All extensions and patches are packed into a
view_component-contrib meta-gem. So, to use them add to your Gemfile:
The easiest way to start using
view_component-contrib extensions and patterns is to run an interactive generator (a custom Rails template. All you need to do is to run:
rails app:template LOCATION="https://railsbytes.com/script/zJosO5"
The command above:
- Configures testing framework (RSpec or Minitest).
- Adds required JS/CSS configuration.
- Adds a custom generator to create components.
The custom generator would allow you to create all the required component files in a single command:
bundle exec rails g view_component Example # see all available options bundle exec rails g view_component -h
Learn more in the README!