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
5
Other Decks in Programming
See All in Programming
OTP を自動で入力する裏技
megabitsenmzq
0
110
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.2k
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
270
Claude Code Skill入門
mayahoney
0
390
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
110
「抽象に依存せよ」が分からなかった新卒1年目の私が Goのインターフェースと和解するまで
kurogenki
0
120
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
390
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
200
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
250
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
150
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
3.4k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
510
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
75
11k
Designing for humans not robots
tammielis
254
26k
Unsuck your backbone
ammeep
672
58k
Practical Orchestrator
shlominoach
191
11k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
150
Visualization
eitanlees
150
17k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
88
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
140
The Cult of Friendly URLs
andyhume
79
6.8k
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