🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

shadcn-rails-stimulus

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shadcn-rails-stimulus

Stimulus controllers for shadcn-rails ViewComponents

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

shadcn-rails

Beautiful, accessible UI components for Rails built with ViewComponents, Stimulus, and Tailwind CSS. A Ruby port of shadcn/ui.

CI Gem Version npm version

Features

  • 47 Components - Buttons, forms, dialogs, menus, and more
  • Accessible - Built with WAI-ARIA patterns
  • Dark Mode - Built-in light/dark theme support
  • Customizable - CSS variables for easy theming
  • Rails-first - ViewComponents + Stimulus + Tailwind CSS

Installation

Ruby Gem

bundle add shadcn-rails
rails generate shadcn:install

Stimulus Controllers (npm)

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)

Adding Components

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.

Quick Start

<%# 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 %>

Components

CategoryComponents
ActionsButton, Toggle, Toggle Group
FormsInput, Textarea, Label, Checkbox, Switch, Radio Group, Select, Slider
Data DisplayBadge, Avatar, Card, Table, Progress, Skeleton, Aspect Ratio
FeedbackAlert, Tooltip, Toast
OverlaysDialog, Alert Dialog, Sheet, Drawer, Popover, Hover Card, Dropdown Menu, Context Menu
NavigationTabs, Accordion, Breadcrumb, Pagination, Collapsible, Navigation Menu, Menubar
LayoutSeparator, Scroll Area, Resizable

Theming

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

Stimulus Controllers

All interactive components have corresponding Stimulus controllers:

ControllerComponents
shadcn--dialogDialog
shadcn--sheetSheet
shadcn--tabsTabs
shadcn--accordionAccordion
shadcn--popoverPopover
shadcn--dropdown-menuDropdownMenu
shadcn--selectSelect
shadcn--switchSwitch
shadcn--sliderSlider
shadcn--tooltipTooltip
shadcn--toastToast

Register individual controllers for tree-shaking:

import DialogController from "shadcn-rails-stimulus/controllers/dialog_controller"
application.register("shadcn--dialog", DialogController)

TypeScript Support

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)

Requirements

  • Ruby >= 3.1
  • Rails >= 7.0
  • Tailwind CSS >= 3.0
  • Stimulus >= 3.0
  • ViewComponent >= 3.0

Development

bundle install
cd test/dummy && rails server

Visit http://localhost:3000/docs for the component documentation.

Contributing

Bug reports and pull requests are welcome at https://github.com/iheanyi/shadcn-rails.

License

MIT License - see LICENSE for details.

Credits

Keywords

shadcn

FAQs

Package last updated on 27 Nov 2025

Did you know?

Socket

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.

Install

Related posts