railsui 3.2.7 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -1
- data/README.md +196 -42
- data/app/assets/javascripts/railsui-controllers.js +12 -0
- data/app/controllers/railsui/configurations_controller.rb +11 -2
- data/app/helpers/railsui/application_helper.rb +12 -0
- data/app/javascript/controllers/index.js +3 -31
- data/app/javascript/controllers/railsui_anchor_controller.js +4 -3
- data/app/javascript/controllers/railsui_auto_expand_text_area_controller.js +1 -1
- data/app/javascript/controllers/railsui_canvas_controller.js +1 -1
- data/app/javascript/controllers/railsui_code_controller.js +3 -28
- data/app/javascript/controllers/railsui_color_controller.js +1 -1
- data/app/javascript/controllers/railsui_configuration_controller.js +1 -1
- data/app/javascript/controllers/railsui_dialog_controller.js +1 -1
- data/app/javascript/controllers/railsui_flash_controller.js +1 -1
- data/app/javascript/controllers/railsui_helper_controller.js +1 -1
- data/app/javascript/controllers/railsui_loading_controller.js +1 -1
- data/app/javascript/controllers/railsui_modal_controller.js +4 -3
- data/app/javascript/controllers/railsui_nav_controller.js +4 -3
- data/app/javascript/controllers/railsui_pages_controller.js +1 -1
- data/app/javascript/controllers/railsui_prevent_controller.js +1 -1
- data/app/javascript/controllers/railsui_scroll_controller.js +1 -1
- data/app/javascript/controllers/railsui_scroll_spy_controller.js +1 -1
- data/app/javascript/controllers/railsui_search_controller.js +1 -1
- data/app/javascript/controllers/railsui_smooth_controller.js +1 -1
- data/app/javascript/controllers/railsui_snippet_controller.js +1 -1
- data/app/views/layouts/railsui/application.html.erb +7 -5
- data/app/views/layouts/railsui/fullwidth.html.erb +4 -4
- data/app/views/layouts/railsui/landing.html.erb +3 -4
- data/app/views/layouts/railsui/routes.html.erb +4 -3
- data/app/views/railsui/admin/_form.html.erb +18 -1
- data/app/views/railsui/admin/fields/_theme.html.erb +0 -1
- data/app/views/railsui/shared/_cdn_dependencies.html.erb +121 -0
- data/app/views/railsui/shared/_inline_controllers.html.erb +498 -0
- data/app/views/railsui/shared/_snippet.html.erb +23 -1
- data/app/views/railsui/themes/hound/forms/_input_group.html.erb +3 -1
- data/app/views/railsui/themes/shepherd/authentication/devise/_overview.html.erb +30 -28
- data/app/views/railsui/themes/shepherd/authentication/static/_overview.html.erb +8 -8
- data/app/views/railsui/themes/shepherd/content/typography/_headings.html.erb +23 -21
- data/app/views/railsui/themes/shepherd/forms/_input.html.erb +1 -1
- data/guides/CONFIGURATION.md +199 -0
- data/guides/MIGRATION_GUIDE.md +220 -0
- data/lib/generators/railsui/install/install_generator.rb +124 -38
- data/lib/generators/railsui/install/templates/Procfile.dev.build +1 -0
- data/lib/generators/railsui/install/templates/Procfile.dev.nobuild +2 -0
- data/lib/generators/railsui/install/templates/bin/dev +21 -0
- data/lib/generators/railsui/install/templates/themes/corgie/stylesheets/railsui/actiontext.css +0 -1
- data/lib/generators/railsui/install/templates/themes/corgie/views/layouts/rui/railsui.html.erb +7 -2
- data/lib/generators/railsui/install/templates/themes/corgie/views/layouts/rui/railsui_admin.html.erb +7 -2
- data/lib/generators/railsui/install/templates/themes/corgie/views/layouts/rui/railsui_auth.html.erb +6 -2
- data/lib/generators/railsui/install/templates/themes/corgie/views/rui/pages/{privacy.html.erb → privacy_policy.html.erb} +1 -1
- data/lib/generators/railsui/install/templates/themes/corgie/views/rui/pages/terms.html.erb +2 -2
- data/lib/generators/railsui/install/templates/themes/corgie/views/rui/shared/sidebar/_link.html.erb +4 -4
- data/lib/generators/railsui/install/templates/themes/hound/stylesheets/railsui/actiontext.css +0 -1
- data/lib/generators/railsui/install/templates/themes/hound/views/layouts/rui/railsui.html.erb +6 -2
- data/lib/generators/railsui/install/templates/themes/hound/views/layouts/rui/railsui_admin.html.erb +6 -2
- data/lib/generators/railsui/install/templates/themes/shepherd/stylesheets/railsui/actiontext.css +0 -1
- data/lib/generators/railsui/install/templates/themes/shepherd/views/layouts/rui/railsui.html.erb +6 -2
- data/lib/generators/railsui/install/templates/themes/shepherd/views/layouts/rui/railsui_admin.html.erb +6 -2
- data/lib/generators/railsui/update/update_generator.rb +40 -4
- data/lib/railsui/configuration.rb +116 -15
- data/lib/railsui/engine.rb +15 -0
- data/lib/railsui/theme_setup.rb +598 -38
- data/lib/railsui/version.rb +1 -1
- data/lib/railsui.rb +10 -7
- data/lib/tasks/install.rake +9 -3
- data/lib/tasks/migrate.rake +219 -0
- metadata +26 -4
- data/.claude/settings.local.json +0 -10
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
</div>
|
|
19
19
|
</div>
|
|
20
20
|
|
|
21
|
-
|
|
22
21
|
<div id="auth-global-layout" class="py-6">
|
|
23
22
|
|
|
24
23
|
<div class="prose prose-neutral dark:prose-invert my-6">
|
|
@@ -188,17 +187,18 @@
|
|
|
188
187
|
</div>
|
|
189
188
|
<%% end %>
|
|
190
189
|
<% end %>
|
|
191
|
-
|
|
190
|
+
<%= render_snippet active_tab: :erb %>
|
|
192
191
|
<% end %>
|
|
193
192
|
</div>
|
|
194
193
|
|
|
195
194
|
<%= system_pagination(prev_path: systems_authentication_devise_unlocks_path, prev_text: "Devise: Unlocks", next_path: systems_authentication_static_signup_path, next_text: "Sign up") %>
|
|
196
195
|
|
|
197
196
|
<%= content_for :component_nav do %>
|
|
198
|
-
<%= render layout: "railsui/shared/component_nav", locals: { title: "On this page" } do %>
|
|
199
|
-
<%= component_link "Prerequisites", "#auth-prerequisites" %>
|
|
200
|
-
<%= component_link "Layout", "#auth-global-layout" %>
|
|
201
|
-
<%= component_link "OmniAuth", "#auth-omniauth-ui" %>
|
|
202
|
-
<%= component_link "Error messages", "#auth-error-messages" %>
|
|
203
|
-
<% end %>
|
|
197
|
+
<%= render layout: "railsui/shared/component_nav", locals: { title: "On this page" } do %>
|
|
198
|
+
<%= component_link "Prerequisites", "#auth-prerequisites" %>
|
|
199
|
+
<%= component_link "Layout", "#auth-global-layout" %>
|
|
200
|
+
<%= component_link "OmniAuth", "#auth-omniauth-ui" %>
|
|
201
|
+
<%= component_link "Error messages", "#auth-error-messages" %>
|
|
202
|
+
<% end %>
|
|
203
|
+
<% end %>
|
|
204
204
|
<% end %>
|
|
@@ -43,42 +43,44 @@
|
|
|
43
43
|
<% end %>
|
|
44
44
|
</div>
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<% content_for :html, flush: true do %>
|
|
46
|
+
<% content_for :example do %>
|
|
47
|
+
<%# snippet content :html %>
|
|
48
|
+
<% content_for :html, flush: true do %>
|
|
50
49
|
<h1 class="h1">A quick brown fox jumps over the lazy dog.</h1>
|
|
51
50
|
<h2 class="h2">A quick brown fox jumps over the lazy dog.</h2>
|
|
52
51
|
<h3 class="h3">A quick brown fox jumps over the lazy dog.</h3>
|
|
53
52
|
<h4 class="h4">A quick brown fox jumps over the lazy dog.</h4>
|
|
54
53
|
<h5 class="h5">A quick brown fox jumps over the lazy dog.</h5>
|
|
55
54
|
<h6 class="h6">A quick brown fox jumps over the lazy dog.</h6>
|
|
56
|
-
<% end %>
|
|
57
|
-
<%# snippet content :erb %>
|
|
58
|
-
|
|
59
|
-
<%%= content_tag :h1, "A quick brown fox jumps over the lazy dog.", class: "
|
|
60
|
-
<%%= content_tag :h2, "A quick brown fox jumps over the lazy dog.", class: "
|
|
55
|
+
<% end %>
|
|
56
|
+
<%# snippet content :erb %>
|
|
57
|
+
<% content_for :erb, flush: true do %>
|
|
58
|
+
<%%= content_tag :h1, "A quick brown fox jumps over the lazy dog.", class: "h1" %>
|
|
59
|
+
<%%= content_tag :h2, "A quick brown fox jumps over the lazy dog.", class: "h2" %>
|
|
61
60
|
<%%= content_tag :h3, "A quick brown fox jumps over the lazy dog.", class: "h3" %>
|
|
62
61
|
<%%= content_tag :h4, "A quick brown fox jumps over the lazy dog.", class: "h4" %>
|
|
63
62
|
<%%= content_tag :h5, "A quick brown fox jumps over the lazy dog.", class: "h5" %>
|
|
64
63
|
<%%= content_tag :h6, "A quick brown fox jumps over the lazy dog.", class: "h6" %>
|
|
64
|
+
<% end %>
|
|
65
65
|
<% end %>
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<div id="typography-responsive" class="prose prose-netural dark:prose-invert max-w-full prose-headings:tracking-tight">
|
|
69
|
-
<h3>Responsive heading design</h3>
|
|
70
|
-
<p>Change heading sizes relative to viewports with Tailwind CSS responsive utilities.</p>
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
<% content_for :html, flush: true do %>
|
|
74
|
-
<h1 class="md:h1 h2">My sample title</h1>
|
|
67
|
+
<%= render_snippet %>
|
|
75
68
|
<% end %>
|
|
69
|
+
</div>
|
|
76
70
|
|
|
71
|
+
<div id="typography-responsive" class="prose prose-netural dark:prose-invert max-w-full prose-headings:tracking-tight">
|
|
72
|
+
<h3>Responsive heading design</h3>
|
|
73
|
+
<p>Change heading sizes relative to viewports with Tailwind CSS responsive utilities.</p>
|
|
77
74
|
|
|
78
|
-
|
|
75
|
+
<div class="not-prose">
|
|
76
|
+
<% content_for :html, flush: true do %>
|
|
77
|
+
<h1 class="md:h1 h2">My sample title</h1>
|
|
78
|
+
<% end %>
|
|
79
79
|
|
|
80
|
-
<%
|
|
80
|
+
<% content_for :erb, flush: true do %>
|
|
81
|
+
<%%= content_tag :h1, "My sample title", class: "md:h1 h2" %>
|
|
82
|
+
<% end %>
|
|
81
83
|
|
|
82
|
-
<%= render_snippet %>
|
|
83
|
-
</div>
|
|
84
|
+
<%= render_snippet %>
|
|
85
|
+
</div>
|
|
84
86
|
</div>
|
|
@@ -434,10 +434,10 @@ application.register('railsui-date-range-picker', RailsuiDateRangePicker)
|
|
|
434
434
|
<% end %>
|
|
435
435
|
<% end %>
|
|
436
436
|
</div>
|
|
437
|
+
</div>
|
|
437
438
|
|
|
438
439
|
<%= system_pagination(prev_path: systems_forms_path, prev_text: "Forms", next_path: systems_forms_input_group_path, next_text: "Input Group") %>
|
|
439
440
|
|
|
440
|
-
|
|
441
441
|
<%= content_for :component_nav do %>
|
|
442
442
|
<%= render layout: "railsui/shared/component_nav", locals: { title: "On this page" } do %>
|
|
443
443
|
<%= component_link "Input", "#input-input" %>
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Configuration guide
|
|
2
|
+
|
|
3
|
+
This guide covers configuring Rails UI for your application, including build modes, themes, and customization options.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Configuration file](#configuration-file)
|
|
8
|
+
- [Build mode configuration](#build-mode-configuration)
|
|
9
|
+
- [Color and theme customization](#color-and-theme-customization)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Configuration file
|
|
14
|
+
|
|
15
|
+
Rails UI stores its configuration in:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
config/railsui.yml
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This file is automatically created during installation and can be edited manually or via the admin UI at `/railsui`.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Build mode configuration
|
|
26
|
+
|
|
27
|
+
Rails UI supports two JavaScript build modes. This setting determines how JavaScript is loaded and processed.
|
|
28
|
+
|
|
29
|
+
### Build mode options
|
|
30
|
+
|
|
31
|
+
#### Option 1: No-build mode (importmap) - default
|
|
32
|
+
|
|
33
|
+
Nobuild mode is the default for Rails UI v3.3+. Simply running the installer `rails railsui:install` after adding the `railsui_pro` gem to your app's Gemfile gets everything set up using importmaps.
|
|
34
|
+
|
|
35
|
+
**Best for**: Simple apps, prototypes, apps without complex JS requirements
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
# config/railsui.yml
|
|
39
|
+
application_name: My App
|
|
40
|
+
support_email: support@example.com
|
|
41
|
+
theme: hound
|
|
42
|
+
build_mode: nobuild
|
|
43
|
+
pages:
|
|
44
|
+
- dashboard
|
|
45
|
+
- pricing
|
|
46
|
+
- ...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Characteristics:**
|
|
50
|
+
- ✅ Zero build step for JavaScript
|
|
51
|
+
- ✅ No Node.js required
|
|
52
|
+
- ✅ JavaScript loaded from CDN via importmap
|
|
53
|
+
- ✅ Fast refresh during development
|
|
54
|
+
- ✅ Simpler deployment
|
|
55
|
+
- ⚠️ Less control over JS bundling
|
|
56
|
+
- ⚠️ Requires internet for CDN dependencies (dev mode)
|
|
57
|
+
|
|
58
|
+
**Development server:**
|
|
59
|
+
```bash
|
|
60
|
+
bin/dev
|
|
61
|
+
# Runs: Rails server + Tailwind CSS watcher only
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Option 2: Build Mode
|
|
65
|
+
|
|
66
|
+
**Best for**: Production apps, TypeScript projects, complex JS requirements
|
|
67
|
+
|
|
68
|
+
To install, run the installer with the `--build` flag:
|
|
69
|
+
|
|
70
|
+
`rails railsui:install --build`
|
|
71
|
+
|
|
72
|
+
If already installed you may modify your `railsui.yml` file.
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
# config/railsui.yml
|
|
76
|
+
application_name: My App
|
|
77
|
+
support_email: support@example.com
|
|
78
|
+
theme: hound
|
|
79
|
+
build_mode: build
|
|
80
|
+
pages:
|
|
81
|
+
- dashboard
|
|
82
|
+
- pricing
|
|
83
|
+
- ...
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Characteristics:**
|
|
87
|
+
- ✅ Full control over JavaScript bundling
|
|
88
|
+
- ✅ Supports TypeScript, JSX, advanced tooling
|
|
89
|
+
- ✅ Tree-shaking and optimization
|
|
90
|
+
- ✅ Works offline
|
|
91
|
+
- ⚠️ Requires Node.js and package manager
|
|
92
|
+
- ⚠️ Additional build step
|
|
93
|
+
- ⚠️ Slightly more complex deployment
|
|
94
|
+
|
|
95
|
+
**Development server:**
|
|
96
|
+
```bash
|
|
97
|
+
bin/dev
|
|
98
|
+
# Runs: Rails server + Tailwind CSS watcher + JS bundler watcher
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Supported JS bundlers:**
|
|
102
|
+
- Bun
|
|
103
|
+
- esbuild
|
|
104
|
+
- Rollup
|
|
105
|
+
- Webpack
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Color and theme customization
|
|
109
|
+
|
|
110
|
+
Most themes include primary and secondary color palettes in addition to Tailwind CSS v4 defaults. Colors are defined in CSS using Tailwind CSS v4.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
**Step 1**: Edit `app/assets/stylesheets/railsui/theme.css`
|
|
114
|
+
|
|
115
|
+
**Step 2**: Update color or utility values based on Tailwind CSS:
|
|
116
|
+
|
|
117
|
+
For colors, we like using a tool like [Tailwind Color Generator](https://uicolors.app/create) to generate a complete color palette or [https://www.tints.dev/](https://www.tints.dev/) to generate oklch colors which have a wider gamut.
|
|
118
|
+
|
|
119
|
+
```css
|
|
120
|
+
@theme {
|
|
121
|
+
/* Your brand colors */
|
|
122
|
+
--color-primary-500: #3b82f6;
|
|
123
|
+
--color-primary-600: #2563eb;
|
|
124
|
+
/* ... update other shades ... */
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Step 3**: Rebuild CSS or reboot server:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
rails tailwindcss:build
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Using Colors in Templates
|
|
135
|
+
|
|
136
|
+
Colors are available via Tailwind utility classes:
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<!-- Primary colors -->
|
|
140
|
+
<button class="bg-primary-600 hover:bg-primary-700 text-white">
|
|
141
|
+
Click me
|
|
142
|
+
</button>
|
|
143
|
+
|
|
144
|
+
<!-- Secondary colors -->
|
|
145
|
+
<div class="border-secondary-200 bg-secondary-50">
|
|
146
|
+
Content
|
|
147
|
+
</div>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Validating Configuration
|
|
151
|
+
|
|
152
|
+
Rails UI validates configuration on save. Invalid config will raise errors:
|
|
153
|
+
|
|
154
|
+
**Valid values:**
|
|
155
|
+
- `application_name`: Non-empty string
|
|
156
|
+
- `support_email`: Valid email format
|
|
157
|
+
- `theme`: One of: `hound`, `shepherd`, `corgie`
|
|
158
|
+
- `build_mode`: One of: `build`, `nobuild`
|
|
159
|
+
- `pages`: Array of strings
|
|
160
|
+
|
|
161
|
+
**Example validation error:**
|
|
162
|
+
```
|
|
163
|
+
❌ Configuration validation failed:
|
|
164
|
+
- Invalid theme: 'custom'. Available themes: hound, shepherd, corgie, ...
|
|
165
|
+
- Invalid email format for support_email: 'not-an-email'
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Loading configuration programmatically
|
|
169
|
+
|
|
170
|
+
While you can do this, it's likely easier to visit `/railsui` locally to update these values in the form and click `Save Changes`.
|
|
171
|
+
|
|
172
|
+
```ruby
|
|
173
|
+
# Load current configuration
|
|
174
|
+
config = Railsui::Configuration.load!
|
|
175
|
+
|
|
176
|
+
# Access values
|
|
177
|
+
puts config.theme # => "hound"
|
|
178
|
+
puts config.build_mode # => "nobuild"
|
|
179
|
+
puts config.nobuild? # => true
|
|
180
|
+
puts config.build? # => false
|
|
181
|
+
|
|
182
|
+
# Update configuration
|
|
183
|
+
config.theme = "shepherd"
|
|
184
|
+
config.save
|
|
185
|
+
|
|
186
|
+
# Update with hash
|
|
187
|
+
Railsui::Configuration.update(
|
|
188
|
+
theme: "shepherd",
|
|
189
|
+
application_name: "New Name"
|
|
190
|
+
)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Getting Help
|
|
196
|
+
|
|
197
|
+
- **Documentation**: https://railsui.com/docs
|
|
198
|
+
- **Discussions**: https://github.com/getrailsui/railsui/discussions
|
|
199
|
+
- **Issues**: https://github.com/getrailsui/railsui/issues
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Rails UI Migration Guide
|
|
2
|
+
|
|
3
|
+
Covers migrating existing installations and common upgrade scenarios.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Migrating from cssbundling-rails to tailwindcss-rails](#migrating-from-cssbundling-rails-to-tailwindcss-rails)
|
|
8
|
+
- [Upgrading from v3.2 and Earlier](#upgrading-from-v32-and-earlier)
|
|
9
|
+
- [Switching Between Build Modes](#switching-between-build-modes)
|
|
10
|
+
- [Troubleshooting](#troubleshooting)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Migrating from cssbundling-rails to tailwindcss-rails
|
|
15
|
+
|
|
16
|
+
Rails UI v3.3+ uses `tailwindcss-rails` to support #nobuild, faster builds, and requires fewer dependencies.
|
|
17
|
+
|
|
18
|
+
### Automatic Migration (easy mode)
|
|
19
|
+
|
|
20
|
+
If you app previously used `cssbundling-rails`, you can migrate to `tailwindcss-rails` with the following command:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
rails railsui:migrate_to_tailwindcss_rails
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
This will:
|
|
27
|
+
- Install tailwindcss-rails gem
|
|
28
|
+
- Remove Tailwind packages from package.json
|
|
29
|
+
- Update your Procfile.dev
|
|
30
|
+
- Create new CSS file at `app/assets/tailwind/application.css`
|
|
31
|
+
- **Preserve your old CSS file** for manual migration
|
|
32
|
+
|
|
33
|
+
**Important**: Your existing `app/assets/stylesheets/application.tailwind.css` is preserved. Manually copy any custom CSS, `@import` statements, or legacy styles to `app/assets/tailwind/application.css`.
|
|
34
|
+
|
|
35
|
+
### Migrating Custom CSS
|
|
36
|
+
|
|
37
|
+
Copy your customizations from the old file to the new one:
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
/* Old: app/assets/stylesheets/application.tailwind.css Tailwind v3 */
|
|
41
|
+
@tailwind base;
|
|
42
|
+
@tailwind components;
|
|
43
|
+
@tailwind utilities;
|
|
44
|
+
|
|
45
|
+
@import "custom/buttons";
|
|
46
|
+
.my-custom-component { /* ... */ }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```css
|
|
50
|
+
/* New: app/assets/tailwind/application.css */
|
|
51
|
+
@import "tailwindcss";
|
|
52
|
+
|
|
53
|
+
@import "custom/buttons";
|
|
54
|
+
.my-custom-component { /* ... */ }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The `@import "tailwindcss";` directive replaces the three separate `@tailwind` directives (Tailwind v4 syntax).
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Upgrading from v3.2 and Earlier
|
|
62
|
+
|
|
63
|
+
### Quick Upgrade
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
bundle update railsui
|
|
67
|
+
rails railsui:migrate_to_tailwindcss_rails
|
|
68
|
+
rails generate railsui:update
|
|
69
|
+
bin/dev
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### What Changed
|
|
73
|
+
|
|
74
|
+
- **CSS**: Now uses `tailwindcss-rails` instead of `cssbundling-rails`
|
|
75
|
+
- **Default mode**: No-build (importmap), like Rails 8
|
|
76
|
+
- **Installation**: Use `--build` flag to opt into build mode for JS bundling.
|
|
77
|
+
|
|
78
|
+
### New installation workflow
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# nobuild mode (default)
|
|
82
|
+
rails new myapp
|
|
83
|
+
bundle add railsui
|
|
84
|
+
rails railsui:install
|
|
85
|
+
|
|
86
|
+
# build mode (with JS bundler)
|
|
87
|
+
rails new myapp -j [bun|esbuild|rollup|webpack]
|
|
88
|
+
bundle add railsui
|
|
89
|
+
rails railsui:install --build
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The TL;DR;: No need to use `-c tailwind` anymore - Rails UI handles CSS via the tailwindcss-rails gem.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Switching between build modes
|
|
97
|
+
|
|
98
|
+
You can switch between nobuild (importmaps) and build (JS bundler) modes anytime though we'd suggest picking one path and sticking to it for less complexity.
|
|
99
|
+
|
|
100
|
+
### Switch to nobuild mode
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# 1. Install importmap-rails if needed
|
|
104
|
+
bundle add importmap-rails
|
|
105
|
+
rails importmap:install
|
|
106
|
+
|
|
107
|
+
# 2. Update config/railsui.yml
|
|
108
|
+
# Change: build_mode: nobuild
|
|
109
|
+
|
|
110
|
+
# 3. Regenerate Rails UI assets
|
|
111
|
+
rails generate railsui:update
|
|
112
|
+
|
|
113
|
+
# 4. Update Procfile.dev (remove js line):
|
|
114
|
+
# web: bin/rails server
|
|
115
|
+
# css: bin/rails tailwindcss:watch
|
|
116
|
+
|
|
117
|
+
# 5. Restart server
|
|
118
|
+
bin/dev
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Switch to build mode
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# 1. Install jsbundling-rails and a bundler
|
|
125
|
+
bundle add jsbundling-rails
|
|
126
|
+
rails javascript:install:[bun|esbuild|rollup|webpack]
|
|
127
|
+
|
|
128
|
+
# 2. Update config/railsui.yml
|
|
129
|
+
# Change: build_mode: build
|
|
130
|
+
|
|
131
|
+
# 3. Regenerate Rails UI assets
|
|
132
|
+
rails generate railsui:update
|
|
133
|
+
|
|
134
|
+
# 4. Install JS dependencies
|
|
135
|
+
yarn install
|
|
136
|
+
|
|
137
|
+
# 5. Update Procfile.dev (add js line):
|
|
138
|
+
# web: bin/rails server
|
|
139
|
+
# css: bin/rails tailwindcss:watch
|
|
140
|
+
# js: yarn build:js --watch
|
|
141
|
+
|
|
142
|
+
# 6. Restart server
|
|
143
|
+
bin/dev
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Troubleshooting
|
|
147
|
+
|
|
148
|
+
### CSS not compiling
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
rails tailwindcss:build
|
|
152
|
+
rails tmp:clear
|
|
153
|
+
bin/dev
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Check that `Procfile.dev` includes `css: bin/rails tailwindcss:watch`.
|
|
157
|
+
|
|
158
|
+
### JavaScript not loading (no-build mode)
|
|
159
|
+
|
|
160
|
+
Check `config/importmap.rb` for required pins:
|
|
161
|
+
```bash
|
|
162
|
+
cat config/importmap.rb
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Should include: `@hotwired/stimulus`, `railsui-stimulus`, `stimulus-use`, `tippy.js`, and theme dependencies.
|
|
166
|
+
|
|
167
|
+
If missing:
|
|
168
|
+
```bash
|
|
169
|
+
bundle add importmap-rails
|
|
170
|
+
rails importmap:install
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### JavaScript not loading (build mode)
|
|
174
|
+
|
|
175
|
+
Ensure JS bundler is running in `Procfile.dev`:
|
|
176
|
+
```
|
|
177
|
+
js: yarn build:js --watch
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Install dependencies:
|
|
181
|
+
```bash
|
|
182
|
+
yarn install
|
|
183
|
+
yarn build:js
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Conflicting Tailwind versions
|
|
187
|
+
|
|
188
|
+
Remove Tailwind from package.json:
|
|
189
|
+
```bash
|
|
190
|
+
yarn remove tailwindcss @tailwindcss/cli @tailwindcss/typography
|
|
191
|
+
rails tailwindcss:build
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Verify only the gem is installed:
|
|
195
|
+
```bash
|
|
196
|
+
ls node_modules | grep tailwind # Should be empty
|
|
197
|
+
bundle list | grep tailwindcss # Should show tailwindcss-rails
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Getting Help
|
|
201
|
+
|
|
202
|
+
- Documentation: https://railsui.com/docs
|
|
203
|
+
- Issues: https://github.com/getrailsui/railsui/issues
|
|
204
|
+
- Discussions: https://github.com/getrailsui/railsui/discussions
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Quick Reference
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Migration
|
|
212
|
+
rails railsui:migrate_to_tailwindcss_rails
|
|
213
|
+
|
|
214
|
+
# Rebuild assets
|
|
215
|
+
rails tailwindcss:build
|
|
216
|
+
yarn build:js # (build mode only)
|
|
217
|
+
|
|
218
|
+
# Update Rails UI (regenerates assets for current build mode)
|
|
219
|
+
rails generate railsui:update
|
|
220
|
+
```
|