Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Thinking in Components: Building Reusable UIs i...
Search
Prabin Poudel
November 09, 2025
Programming
60
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Thinking in Components: Building Reusable UIs in Rails with ViewComponent
Prabin Poudel
November 09, 2025
More Decks by Prabin Poudel
See All by Prabin Poudel
Coding Standards
coolprobn
0
15
Other Decks in Programming
See All in Programming
The NotImplementedError Problem in Ruby
koic
1
640
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.5k
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
160
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
200
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
510
AIエージェントの隔離技術の徹底比較
kawayu
0
470
net-httpのHTTP/2対応について
naruse
0
450
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
3.2k
3Dシーンの圧縮
fadis
1
670
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
4.5k
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
730
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Paper Plane
katiecoart
PRO
1
51k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Evolving SEO for Evolving Search Engines
ryanjones
0
210
The untapped power of vector embeddings
frankvandijk
2
1.7k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
340
ラッコキーワード サービス紹介資料
rakko
1
3.6M
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Transcript
Building Reusable UIs in Rails with ViewComponent Thinking in Components
Prabin Poudel Ruby on Rails Consultant & CEO @ Truemark Technology
@coolprobn @coolprobn Prabin Poudel 👋 Ruby on Rails Consultant &
CEO @ Truemark Technology prabinpoudel.com.np
Rails view convention The problem with raw views Enter ViewComponent
Example: Building a Form Field Example: Building a Button Benefits of ViewComponent Q&A Agenda
Rails scaffolds views in ERB templates Let’s say we generate
a User form: Rails View Convention
None
Repetition of code Hard to maintain consistency across the app
Code Spaghetti Difficult to preview in isolation Problems with Raw Views
https://viewcomponent.org/ A framework from GitHub to build encapsulated, reusable view
objects Think of it as React components, but for Rails views Each UI piece = a Ruby class + a template Example: following command generates two files app/components/button_component.rb app/components/button_component.html.erb Enter ViewComponent
Example 1: Form Input Field
Refactored Code
Example 2: Button
Refactored Code
1.Encapsulation 2.Reusable & Maintainable 3.First class support for Test 4.Easy
to Preview in Browser Benefits of ViewComponent
Keep logic + markup together Isolate code in each component
Encapsulation
Reusable across multiple views All buttons share consistent styles Reusable
/ Maintainable
Test UI in isolation without full controller First class support
for Test
Preview like Action Mailer previews Create a file named `test/components/previews/button_component_preview.rb`
Visit /rails/view_components to view all previewable components Easy to Preview in Browser
Thank you 🙏 Any Questions? @coolprobn @coolprobn prabinpoudel.com.np