Documentation
We won't send you spam. Unsubscribe at any time.
Rails UI includes several view helpers to streamline common patterns. These helpers are automatically available in your views when the gem is installed.
The railsui_meta_tags helper generates all essential meta tags for SEO and social sharing in a single method call. It outputs title, description, Open Graph, social card (X/Twitter), viewport, and favicon tags.
railsui_meta_tags
In your app/views/rui/shared/_meta.html.erb partial (rendered via railsui_head):
app/views/rui/shared/_meta.html.erb
railsui_head
<%= railsui_meta_tags( title: "Welcome", description: "Build beautiful Rails apps faster with Rails UI." ) %>
This generates complete meta tags including:
Railsui.config.application_name
nil
"railsui/meta/opengraph.jpg"
"railsui/meta/opengraph-mark.jpg"
"website"
"summary"
<%= railsui_meta_tags( site: "My App", title: "About Us", description: "Learn more about our company and mission.", image: "meta/about-opengraph.jpg", card_image: "meta/about-card.jpg", og_type: "website", card_type: "summary_large_image" ) %>
Override meta tags on specific pages by passing options in your view or controller:
<% content_for :head do %> <%= railsui_meta_tags( title: "About Us", description: "Meet the team behind the product." ) %> <% end %>
Tip: Use absolute URLs for images when sharing on social platforms. The helper automatically converts asset paths to full URLs using image_url.
image_url
Replace the default Open Graph and social card images in app/assets/images/railsui/meta/:
app/assets/images/railsui/meta/
opengraph.jpg
opengraph-mark.jpg
favicon.svg
apple-touch-icon.png
Test how your meta tags appear on social platforms:
The railsui_head helper renders the app/views/rui/shared/_railsui_head.html.erb partial, which bundles meta tags, fonts, and third-party stylesheets for your theme.
app/views/rui/shared/_railsui_head.html.erb
<head> <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= yield :head %> <%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %> <%# JavaScript varies by build mode: %> <% if Railsui.config.build_mode == "build" %> <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %> <% else %> <%= javascript_importmap_tags %> <% end %> <%= railsui_head %> </head>
This partial typically includes:
<%= render "rui/shared/meta" %> <%= render "rui/shared/fonts" %> <%= stylesheet_link_tag "https://cdn.example.com/library.css", "data-turbo-track": "reload" %> <%= yield :head %>
The nav_link_to helper creates navigation links that automatically highlight when active, based on the current path.
nav_link_to
<%= nav_link_to "Dashboard", dashboard_path, active_class: "text-primary-600 font-medium", inactive_class: "text-neutral-600" %> <%= nav_link_to "Settings", settings_path, starts_with: ["/settings", "/account"], active_class: "bg-primary-50 text-primary-700", inactive_class: "text-neutral-500" %>
Options:
active_class
"rui-nav-link-active"
inactive_class
""
starts_with
Returns body classes configured in railsui.yml combined with any classes added via content_for :body_classes.
railsui.yml
content_for :body_classes
<body class="<%= railsui_body_classes %>"> <%= yield %> </body> <% content_for :body_classes, "overflow-hidden" %>