# Moving border button

The sign-in page's one-off call to action. A navy glow travels its edge once every 2 seconds while it is hovered or focused, and keeps going while it is working. Use it once per page, for the action the page exists for; everywhere else, Button. Under reduced motion the glow holds still and the edge turns the focus blue.

- Beta: ready to use; its API can still change in a minor release.
- Category: Actions

```tsx
import { MovingBorderButton } from "@leap-crm/design-system";
```

## Best practices

- Do: Use it once per page, for the action the page exists for, like Sign in with LEAP.
- Do: Set `loading` while the work runs and say so in the label, like Signing in… The glow keeps travelling and the button is marked busy.
- Do: Give it a width through `className`, like `w-full` on a sign-in card. Its height is fixed at 48 px.
- Don't: Use it in the CRM's own screens, dialogs or forms. Use `Button` with `intent="primary"`.
- Don't: Rely on the glow alone to show that it is working. Under reduced motion the glow holds still, so the label has to say it.

## Keyboard

| Keys | What they do |
| --- | --- |
| Enter, Space | Presses the focused button. |

## Related

- [Button](./button.md)

## Examples

What the examples import:

```tsx
import { useState } from "react";
import { LeapIcon, MovingBorderButton } from "@leap-crm/design-system";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const wait = (ms: number) =>
  new Promise<void>(resolve => {
    setTimeout(resolve, ms);
  });

function SignIn() {
  const [loading, setLoading] = useState(false);
  const signIn = async () => {
    setLoading(true);
    await wait(2400);
    setLoading(false);
  };
  return (
    <MovingBorderButton
      icon={<LeapIcon />}
      loading={loading}
      onClick={signIn}
      className="w-80"
    >
      {loading ? "Signing in…" : "Sign in with LEAP"}
    </MovingBorderButton>
  );
}
```

### Rest

A neutral edge on a navy-50 fill, 48 px tall.

```tsx
<MovingBorderButton icon={<LeapIcon />} className="w-80">
  Sign in with LEAP
</MovingBorderButton>
```

### Hover

Hover over it or tab to it: the glow fades in and travels the edge.

```tsx
<MovingBorderButton icon={<LeapIcon />} className="w-80">
  Sign in with LEAP
</MovingBorderButton>
```

### Loading

Press it: while it works the glow keeps travelling, without a hover, and the button is busy.

```tsx
<SignIn />
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` (required) | `ReactNode` |  | The label, like "Sign in with LEAP". |
| `icon` | `ReactNode` |  | A 16 px mark before the label, like the LEAP icon. |
| `loading` | `boolean` | `false` | Working, like signing in: the glow keeps travelling and the button is busy. |
| `className` | `string` |  | Its width, like "w-full" (it is 48 px tall). |
