> For the complete documentation index, see [llms.txt](https://docs.orbs.network/orbs-integrations/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.orbs.network/orbs-integrations/swap-ui-library/usage.md).

# Usage

[**View on GitHub**](https://github.com/orbs-network/swap-ui)

The SwapFlow component handles the entire swap process. It takes in various props like inAmount, outAmount, inToken, and outToken, as well as custom content to display during different steps of the process.

Props:

* `inAmount`: The amount of the input token.
* `outAmount`: The amount of the output token.
* `inToken`: An object representing the input token (e.g., symbol, logo).
* `outToken`: An object representing the output token (e.g., symbol, logo).
* `mainContent`: The main content displayed during the swap.
* `failedContent`: The content shown if the swap fails.
* `successContent`: The content shown if the swap succeeds.
* `swapStatus`: The current status of the swap (loading, success, or failed).

the SwapFlow\.Swap component is a built-in component that displays the swap steps. It takes in the next props:

* `inUsd`: The amount of the input token in USD.
* `outUsd`: The amount of the output token in USD.
* `steps`: An array of steps in the swap process.
* `currentStep`: The current step in the swap process.

the steps array is an array of objects representing the steps in the swap process. Each object has the next properties:

* `id`: The step ID.
* `title`: The title of the step.
* `image`: The URL of the image for the step.
* `timeout`: The timeout for the step (optional).

the SwapFlow\.FailedContent component is a built-in component that displays the failed content. It takes in the next props:

* `error`: The error message.

the SwapFlow\.SuccessContent component is a built-in component that displays the success content. It takes in the next props:

* `title`: The title of the success message.
* `explorerUrl`: The URL to the transaction explorer.

```javascript
const steps: SwapStep[] = [
  {
    id: 1,
    title: "Wrap ETH",
    image: "logo-url",
  },
  {
    id: 2,
    title: "Approve ETH",
    image: "logo-url",
  },
  {
    id: 3,
    title: "Confirm Swap",
    timeout: 40_000,
    image: "logo-url",
  },
];

export const Swap = () => {
  return (
    <>
      <SwapFlow
        inAmount="10"
        outAmount="10"
        inToken={{
          symbol: "ETH",
          logo: "logo-url",
        }}
        outToken={{
          symbol: "USDC",
          logo: "logo-url",
        }}
        mainContent={
          <SwapFlow.Swap
            inUsd={inUsd}
            outUsd={outUsd}
            steps={steps}
            currentStep={currentStep}
          />
        }
        failedContent={<FailedContent error="error" />}
        successContent={
          <SuccessContent title="title" explorerUrl="explorerUrl" />
        }
        swapStatus={swapStus}
      />
      <Button className="swap-button" onClick={swap}>
        Swap
      </Button>
    </>
  );
};
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.orbs.network/orbs-integrations/swap-ui-library/usage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
