Helpers

Email Action

Email Action

Buttons in emails are hard. This helper makes them easy.

The email_action helper extracts logic for displaying buttons and adding dependable spacing between HTML elements in a given template.

email_action is added automatically when you install Rails UI and appended to your application_helper.rb file.

def email_action(action, url, options={})
  align = options[:align] ||= "left"
  theme = options[:theme] ||= "primary"
  fullwidth = options[:fullwidth] ||= false
  render "rui/shared/email_action", align: align, theme: theme, action: action, url: url, fullwidth: fullwidth
end

You'll find the partials referenced above inside the rui/shared view directory. Treat these as read-only as swapping themes may override your changes.

Customize the theming inside the Rails UI mailer layout css.

email_action(action, path, options)

Required parameters

  • action - required

    The button label

  • path - required

    The url for the button. Be sure to use url helpers and not path helpers in an email

Additional options

  • theme

    primary or secondary. Default: primary.

  • align

    Align button to center, left, or right. Default: left

  • fullwidth

    (boolean) true / false. Default: false

Email Action

  • From:
  • To:
  • Date:
  • Subject:
  • info.meatean@gmail.com
  • saasquatch@railsui.com
  • December 11, 2025
  • A sample email
Email preview
 
 

Welcome to our service! We're excited to have you join us. Below you'll find important information about your account and next steps.

To get started, please verify your email address by clicking the button below:

View notification
 
 

On this page