> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yield.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Widgets & UI

> Ready-made interfaces on the Yield.xyz APIs: the yield widget, Widget Pro with Borrow, and the Perps widget and dashboard.

export const ExpandableDemo = ({src, title, desktopWidth = 1440, desktopHeight = 900, caption}) => {
  const [open, setOpen] = useState(false);
  const [scale, setScale] = useState(0.5);
  const boxRef = useRef(null);
  useEffect(() => {
    const box = boxRef.current;
    if (!box) return undefined;
    const update = () => setScale(Math.min(1, box.clientWidth / desktopWidth));
    update();
    const observer = new ResizeObserver(update);
    observer.observe(box);
    return () => observer.disconnect();
  }, [desktopWidth]);
  const dialogRef = useRef(null);
  const closeRef = useRef(null);
  useEffect(() => {
    const dialog = dialogRef.current;
    if (!dialog) return undefined;
    if (open && !dialog.open) {
      dialog.showModal();
      closeRef.current?.focus();
    }
    if (!open && dialog.open) dialog.close();
    const previousOverflow = document.body.style.overflow;
    if (open) document.body.style.overflow = "hidden";
    return () => {
      document.body.style.overflow = previousOverflow;
    };
  }, [open]);
  return <figure style={{
    margin: "24px 0"
  }}>
      <div ref={boxRef} style={{
    position: "relative",
    width: "100%",
    height: `${Math.round(desktopHeight * scale)}px`,
    overflow: "hidden",
    borderRadius: "16px",
    border: "1px solid rgba(127, 127, 127, 0.25)"
  }}>
        <iframe src={src} title={`${title} (preview)`} width={desktopWidth} height={desktopHeight} loading="lazy" tabIndex={-1} aria-hidden="true" style={{
    border: 0,
    width: `${desktopWidth}px`,
    height: `${desktopHeight}px`,
    transform: `scale(${scale})`,
    transformOrigin: "0 0",
    pointerEvents: "none"
  }} />
        <button type="button" onClick={() => setOpen(true)} aria-label={`Open the ${title} live demo`} style={{
    position: "absolute",
    inset: 0,
    width: "100%",
    height: "100%",
    display: "flex",
    alignItems: "center",
    justifyContent: "center",
    background: "rgba(0, 0, 0, 0.12)",
    border: 0,
    cursor: "pointer"
  }}>
          <span style={{
    padding: "10px 18px",
    borderRadius: "999px",
    background: "#111827",
    color: "#ffffff",
    fontSize: "15px",
    fontWeight: 600,
    boxShadow: "0 4px 16px rgba(0, 0, 0, 0.25)"
  }}>
            Open live demo
          </span>
        </button>
      </div>
      <figcaption style={{
    marginTop: "8px",
    fontSize: "14px",
    opacity: 0.75,
    textAlign: "center"
  }}>
        {caption ? `${caption} ` : ""}
        <a href={src} target="_blank" rel="noopener noreferrer">
          Open in a new tab
        </a>
      </figcaption>

      <dialog ref={dialogRef} aria-label={title} onClose={() => setOpen(false)} onClick={event => {
    if (event.target === event.currentTarget) setOpen(false);
  }} style={{
    width: "100vw",
    height: "100vh",
    maxWidth: "100vw",
    maxHeight: "100vh",
    margin: 0,
    padding: "24px",
    border: 0,
    background: "rgba(0, 0, 0, 0.75)",
    display: open ? "flex" : "none",
    alignItems: "center",
    justifyContent: "center",
    boxSizing: "border-box"
  }}>
        {open && <div style={{
    position: "relative",
    width: "min(94vw, 1600px)",
    height: "88vh",
    borderRadius: "16px",
    overflow: "hidden",
    background: "#ffffff",
    boxShadow: "0 24px 64px rgba(0, 0, 0, 0.4)"
  }}>
            <iframe src={src} title={title} allow="clipboard-read; clipboard-write" style={{
    border: 0,
    width: "100%",
    height: "100%"
  }} />
            <button ref={closeRef} type="button" onClick={() => setOpen(false)} aria-label="Close the demo" style={{
    position: "fixed",
    top: "8px",
    right: "8px",
    width: "36px",
    height: "36px",
    borderRadius: "999px",
    border: 0,
    background: "#111827",
    color: "#ffffff",
    fontSize: "18px",
    lineHeight: "36px",
    cursor: "pointer"
  }}>
              ✕
            </button>
          </div>}
      </dialog>
    </figure>;
};

