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.
Options
| Option | What it does |
|---|---|
variant | :default, :primary, :danger, :danger_fill, :ghost |
size | :md (34px) or :sm (30px) |
icon | Tabler icon shown before the label |
href | Render an <a> instead of a <button>; data-turbo-method etc. go in **html |
type | Button type when not a link: button (default) or submit |