Button

Every action, with one modifier for its role.

Helper
button(
  label = nil,        # or a block with custom content
  variant: :default,  # :primary, :danger, :danger_fill, :ghost
  size: :md,          # or :sm
  icon: nil,
  href: nil,          # renders a link instead of a <button>
  type: "button",
  **html
)

icon_button(icon, label:, variant: :ghost, href: nil, **html)

primary is the one action the page exists for, at most once per view. danger marks destructive actions that still confirm; danger_fill is only the confirming button inside a modal. With href: it renders a link. Pass a block instead of label for custom content.

Small and icon-only

Use size: :sm in toolbars, footers and panels. icon_button is a 30px square that needs a label: for screen readers.

Ver nota

Options

OptionWhat it does
variant:default, :primary, :danger, :danger_fill, :ghost
size:md (34px) or :sm (30px)
iconTabler icon shown before the label
hrefRender an <a> instead of a <button>; data-turbo-method etc. go in **html
typeButton type when not a link: button (default) or submit