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
55
0
Share
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
13
Other Decks in Programming
See All in Programming
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
460
要はバランスからの卒業 #yumemi_grow
kajitack
0
170
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
250
20260514 - build with ai 2026 - build LINE Bot with Gemini CLI
line_developers_tw
PRO
0
450
How We Practice Exploratory Testing in Iterative Development( #scrumniigata ) / 反復開発の中で、探索的テストをどう実施しているか
teyamagu
PRO
3
980
1人1案件のプロダクトエンジニア時代に、"プロセス監督"としてチャレンジしたこと
non0113
0
120
決定論 vs 確率論:Gemini 3 FlashとTF-IDFを組み合わせた「法規判定エンジン」の構築
shukob
0
170
Skillは並べた。動かなかった。契約で繋いだ。— 65個のSkillから、自走する開発サイクルへ
junholee
0
650
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
680
AWSはOSSをどのように 考えているのか?
akihisaikeda
0
130
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
570
継続的な負荷検証を目指して
pyama86
3
1.2k
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
300
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
300
How to make the Groovebox
asonas
2
2.2k
Building AI with AI
inesmontani
PRO
1
1k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
250
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Darren the Foodie - Storyboard
khoart
PRO
3
3.3k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
190
AI: The stuff that nobody shows you
jnunemaker
PRO
7
640
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
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