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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Prabin Poudel
November 09, 2025
Programming
0
42
Thinking in Components: Building Reusable UIs in Rails with ViewComponent
Prabin Poudel
November 09, 2025
Tweet
Share
More Decks by Prabin Poudel
See All by Prabin Poudel
Coding Standards
coolprobn
0
3
Other Decks in Programming
See All in Programming
CSC307 Lecture 08
javiergs
PRO
0
670
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
Architectural Extensions
denyspoltorak
0
300
2026年 エンジニアリング自己学習法
yumechi
0
140
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1k
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
210
CSC307 Lecture 01
javiergs
PRO
0
690
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
140
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
4.4k
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
620
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
980
Featured
See All Featured
Ethics towards AI in product and experience design
skipperchong
2
200
Color Theory Basics | Prateek | Gurzu
gurzu
0
200
Unsuck your backbone
ammeep
671
58k
Marketing to machines
jonoalderson
1
4.6k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
Designing for Timeless Needs
cassininazir
0
130
RailsConf 2023
tenderlove
30
1.3k
How to make the Groovebox
asonas
2
1.9k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
Facilitating Awesome Meetings
lara
57
6.8k
Prompt Engineering for Job Search
mfonobong
0
160
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
100
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