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
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
並行開発のためのコードレビュー
miyukiw
0
320
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
200
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
180
CSC307 Lecture 06
javiergs
PRO
0
690
要求定義・仕様記述・設計・検証の手引き - 理論から学ぶ明確で統一された成果物定義
orgachem
PRO
1
170
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
200
Best-Practices-for-Cortex-Analyst-and-AI-Agent
ryotaroikeda
1
110
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
390
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1371
200k
The Limits of Empathy - UXLibs8
cassininazir
1
220
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
220
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
30 Presentation Tips
portentint
PRO
1
220
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
61
52k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
450
Are puppies a ranking factor?
jonoalderson
1
2.7k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
590
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
86
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