#viewcomponent

2025-05-22

I’ve wanted more compact syntax for rendering #ViewComponent in #Rails and finally got around to making a proof-of-concept.

Before:
<%= render Admin::HeadingComponent.new(“Hi”) %>

After:
<%= c.heading “Hi” %>

Inspired by the `tag.strong “Hi”` Rails tag proxy.

Curious if others do anything similar!

gist.github.com/henrik/d053195

Josh Frankel :ruby:JoshFrankel@ruby.social
2025-05-15

ViewComponents reduce bloat, simplify data, and create reusable consistent frontend styling. Despite these benefits, they're often under-utilized in the Rails community. I've written a blog post outlining an overview of how they work by refactoring a real-world example into isolated ViewComponents.

💎 Check it out 💎

joshfrankel.me/blog/viewcompon

#ruby #rails #viewcomponent

Aaron Sumnerruralocity
2024-07-30

🤔 random thought—does DHH's recent "system tests are dead" proclamation open the door to ViewComponents (or Phlex, or ?) being stock Rails features? I like ViewComponents because I can test UI things without the browser overhead—even if I only use a component once in my whole app.

2024-05-15

Happy to hear that there will be a ViewComponent-related talk by @jeremysmithco at @balticruby on June 13-15 in Malmö! Join us!
#ViewComponent

2024-02-20

If you use VSCode and have a lot of View Components, configuring explorer.fileNesting might clean up your `app/components` in the explorer a lot:

"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*_component.rb": "_${capture}_component_*.html.erb, ${capture}_component.html.erb, ${capture}_component.js, ${capture}_component_controller.js, ${capture}_component.scss"
},

#rails #viewcomponent #vscode

How the file explorer looks with file nesting enabled.How to enable file nesting in VSCode (UI)How to enable file nesting in VSCode (JSON)
2024-02-19

I've always felt rendering ViewComponent with Rails is a bit too verbose.

Especially if you have namespaces. E.g:

render(Admin::Navigation::Item.new(label: 'Example'))

I've used a helper to make it nicer on 2 projects so far:

vc.admin.navigation.item(label: 'Example')

Maybe make it into a gem?

(Might seem a bit over-engineered on a first glance. But it's something that might be called 100s-1000s of time on a page, so had to make sure it's fast enough.

#rails #ruby #ViewComponent

2024-02-07

New on the Honeybadger Developer Blog:

Building reusable UI components in Rails with ViewComponent :ruby:

Harness the power of modularity in Rails. Learn how to build reusable UI components to reduce code duplication and scale your design system.

honeybadger.io/blog/rails-view

#Ruby #RubyOnRails #ViewComponent

2023-10-13

What do you even do when presented with this situation? Bug in #haml? Bug in #viewcomponent? Bug in my brain?? #ruby

Roli on Railsroli@ruby.social
2023-07-27

TIL how to capture all the output of a block when doing your own slot like API for #ViewComponent

The trick is to use `viewcontext.capture(data_to_yield, &some_block)`

github.com/RolandStuder/til/bl

Roli on Railsroli@ruby.social
2023-07-25

Ever since using the elegance and simplicity of #Phlex I have been wondering, if I can't reach some of that expressiveness with #ViewComponent : rstuder.ch/2023-calling-view-c

Paul Sadauskas ✊ ResistPaul@ruby.social
2023-07-06

Thoughts on having ActiveRecord queries within a ViewComponent? I've got a sidebar component that's used in several controllers, but not the whole app, and need to load some data for it. I feel like I'm re-inventing React "smart" vs "dumb" components... #ruby #viewcomponent

2023-06-06

Suchst Du frische Impulse für deine #Ruby Projekte? ☕ Unser #Tech Kafi am 12. Juni ist die Lösung! Lerne, mit Rails #ViewComponent deinen Code besser zu strukturieren 🛠️. Triff Gleichgesinnte in Bern 🏢 oder online 💻. #Community 🚀

puzzle.ch/de/blog/articles/202

2023-06-05

This blog post about #rubyonrails Turbo Streams + #viewcomponent by @jasonyork was helpful to me! It demonstrates how all of the pieces fit together and includes recent changes as of #hotwire turbo-rails 1.4.0 to help rendering, introduced by @joeldrapper

predicatemethod.com/posts/usin

2023-02-21

Continuing the exploration of this "previews as unit tests" theme, I wish #ViewComponent previews were written like #RSpec specs. Specifically, I miss using nested contexts as a way to vary the state of components I'm previewing. Someone should look into that.

2023-02-04

Exciting times for ViewComponent!

#ViewComponent v3 release candidate is available for testing
github.com/ViewComponent/view_

#Lookbook v2 beta is just out, including preview embeds, support for #Phlex components and ActionView partials, and a completely rewritten file watching/live updates system!
github.com/ViewComponent/lookb

And ViewComponent::Form has an updated roadmap to v1
github.com/pantographe/view_co

We'd love to have your feedback on this!

2023-01-05

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst