Classic Rails Installation
Install components using traditional Rails partials and Stimulus controllers.
Overview
The Classic format uses ERB partials for templates and Stimulus controllers for JavaScript behavior. This is the most common pattern in Rails applications and requires no additional gems.
Project Structure
RailsKit components follow a conventional file organization:
app/
├── views/
│ └── components/
│ ├── _dropdown.html.erb # Partial template
│ ├── _modal.html.erb
│ └── ...
└── javascript/
└── controllers/
├── dropdown_controller.js # Stimulus controller
├── modal_controller.js
└── ...
Installing Partials
For each component, copy the .html.erb file to app/views/components/.
The filename should be prefixed with an underscore (Rails partial convention).
Create the components directory
mkdir -p app/views/components
Copy the partial file
From the component page, copy the .html.erb file contents and save it to
app/views/components/_component_name.html.erb.
Customize as needed
Modify the HTML, CSS classes, or default values to match your application's design system.
Stimulus Controllers
Interactive components include a Stimulus controller for JavaScript behavior.
Copy these to app/javascript/controllers/.
If you're using importmaps (Rails 7 default), controllers are automatically registered. For other bundlers (esbuild, webpack), ensure the controller is imported in your manifest.
import { application } from "controllers/application"
// Import RailsKit controllers
import DropdownController from "controllers/dropdown_controller"
application.register("dropdown", DropdownController)
import ModalController from "controllers/modal_controller"
application.register("modal", ModalController)
Usage Example
Once installed, render components in your views using Rails' render helper:
<%# Render the dropdown component %>
<%= render "components/dropdown",
label: "Options",
items: [
{ label: "Edit", href: edit_path(@item) },
{ label: "Delete", href: @item, method: :delete }
] %>
Each component's documentation page shows the available parameters and customization options.