Getting started
Add VelvetKit to a Rails app and put your first component on a page. It takes about five minutes.
What you need
jsbundling-rails. The Stimulus controllers are .ts files.
Working with an agent?
Give it one prompt and it does every step below, then learns the kit from llms.txt.
-
1
Add the gem
VelvetKit only runs generators. Nothing loads from it in production, so it goes in the development group.
Gemfilegem "velvetkit", group: :developmentbundle install -
2
Install
Choose the module your components will live under.
UIis the default. You can't easily change it later, so read about namespacing if you're unsure.bin/rails generate velvetkit:install --namespace=UIWhat install does
-
Writes
config/velvetkit.ymlwith your namespace -
Adds
view_component and tailwind_mergeto your Gemfile -
Copies
app/assets/tailwind/velvetkit.cssthe design tokens, and imports it -
Copies
config/locales/velvetkit.en.ymlevery string the components show -
Copies
app/javascript/velvetkit_icons.tsthe Lucide icons, and imports it -
Copies
the base componentthat every other component builds on
-
Writes
-
3
Add components
Name the components you want. Each one brings the components it renders, so a dialog also brings the button and icon it uses.
bin/rails generate velvetkit:add dialog date_pickerRun it with no names to list all 42 components, or add
--allto copy every one. -
4
Render it
app/views/settings/show.html.erb<%= render(UI::Dialog.new) do |dialog| %> <% dialog.with_trigger(variant: :outline) { "Delete account" } %> <% dialog.with_content do |content| %> <% content.with_title { "Delete your account?" } %> <% content.with_description { "This cannot be undone." } %> <% end %> <% end %>← that's the real thing. Try it.
Generator options
| Option | What it does |
|---|---|
--namespace=Kit |
Use this module instead of the one in config/velvetkit.yml. |
--all |
Add every component. |
--skip-tests |
Don't copy the components' Minitest tests. |
--skip-previews |
Don't copy the Lookbook previews. |
--skip-packages |
Print the npm packages to add instead of installing them. |
--force / --skip |
Overwrite, or keep, files that already exist. |
Questions
Yes, that's the point. It's a file in your app. Change the classes, the arguments or the markup. Its tests are copied too, so they'll tell you what you changed.
Update the gem and run add again with --force. The files are overwritten, so commit first and use git diff to review the changes and keep your own edits.
The Ruby side does. The Stimulus controllers are TypeScript, so they need a bundler such as Bun or esbuild. Importmap can't compile them.
So you never wait on us. You can fix a bug today, style a component to match your brand, or delete what you don't use, all without forking a library.