Spacer Components introduced in ViewComponent 3.20
Rails Designer

Rails Designer @railsdesigner

About: I help teams around the world make their Rails apps a bit nicer to maintain and look at. 🎨 Also kickstart SaaS' in a month. 👷 And built a Rails UI Components library, used by 1000+ developers. 🚀

Location:
Amsterdam, The Netherlands
Joined:
Sep 29, 2023

Spacer Components introduced in ViewComponent 3.20

Publish Date: Nov 27 '24
1 0

This article was originally published on Rails Designer


Version 3.20 of ViewComponent introduced spacer_component.

It's a new attribute that can be added to a collection to add another component between each item of a collection. It works like this:

<%= render(ProductComponent.with_collection(@products, spacer_component: SpacerComponent.new)) %>
Enter fullscreen mode Exit fullscreen mode

This will then render SpacerComponent's between each ProductComponent. Pretty cool.

If you think, you've seen this feature before. You could be right. It was inspired by Rails' collection partial rendering.

Comments 0 total

    Add comment