Steps

Renders a navigation for form steps.

Read more Read less

Maturity: Developing

Usage

Completed steps get accessibility text marked with the data-visually-hidden attribute, which needs a CSS rule. See Visually hidden text.

With patch navigation:

<.steps current_step={0} label="Order process">
  <:step on_click={JS.patch(to: ~p"/form/step/personal-information")}>
    Profile
  </:step>
  <:step on_click={JS.patch(to: ~p"/form/step/delivery")}>
    Delivery
  </:step>
  <:step on_click={JS.patch(to: ~p"/form/step/confirmation")}>
    Confirmation
  </:step>
</.steps>

With push events:

<.steps current_step={0} label="Order process">
  <:step on_click={JS.push("go-to-step", value: %{step: "profile"})}>
    Profile
  </:step>
  <:step on_click={JS.push("go-to-step", value: %{step: "delivery"})}>
    Delivery
  </:step>
  <:step on_click={JS.push("go-to-step", value: %{step: "confirmation"})}>
    Confirmation
  </:step>
</.steps>
<.steps label="Order process" current_step={1}>
  <:step on_click={Phoenix.LiveView.JS.push("go-to-step", value: %{step: "profile"})}>
    Profile
  </:step>
  <:step on_click={Phoenix.LiveView.JS.push("go-to-step", value: %{step: "delivery"})}>
    Delivery
  </:step>
  <:step on_click={Phoenix.LiveView.JS.push("go-to-step", value: %{step: "confirmation"})}>
    Confirmation
  </:step>
</.steps>
<.steps label="Order process" current_step={1} linear>
  <:step on_click={Phoenix.LiveView.JS.push("go-to-step", value: %{step: "profile"})}>
    Profile
  </:step>
  <:step on_click={Phoenix.LiveView.JS.push("go-to-step", value: %{step: "delivery"})}>
    Delivery
  </:step>
  <:step on_click={Phoenix.LiveView.JS.push("go-to-step", value: %{step: "confirmation"})}>
    Confirmation
  </:step>
</.steps>