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
67
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
27
Other Decks in Programming
See All in Programming
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
350
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.1k
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
200
AIを紡ぐPMのお話
swdtkuy
0
120
リアルな遅延を測る仕様
kota_yata
1
120
仕様駆動開発の消費期限
watany
20
8.8k
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
190
Android CLI
fornewid
0
230
Building a Meta Ray-Ban display app
akkeylab
0
170
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
390
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
230
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
230
Featured
See All Featured
The browser strikes back
jonoalderson
0
1.5k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
Darren the Foodie - Storyboard
khoart
PRO
3
3.7k
Making the Leap to Tech Lead
cromwellryan
135
10k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
440
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Navigating Weather and Climate Data
rabernat
0
490
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
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