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
44
0
Share
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
6
Other Decks in Programming
See All in Programming
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
5
2.4k
Rethinking API Platform Filters
vinceamstoutz
0
7.1k
AI駆動開発がもたらすパラダイムシフト
ryosuke0911
0
110
Feature Toggle は捨てやすく使おう
gennei
0
410
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
190
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
940
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
140
Symfonyの特性(設計思想)を手軽に活かす特性(trait)
ickx
0
120
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
330
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
340
iOS機能開発のAI環境と起きた変化
ryunakayama
0
140
へんな働き方
yusukebe
6
2.9k
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
100
6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
240
First, design no harm
axbom
PRO
2
1.2k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
190
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
How to build a perfect <img>
jonoalderson
1
5.3k
Tell your own story through comics
letsgokoyo
1
880
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
160
A Modern Web Designer's Workflow
chriscoyier
698
190k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
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