↖️ Show all posts

Sexy Submit Buttons in Rails 4+

Forms are an essential part of user interaction. Yet styling Rails’ form submit is not working as easy as you might think.

<%= f.submit 'save', class: "btn btn-primary pull-xs-right" %>

use f.button with a block instead…

<!-- pass an id, add confirm warning and an icon (via a gem) -->
<%= f.button type: 'submit',
  class: "btn btn-primary pull-xs-right",
  id: "register-button",
  data: { confirm: "Bitte die Eingaben kontrollieren, eine Änderung ist im Nachhinein nicht mehr möglich!" } do
%>
<%= icon('check') << ' übernehmen' %>
<% end %>

⬅️ Read previous Read next ➡️