export const CompactDemo = ({src, title, width = 480, height = 720, caption}) => {
  return <figure style={{
    margin: "24px 0",
    textAlign: "center"
  }}>
      <iframe src={src} title={title} width={width} height={height} allow="clipboard-read; clipboard-write" loading="lazy" style={{
    border: "1px solid rgba(127, 127, 127, 0.25)",
    borderRadius: "16px",
    width: "100%",
    maxWidth: `${width}px`,
    height: `${height}px`,
    display: "block",
    margin: "0 auto"
  }} />
      <figcaption style={{
    marginTop: "8px",
    fontSize: "14px",
    opacity: 0.75
  }}>
        {caption ? `${caption} ` : ""}
        <a href={src} target="_blank" rel="noopener noreferrer">
          Open the demo in a new tab
        </a>
      </figcaption>
    </figure>;
};

Yield.xyz provides ready-made interfaces built on the same APIs you integrate directly. Use one to launch Earn, Borrow or Perps without building the UI yourself, then keep it or replace it later. Each one calls the APIs with your project's API key, so it shows only what is enabled for your project. Users sign every transaction in their own wallet.

## Which one to use

| | What it is | Covers | How you add it |
| - | - | - | - |
| [Yield widget](/guides/widgets-dashboard/yield-widget) | A compact Earn interface | Yield discovery, wallet connection, enter, exit and manage | npm package `@stakekit/widget`, as a React component or a browser renderer |
| [Widget Pro](/guides/widgets-dashboard/yield-dashboard) | The dashboard layout of the same widget | Earn by category, Borrow, positions and activity | The same package with `dashboardVariant` |
| [Perps widget](/guides/widgets-dashboard/perps-widget) | A compact perpetual futures trading module | Long and short with leverage, orders, TP/SL, deposits and withdrawals | Hostable app from a public repository, embedded with an iframe |
| [Perps dashboard](/guides/widgets-dashboard/perps-dashboard) | A full desktop trading terminal | Markets, chart, order form, positions and orders | Hostable app from the same repository |

Borrow is a Widget Pro setting, not a separate widget. Turn it on with `borrowEnabled`. See the [Borrow widget](/guides/borrow/widget) guide.

## Try the demos

<Tabs>
  <Tab title="Yield widget">
    <CompactDemo src="https://widget.stakek.it/?variant=classic" title="Yield.xyz widget demo" width={480} height={720} />
  </Tab>

  <Tab title="Widget Pro">
    <ExpandableDemo src="https://widget-pro.yield.xyz/" title="Widget Pro" />
  </Tab>

  <Tab title="Perps widget">
    <CompactDemo src="https://perps-widget.vercel.app/" title="Yield.xyz Perps widget demo" width={400} height={640} />
  </Tab>

  <Tab title="Perps dashboard">
    <ExpandableDemo src="https://perps-dashboard.vercel.app/" title="Perps dashboard" />
  </Tab>
</Tabs>

Wallet extensions connect more reliably in a full tab than inside an embedded demo, so open a demo in a new tab to try a full flow.

## Before you go live

* **API key exposure.** A widget runs in the browser, so its API key is readable by anyone who loads the page. Read the [security notice](/legal/security-notice) for the risks and how to limit them.
* **What users see.** The widgets show only the yields, markets and venues enabled for your project. Use [yield blocking](/documentation/advanced-setup/dashboard/yield-blocking) to remove specific yields.
* **Fees.** Fees configured for your project apply to actions taken through a widget, as they do through the API. See [Earn monetization](/documentation/earn/monetization).
* **Theming.** The yield widget and Widget Pro take a theme object with your colors, fonts and radii. To restyle the Perps apps, edit their source.

## Guides

<Columns cols={2}>
  <Card title="Yield widget" icon="code" href="/guides/widgets-dashboard/yield-widget">
    Install, embed, wallets, theming and every prop.
  </Card>

  <Card title="Widget Pro" icon="gauge" href="/guides/widgets-dashboard/yield-dashboard">
    The dashboard layout, with Borrow, Manage and Activity.
  </Card>

  <Card title="Perps widget" icon="mobile-screen" href="/guides/widgets-dashboard/perps-widget">
    Run, deploy and embed the compact Perps module.
  </Card>

  <Card title="Perps dashboard" icon="chart-line" href="/guides/widgets-dashboard/perps-dashboard">
    Run and deploy the full trading terminal.
  </Card>
</Columns>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.