Helpers

Railsui Head

Railsui Head

A bundled helper responsible for rendering a collection of partials in the head tags of your app.

Rails UI Head

The railsui_head helper is responsible for rendering a collection of partials in the head tags of your app. It's a handy way to include common elements like stylesheets, fonts, JavaScript files, and meta tags without having to repeat them in every view. Assets included vary by theme.

This helper renders by default for each Rails UI layout when you install Rails UI. You'll find it inside app/views/code/layouts/rui/railsui.html.erb and any other layouts with the railsui_ prefix in the name (i.e. railsui_admin.html.erb).

You shouldn't need to do much outside of ensure this helper renders in your layouts. Consider this page for reference.

<%= railsui_head %>

<!-- app/views/code/layouts/rui/railsui.html.erb -->

<!-- Meta tags via meta-tags gem. Customize yours at app/views/rui/shared/_meta.html.erb -->
<%= render "rui/shared/meta" %>

<!-- Custom fonts for each theme -->
<%= render "rui/shared/fonts" %>

<!-- CDN links for 3rd party CSS -->
<%= stylesheet_link_tag "https://unpkg.com/tippy.js@6.3.7/dist/tippy.css", "https://unpkg.com/trix@2.1.8/dist/trix.css", "data-turbo-track": "reload" %>

<!-- Various 3rd party JavaScript if necessary -->

<%= yield :head %>

yield :head

Included is a a <%= yield :head %> statement so you can add additional assets in the head tags inside your views as necessary or leverage Turbo morphing as required.

<% content_for :head do %>
  <%= javascript_include_tag "https://unpkg.com/alpinejs@3.12.2/dist/cdn.min.js", "data-turbo-track": "reload" %>
<% end %>

On this page