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
44
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
6
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
1.3k
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
310
S3ストレージクラスの「見える」「ある」「使える」は全部違う ─ 体験から見た、仕様の深淵を覗く
ya_ma23
0
1.2k
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
140
Strategy for Finding a Problem for OSS: With Real Examples
kibitan
0
130
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
220
飯MCP
yusukebe
0
450
Nuxt Server Components
wattanx
0
230
見せてもらおうか、 OpenSearchの性能とやらを!
shunta27
1
170
AI時代のシステム設計:ドメインモデルで変更しやすさを守る設計戦略
masuda220
PRO
6
1.2k
PHPで TLSのプロトコルを実装してみる
higaki_program
0
730
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
320
Featured
See All Featured
Music & Morning Musume
bryan
47
7.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Scaling GitHub
holman
464
140k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
280
Speed Design
sergeychernyshev
33
1.6k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
160
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Paper Plane
katiecoart
PRO
1
48k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
240
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
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