Componeer renders the Trail UI design system in Rails. Every component is a ViewComponent class exposed as a view helper, so a screen is a tree of helper calls: page_header, card, table, button… Each helper takes options and, when it holds content, a block.
Trail UI itself (tokens, rules, previews) lives in its design system artifact. This gem is its Rails implementation: the CSS here is generated from it, and component changes start there.
Install
Componeer is not on RubyGems.org yet. Add it from git and bundle.
# Gemfile
gem "componeer", git: "https://github.com/andrerpbts/componeer.git"
Stylesheets
Load the tokens and the component styles in your layout, and put tr-root on the body for the base font and colours.
<head>
<%= componeer_stylesheets %>
</head>
<body class="tr-root">
JavaScript
Popovers, the multi-select, the period picker, row links and dismissable overlays use Stimulus. With importmap-rails and stimulus-rails, the engine pins its controllers for you; register them once.
Without importmap, copy app/javascript/componeer into your bundle and import it the same way.
// app/javascript/controllers/index.js
import { application } from "controllers/application"
import { registerComponeer } from "componeer"
registerComponeer(application)
Documentation
Mount the engine to browse these pages inside your own app, with your own data and layout around them. Mount it only where you want it, for example in development.
# config/routes.rb
mount Componeer::Engine => "/componeer" if Rails.env.development?