Result

Component

Interactive examples and API documentation

Success
Success state uses Ant Design
Order received
We will email you once the shipment is scheduled.
Code
<%= render(HakumiComponents::Result::Component.new(
  id: "result-success",
  status: :success,
  title: "Order received",
  sub_title: "We will email you once the shipment is scheduled.",
  extra: render(HakumiComponents::Button::Component.new(type: :primary)) { "Back to orders" }
)) %>
Info
Informational status with the default info-circle icon.
Awaiting review
We’ll notify you once your submission has been approved.
Code
<%= render(HakumiComponents::Result::Component.new(
  id: "result-info",
  status: :info,
  title: "Awaiting review",
  sub_title: "We’ll notify you once your submission has been approved.",
  extra: render(HakumiComponents::Button::Component.new(type: :link)) { "View submission" }
)) %>
Warning
Warning status highlighting required actions.
Action required
Review the highlighted information before proceeding.
Code
<%= render(HakumiComponents::Result::Component.new(
  id: "result-warning",
  status: :warning,
  title: "Action required",
  sub_title: "Review the highlighted information before proceeding.",
  extra: render(HakumiComponents::Space::Component.new) do |space|
    space.with_item { render(HakumiComponents::Button::Component.new(type: :primary)) { "Review details" } }
    space.with_item { render(HakumiComponents::Button::Component.new) { "Dismiss" } }
  end
)) %>
Error
Error status with additional supporting content.
Payment failed
We could not process your payment. Please update your card info and try again.
The system will keep this order on hold for 24 hours before cancelling it automatically.
Code
<%= render(HakumiComponents::Result::Component.new(
  id: "result-error",
  status: :error,
  title: "Payment failed",
  sub_title: "We could not process your payment. Please update your card info and try again.",
)) do %>
  <%= render(HakumiComponents::Typography::Paragraph::Component.new(type: :secondary)) do %>
    The system will keep this order on hold for 24 hours before cancelling it automatically.
  <% end %>
  <%= render(HakumiComponents::Space::Component.new(style: "margin-top: 16px;")) do |space| %>
    <% space.with_item do %>
      <%= render(HakumiComponents::Button::Component.new(type: :primary, danger: true)) { "Retry payment" } %>
    <% end %>
    <% space.with_item do %>
      <%= render(HakumiComponents::Button::Component.new) { "Change method" } %>
    <% end %>
  <% end %>
<% end %>
Without icon
Hide the illustration by passing <code>icon: false</code>.
Action required
Review the highlighted items before continuing.
This variant hides the illustration entirely by passing icon: false.
Code
<%= render(HakumiComponents::Result::Component.new(
  id: "result-without-icon",
  status: :warning,
  title: "Action required",
  sub_title: "Review the highlighted items before continuing.",
  icon: false,
  extra: render(HakumiComponents::Space::Component.new) do |space|
    space.with_item do
      render(HakumiComponents::Button::Component.new(type: :primary)) { "Resolve issues" }
    end
    space.with_item do
      render(HakumiComponents::Button::Component.new) { "Dismiss" }
    end
  end
)) do %>
  <%= render(HakumiComponents::Typography::Paragraph::Component.new(type: :secondary)) do %>
    This variant hides the illustration entirely by passing <code>icon: false</code>.
  <% end %>
<% end %>
Programmatic
Create results dynamically with status, title, subtitle, extra, and <code>icon: false</code> params via <code>HakumiComponents.renderComponent</code>.
Code
<%= render(HakumiComponents::Space::Component.new) do |space| %>
  <% space.with_item do %>
    <%= render(HakumiComponents::Button::Component.new(id: "prog-result-create", type: :primary)) { "Create result (no icon)" } %>
  <% end %>
  <% space.with_item do %>
    <%= render(HakumiComponents::Button::Component.new(id: "prog-result-clear")) { "Clear results" } %>
  <% end %>
<% end %>

<%= render(HakumiComponents::Flex::Component.new(
  id: "result-programmatic-target",
  vertical: true,
  gap: "16px",
  style: "margin-top: 16px;"
)) { "" } %>

<script>
  (() => {
    const wire = () => {
      if (!window.HakumiComponents?.renderComponent) return false

      const targetSelector = "#result-programmatic-target"
      const createButton = document.getElementById("prog-result-create")
      const clearButton = document.getElementById("prog-result-clear")

      createButton?.addEventListener("click", () => {
        window.HakumiComponents.renderComponent("result", {
          params: {
            status: "info",
            icon: false,
            title: "Programmatic result",
            sub_title: `Generated at ${new Date().toLocaleTimeString()}`,
            extra: "You can add actions here"
          },
          target: targetSelector,
          mode: "append"
        })
      })

      clearButton?.addEventListener("click", () => {
        const target = document.querySelector(targetSelector)
        if (target) target.innerHTML = ""
      })

      return true
    }

    if (wire()) return

    const onReady = () => {
      if (wire()) {
        document.removeEventListener("turbo:load", onReady)
        window.removeEventListener("load", onReady)
      }
    }

    document.addEventListener("turbo:load", onReady)
    window.addEventListener("load", onReady)
  })()
</script>

Props

Prop Type Default Description
status Symbol :info Visual status. One of: :success, :info, :warning, :error.
title String Status-based default Shorthand title. Prefer with_title slot for rich content.
sub_title String - Shorthand subtitle. Prefer with_sub_title slot for rich content.
icon Renderable or false Status illustration Custom icon component, or false to hide the icon entirely.
extra Renderable - Shorthand extra content. Prefer with_extra slot for rich content.
**html_options Keyword args - Attributes merged into the wrapper element.

Programmatic Rendering

Supported params for <code>HakumiComponents.renderComponent("result", ...)</code>. Custom icon renderables are Ruby-only; programmatic rendering only maps <code>icon: false</code> to hide the status icon.
Prop Type Default Description
status String - Visual status. One of: success, info, warning, error.
title String - Shorthand title text.
sub_title String - Shorthand subtitle text.
extra String - Shorthand extra content.
icon false - Pass false to hide the status icon. Other icon values are not mapped.