# ViewComponent

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

Source: https://talira.ai/catalog/viewcomponent-v7yr5dbn
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Framework, Library
- Categories: [frameworks / rails / view components](https://talira.ai/categories/frameworks/rails/view-components), [languages / ruby / rails](https://talira.ai/categories/languages/ruby/rails)
- Licence: MIT[^1]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Self-hostable: yes[^2]

ViewComponent turns pieces of Rails views into components: a Ruby class that declares what it needs in its initializer, paired with a template. Because a component is a plain object, it can be unit tested on its own with `render_inline` and [Capybara](https://talira.ai/catalog/capybara-s6z3hhxe.md) matchers ([GitHub](https://talira.ai/catalog/github-ppcgj756.md) says over 100 times faster than similar controller tests), and its benchmark shows rendering about 2.5 times faster than partials. Slots, previews and testing helpers are documented on viewcomponent.org. Version 4 is in long-term support and described as feature-complete.

## Links

- Website: https://viewcomponent.org
- GitHub: https://github.com/ViewComponent/view_component
- Docs: https://viewcomponent.org

## Problems it solves

- our Rails partials take a dozen locals and nobody knows which ones are required
- unit test a piece of a Rails view without a full controller test
- build a design system of reusable UI components for a server-rendered Rails app
- partials are slow to render on our busiest page
- preview every state of a UI component in isolation
- move view logic out of helpers into something testable
- components with named slots for header, body and footer in Rails
- encapsulate a button or card so it looks the same on every page

## Features

- Ruby class plus template per component
- unit tests with render_inline
- Capybara matchers in tests
- slots
- previews
- about 2.5x faster than partials in its benchmark
- long-term support release (4.x)

## Trust

Overall: 0.67 out of 1.
Signals: maintenance 1.00, adoption 0.71, momentum 0.49, community 1.00, backing 0.20, extensibility 0.00.

- last commit 11 days ago
- 316 commits in the last 90 days
- latest release v4.24.0 11 days ago
- 3.6k GitHub stars
- 327 contributors
- used by GitHub

## Alternatives

- [Phlex](https://talira.ai/catalog/phlex-xh5ps07b.md): Object-oriented views in Ruby

## Sources

[^1]: https://github.com/ViewComponent/view_component (checked 17 Nov 2026)
[^2]: https://viewcomponent.org/guide/getting-started.html (checked 17 Nov 2026)
