rails-view-components
Installation
SKILL.md
Rails View Layer Conventions (ViewComponent + Hotwire)
ViewComponent is this codebase's standard for reusable view logic — not plain ERB partials, not Phlex.
Partial vs. Component
| Use a partial for | Use a ViewComponent for |
|---|---|
Static markup with no Ruby logic beyond each |
Anything with conditional rendering, formatting, or state |
| One-off markup used in a single view | Markup reused across 2+ views, or that needs a dedicated spec |
If a partial grows a helper method to format its data, or gets reused a second time, promote it to a component.
Structure
# app/components/user_badge_component.rb
# frozen_string_literal: true