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
0
41
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
2
Other Decks in Programming
See All in Programming
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.2k
AIエージェントの設計で注意するべきポイント6選
har1101
6
3.2k
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
1.8k
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
280
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
810
高速開発のためのコード整理術
sutetotanuki
1
130
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
170
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
220
Pythonではじめるオープンデータ分析〜書籍の紹介と書籍で紹介しきれなかった事例の紹介〜
welliving
3
810
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
170
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
120
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
170
Featured
See All Featured
Faster Mobile Websites
deanohume
310
31k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Darren the Foodie - Storyboard
khoart
PRO
2
2.2k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
110
What the history of the web can teach us about the future of AI
inesmontani
PRO
0
400
BBQ
matthewcrist
89
10k
Designing Powerful Visuals for Engaging Learning
tmiket
0
200
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
The SEO identity crisis: Don't let AI make you average
varn
0
55
Making Projects Easy
brettharned
120
6.5k
Navigating Team Friction
lara
191
16k
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