clickworks
Works / Forms

Compose Link

At rest it's a plain email link that works without JavaScript. Click it and the address flies into the To line of a letter that unfolds in place, with topic chips that start the message and a greeting already written. Send hands it to Gmail, Outlook or the mail app, or to your own handler. Then the letter folds into a Sent note and flies off.

Free1 file0 dependencies10.7 kB gzippedRenders on the serverKeyboard and screen reader

Install

npx shadcn@latest add https://clickworks.dev/r/compose-link.json

The files land in components/clickworks/compose-link/. No other packages are added.

Usage

import { ComposeLink } from "@/components/clickworks/compose-link/react/ComposeLink"

export function Contact() {
  return <ComposeLink email="hello@yourstudio.com" person={{ name: "Sam", city: "Lisbon", timeZone: "Europe/Lisbon" }} />
}

Props

email
string

Where the letter goes.

Default "hello@example.com"

person
{ name?, city?, timeZone?, replyNote?, avatar?, photo? }

Who it's to. The name fills the greeting, and the time zone shows your local time.

topics
{ label, subject, starter }[]

Chips that fill in the subject and start the message. Up to five.

texts
object

Every word on the letter, from the To label to the Sent note.

theme
"auto" | "light" | "dark"

Auto follows the page (its background, data-theme or dark class), then the device.

Default "auto"

light / dark
object

Colours for each theme.

behaviour
{ opens?, gmail?, outlook?, mailApp?, veil?, drafts? }

Where the letter opens and which inboxes are offered. Drafts are kept between visits.

onSend
(letter: { from, to, subject, message }) => unknown

Send it yourself, for example to an API route. The letter then asks where to reply first.

Events

onSent
() => void

The letter went out.

onError
() => void

Your handler failed.

Styling

Colours come in through the light and dark props. The link takes linkFont and the letter takes cardFont, or both use your site's font.

Behaviour and accessibility

  • The link is a real mailto link, so it works without JavaScript and for search engines.
  • The letter traps focus while open. Escape closes it and returns focus to the link.
  • Sending and errors are announced to screen readers.
  • With reduced motion the letter appears without flying.

Files

react/ComposeLink.tsxReact component