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
62
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
20
Other Decks in Programming
See All in Programming
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
760
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.4k
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
250
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
200
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
560
1B+ /day規模のログを管理する技術
broadleaf
0
120
どこまでゆるくて許されるのか
tk3fftk
0
270
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.5k
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
810
Contextとはなにか
chiroruxx
1
380
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
150
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.6k
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
230
Done Done
chrislema
186
16k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
200
The Cult of Friendly URLs
andyhume
79
6.9k
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
170
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
210
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
210
Google's AI Overviews - The New Search
badams
0
1.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
210
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
540
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