Description
ViewComponent::Form is a Ruby gem for Rails that builds form fields out of ViewComponent components. It uses the same interface as Rails' built-in form builder, so form_for, form_with and fields_for work as usual, but each field is drawn by a component you can customize. The builder finds components by name, looking for a class with a Component suffix, and a lookup chain lets you change where it searches while falling back to the default lookup. You can replace the built-in components with your own and set a parent component class for all of them. It includes helpers for validations, such as checking whether a field is required or optional, and it supports validation contexts. It needs Rails 7.2 or newer and Ruby 3.2 or newer, and works with or without ActionText. The author notes that it is an early release and the API may change before version 1.0.0. You set the builder with a builder option on a form helper, or as a default in a controller.…
Highlights
- Form builder that renders fields with ViewComponent
- Same interface as Rails' FormBuilder
- Customizable components with a lookup chain
- Required and optional field helpers
- Works with or without ActionText
Ratings & Reviews
No ratings yet
Be the first to rate View Component Form.
People also visit
Simple Form
Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup
Former
A powerful form builder, for Laravel and other frameworks (stand-alone too)
Form Builder
A dynamic form-building tool that allows users to create, customize, and…

@openproject/primer-view-components
ViewComponents of the Primer Design System for OpenProject
View Component Form FAQ
What is ViewComponent::Form?
It is a Ruby gem for Rails that renders form fields with ViewComponent components. It works with the same form helpers you already use, so you can customize how each field looks without rewriting your forms.
Which versions does it support?
The project is tested with Rails 7.2 and newer and Ruby 3.2 and newer. It works with or without ActionText.
How do I use it in a Rails app?
Add the gem to your project, then pass the form builder with a builder option on form_for, form_with or fields_for, or set it as a default in your controller with default_form_builder.
Is it stable?
The README says it is an early release and the API is subject to change until version 1.0.0, so pin your version and check the changelog before upgrading.
What are the best View Component Form alternatives?
Popular alternatives to View Component Form include Simple Form, Former and Form Builder. See all View Component Form alternatives


