# copyFromUrl

> Copies a document fetched from a URL onto the clipboard when its host button is pressed, for a "Copy page" button that hands a page's Markdown twin to the reader.

```ts
import { copyFromUrl } from "@sdxc/ui/docs";
```

Fetches `href` with `Accept: text/markdown, text/plain` on every press and writes the
body to the clipboard, then dispatches a `ui:copy` CopyEvent. A failed fetch or
write writes `failedLabel` into the button's `[role="status"]` element for four seconds.

## Signature

```ts
copyFromUrl(href: string, failedLabel?: string): MixinDescriptor<HTMLButtonElement>
```

Returns: A mixin descriptor for the copy button's `mix` prop.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `href` | `string` | URL of the text to copy, such as the page's `.md` twin. |
| `failedLabel?` | `string` | What a screen reader announces when the copy fails. |

## Examples

```tsx
<button type="button" mix={[copyFromUrl("/docs/install.md", t("copyFailed")), copyFeedback(t("copied"))]}>
	{t("copyPage")}
	<span role="status" mix={[visuallyHidden()]} />
</button>
```
