08.3Block 08.3 · Calls to action
Attract CTA
A newsletter band whose button is a magnet. As the pointer comes near, brass filings behind it turn, stream in and stand round it in a bristling ring, and stay there.
- Version
- 0.1.0
- Size
- 138.3 KB gzipped
- Access
- With a Pass
- Needs
- attract-cta.mjs + attract-cta.css · Filings
- Tests
- 12 tests · 10 states
On this page
Use it
Make the one action on a signup band physically attractive without a word of hype: the button pulls, the visitor sees it pull, hesitation leaves a visible trace, and the form underneath is a real, honest form.
Copy the attract-cta folder and the filings folder from its package next to your page, link the stylesheets and mount it on an element. Every option has a default; the lab’s Code tab writes the same example at any settings, and for React, Vue, Svelte or a custom element (Using a framework).
<link rel="stylesheet" href="filings/filings.css">
<link rel="stylesheet" href="attract-cta/attract-cta.css">
<div id="attract-cta"></div>
<script type="module">
import Filings from './filings/filings.mjs';
import { mount } from './attract-cta/attract-cta.mjs';
const attractCta = mount(document.getElementById('attract-cta'), {
eyebrow: 'A monthly letter · Issue 58',
title: 'Remanence',
subtitle: 'What stays with you after the field is gone.',
}, { Filings });
// attractCta.update({ … }); change any option in place
// attractCta.destroy(); and take it away again
</script>Options
| Option | Type | Default | What it does |
|---|---|---|---|
| eyebrow | text | 'A monthly letter · Issue 58' | Eyebrow |
| title | text | 'Remanence' | Name of the letter |
| subtitle | text | 'What stays with you after the field is gone.' | Standfirst |
| body | text | 'Twelve minutes on magnets, motors and the materials between them: one teardown, one paper worth your evening, one thing we got wrong. Written at the bench by the engineers of a small coil-winding shop.' | Paragraph |
| proof | text | '11,400 engineers read it · No tracking pixels · Leave from any issue' | Separated by “·”; up to four. |
| fieldLabel | text | 'Your email' | Field label |
| placeholder | text | '[email protected]' | Field placeholder |
| button | text | 'Subscribe' | Button (the magnet) |
| fine | text | 'One letter on the first Sunday of the month. The list is never shared or sold.' | Fine print |
| success | text | 'You’re on the list. Issue 59 lands on the first Sunday.' | Thank-you line |
| action | text | '' | Where the form posts. Empty: nothing is sent, and the section says so. |
| palette | brass · bone | 'brass' | Brass filings on black, or dark iron on bone paper. |
| reach | number, 160 to 560 | 340 | How near the pointer must come before the button starts to pull. |
| light | number, 0 to 345 | 300 | Light from (degrees) |
Methods
mount(element, options, { Filings })- Builds the block inside the element and returns its handle. Hand it the Filings it is built with.
handle.update(next = {})- Change options in place.
handle.level- How strongly the button's magnet is on, 0…1.
handle.sheethandle.roothandle.destroy()- Stops it and cleans up after it.
Events it fires, which bubble from the element: subscribe.
States
- WaitingAn even scatter of filings behind the form; the button's magnet is off; a small tag says to bring the pointer closer.
- ApproachingThe magnet is switched on by nearness (full on the button, off at the reach, in twentieths); the filings turn toward the button, clear a moat and gather into a ring 9–36px outside its edge.
- LeavingThe magnet goes off, but the gathered iron stays where it went, as iron does; the sheet settles and sleeps.
- KeyboardFocus in the field or on the button switches the magnet fully on until focus leaves the form.
- Invalid addressThe section says so in its own voice, marks the field invalid and returns focus to it.
- Sent or notA handled subscribe event shows the thank-you line; with an action the form posts; with neither, it says plainly that nothing was sent. Either way the magnet goes full on and the sheet is tapped at the button.
- PaletteBrass filings on black, or dark iron on bone paper with an oxide-red accent.
- NarrowUnder 820px one column: the copy on solid ground, the form on the iron below; under 480px the button fills its row with room for its ring.
- Reduced motionThe iron is gathered round the button on the first paint; nothing moves.
- Off screenThe sheet's loop pauses; the block runs nothing of its own.
How it works
Made of: Button as magnet, Ring magnet shape, Proximity power, Iron remembers, Honest form, Container query recomposition.
Original composition; Remanence and its copy are invented. The ring magnet is Filings' shape option, drawn from the button's measured box. Faces: Crimson Pro and Instrument Sans (SIL OFL 1.1) as WOFF2, licences beside them.
Built with
More blocks on the same object: