# NitroKit Documentation NitroKit is a set of generic UI components to help you build your Ruby on Rails application. Rather than being fancy it is purposefully modest. Instead of giving you a black box, it is provided as a generator and a set of components that give you a starting point to build upon. ## Quick Info - Easy to customize, accessible, Rails native - Components are generated into your app, not hidden in a gem - All components accept keyword arguments passed as HTML attributes - Special handling for `class:` (merged with Tailwind) and `data:` attributes - Variants can be passed as `variant: :primary` or method names like `nk_primary_button` ## Requirements 1. Ruby on Rails 7.0+ 2. Tailwind CSS V4 3. Stimulus (optional – only for components with JavaScript) ## Principles 1. Feel Rails native 2. Convention over configuration 3. Don't be fancy 4. Keep it simple 5. Fewest possible dependencies ## Getting Started Installing Nitro Kit into both new and old apps takes just a few steps. ### Fully automatic installation (from new Rails app): ```shell bin/rails app:template LOCATION="https://nitrokit.dev/t/install" ``` ### Manual installation: 1. Add the gem: ```sh bundle add nitro_kit bundle install ``` 2. Install Tailwind CSS (version 4 recommended): ```shell bundle add tailwindcss-rails bundle install bin/rails tailwindcss:install ``` 3. Configure Tailwind CSS by replacing `app/assets/tailwind/application.css` with: ```css @import "tailwindcss"; @theme { --color-foreground: var(--color-zinc-900); --color-background: var(--color-white); --color-border: var(--color-zinc-200); --color-ring: var(--color-blue-600); --color-muted: var(--color-zinc-100); --color-muted-content: var(--color-zinc-500); --color-primary: var(--color-zinc-800); --color-primary-content: var(--zinc-800); --color-primary-foreground: var(--color-zinc-100); --color-destructive: var(--color-red-500); --color-destructive-content: var(--color-red-800); --color-destructive-foreground: var(--color-white); } @layer base { [data-theme="dark"] { --color-foreground: var(--color-zinc-100); --color-background: var(--color-zinc-950); --color-border: var(--color-zinc-700); --color-ring: var(--color-blue-700); --color-muted: var(--color-zinc-800); --color-muted-content: var(--color-zinc-400); --color-primary: var(--color-zinc-50); --color-primary-content: var(--color-zinc-50); --color-primary-foreground: var(--color-zinc-900); --color-destructive: var(--color-red-900); --color-destructive-content: var(--color-red-600); --color-destructive-foreground: var(--color-white); } } @variant dark (&:where([data-theme="dark"], [data-theme="dark"] *)); @layer base { * { @apply border-border min-w-0 ring-ring; } body { /* Nitro Kit looks great in Inter as well */ /* https://rsms.me/inter */ @apply bg-background text-foreground font-sans; } } ``` 4. Add components to your app: ```bash bin/rails generate nitro_kit:component all # or a list of individual components ``` ### Stimulus Nitro Kit requires Stimulus if you add components that depend on JavaScript. It expects to load all Stimulus controllers from `app/javascript/controllers/`. ## Good to Know ### Make it your own Nitro Kit exists to give you a starting point. Don't be afraid to change the components to fit your needs and tastes. Customization options: 1. Copy them to a new file and go from there 2. Subclass components and override `class` or other methods 3. Make helper methods that pass `class:` or other arguments directly ### Attributes - Nitro Kit components accept any keyword argument, passed as HTML attributes - `nk_button(thing: "1")` becomes `