finds.dev

ViewComponent/view_component

A framework for building reusable, testable & encapsulated view components in Ruby on Rails.

View on GitHubHomepage ↗

★ 3,573RubyMITupdated Sep 2026

// the take

ViewComponent is a Rails gem for building view components as plain Ruby classes paired with a template, instead of partials and helpers. It's for Rails teams whose views have grown past the point where erb partials and helper methods stay maintainable, and who want components they can unit test without spinning up a full request.

Components are testable in isolation with a dedicated test_case/render_in API, so you can assert on markup without hitting a controller or route. The slots API handles multi-part composition (header/body/footer-style content) more cleanly than content_for conventions. Fragment caching gets real dependency tracking via cache_digest, so cache keys bust automatically when a component's template or nested components change, not just when you remember to bump a version string. The Rails version test matrix (7.1 through main/HEAD via Appraisals) shows actual compatibility testing rather than a changelog claim.

The compile/cache_digest layer is a second rendering model bolted onto Rails view resolution, and when cache invalidation misbehaves it's not obvious whether the bug is in your component or in ViewComponent's dependency tracking. Caching support is explicitly marked experimental (experimentally_cacheable.rb), so the API there can still shift under you. It only helps inside Rails view rendering — no benefit if you're doing API-only Rails or plain Ruby. Testing components means learning ViewComponent's own test helpers and system-test harness rather than reusing the controller/view test tooling your team already knows.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
3,573
Forks
487
Language
Ruby
License
MIT
Last commit
24 Sep 2026

// nearby

If view_component isn't quite it.

All repos →