
Product
Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.
shadcn-rails-stimulus
Advanced tools
Beautiful, accessible UI components for Rails built with ViewComponents, Stimulus, and Tailwind CSS. A Ruby port of shadcn/ui.
bundle add shadcn-rails
rails generate shadcn:install
npm install shadcn-rails-stimulus
# or
yarn add shadcn-rails-stimulus
Then register the controllers:
import { Application } from "@hotwired/stimulus"
import { registerShadcnControllers } from "shadcn-rails-stimulus"
const application = Application.start()
registerShadcnControllers(application)
Copy components into your app for customization:
# List all available components
rails generate shadcn:add --list
# Add specific components
rails generate shadcn:add button dialog tabs
# Add all components
rails generate shadcn:add --all
# Add without Stimulus controllers
rails generate shadcn:add dialog --exclude-controllers
Components are copied to app/components/shadcn/ and controllers to app/javascript/controllers/shadcn/. Local files take precedence over the gem's built-in components.
<%# Button %>
<%= render Shadcn::ButtonComponent.new(variant: :default) { "Click me" } %>
<%# Card %>
<%= render Shadcn::CardComponent.new do |card| %>
<% card.with_header do |header| %>
<% header.with_title { "Welcome" } %>
<% end %>
<% card.with_content_slot do %>
<p>Your content here</p>
<% end %>
<% end %>
<%# Dialog %>
<%= render Shadcn::DialogComponent.new do |dialog| %>
<% dialog.with_trigger do %>
<%= render Shadcn::ButtonComponent.new { "Open" } %>
<% end %>
<% dialog.with_body do |body| %>
<% body.with_header do |header| %>
<% header.with_title { "Edit Profile" } %>
<% end %>
<p>Dialog content here</p>
<% end %>
<% end %>
| Category | Components |
|---|---|
| Actions | Button, Toggle, Toggle Group |
| Forms | Input, Textarea, Label, Checkbox, Switch, Radio Group, Select, Slider |
| Data Display | Badge, Avatar, Card, Table, Progress, Skeleton, Aspect Ratio |
| Feedback | Alert, Tooltip, Toast |
| Overlays | Dialog, Alert Dialog, Sheet, Drawer, Popover, Hover Card, Dropdown Menu, Context Menu |
| Navigation | Tabs, Accordion, Breadcrumb, Pagination, Collapsible, Navigation Menu, Menubar |
| Layout | Separator, Scroll Area, Resizable |
Configure colors in your initializer:
# config/initializers/shadcn.rb
Shadcn::Rails.configure do |config|
config.base_color = "slate" # neutral, slate, stone, gray, zinc
config.dark_mode = :class # :class, :media, :both
end
All interactive components have corresponding Stimulus controllers:
| Controller | Components |
|---|---|
shadcn--dialog | Dialog |
shadcn--sheet | Sheet |
shadcn--tabs | Tabs |
shadcn--accordion | Accordion |
shadcn--popover | Popover |
shadcn--dropdown-menu | DropdownMenu |
shadcn--select | Select |
shadcn--switch | Switch |
shadcn--slider | Slider |
shadcn--tooltip | Tooltip |
shadcn--toast | Toast |
Register individual controllers for tree-shaking:
import DialogController from "shadcn-rails-stimulus/controllers/dialog_controller"
application.register("shadcn--dialog", DialogController)
Full TypeScript definitions included for all controllers:
import { registerShadcnControllers } from "shadcn-rails-stimulus"
import DialogController from "shadcn-rails-stimulus/controllers/dialog_controller"
// Full autocomplete and type checking
const dialog = new DialogController()
dialog.open() // Methods are typed
dialog.openValue // Values are typed (boolean)
bundle install
cd test/dummy && rails server
Visit http://localhost:3000/docs for the component documentation.
Bug reports and pull requests are welcome at https://github.com/iheanyi/shadcn-rails.
MIT License - see LICENSE for details.
FAQs
Stimulus controllers for shadcn-rails ViewComponents
We found that shadcn-rails-stimulus demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.