Postcard with signature pad
A hairline postcard with ruled message lines, a drawn stamp, address fields and a canvas to sign in blue biro.
Part of the style
Blue Biro Doodles
7 parts that belong together, with their tokens, type and rules.
https://kitbash.me/components/blue-biro-doodles/postcard/figma.html?type=rollerdrome-colour-block
Use the Figma MCP server (https://mcp.figma.com/mcp). Download https://kitbash.me/components/blue-biro-doodles/postcard/figma.html?type=rollerdrome-colour-block and pass that whole HTML document to the html_to_figma tool, so the part "Postcard with signature pad" lands as editable layers in my open Figma file. Fonts come from Google Fonts: if a face is missing in Figma, pick the closest one.
Code
<style>
/* Goes after the pack's base.css */
@import url("https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,100..900&display=swap");
:root {
--font-hand: "Archivo", "Helvetica Neue", Arial, sans-serif;
--font-body: "Archivo", "Helvetica Neue", Arial, sans-serif;
--font-tag: "IBM Plex Mono", ui-monospace, monospace;
}
</style>
<section class="postcard">
<h2 class="postcard__heading">send a postcard</h2>
<form class="postcard__card" action="#" novalidate>
<div class="postcard__left">
<label class="postcard__label" for="postcard-message">dear studio,</label>
<textarea class="postcard__message" id="postcard-message" name="message" rows="6" placeholder="I'd like a mug that holds a lot of tea..."></textarea>
<div class="postcard__sign">
<span class="postcard__label">sign here</span>
<canvas class="postcard__pad" aria-label="Signature pad: draw with a mouse, pen or finger"></canvas>
<button class="postcard__clear" type="button">rub out</button>
</div>
</div>
<div class="postcard__right">
<svg class="postcard__stamp" viewBox="0 0 80 96" aria-hidden="true">
<path d="M6 6 L74 5.4 L74.6 90 L5.4 90.6 Z" stroke-dasharray="3 4" />
<path d="M14 14.4 L66 14 L66.4 80 L13.6 80.4 Z M26 64 C22 54 26 44 34 40.4 C31 37 33 34 36 34 L46 34.2 C49 34 51 37 48 40.2 C56 44 58 54 54 64 Z M20 72 L60 71.6" />
</svg>
<label class="postcard__label" for="postcard-name">from</label>
<input class="postcard__field" id="postcard-name" name="name" type="text" autocomplete="name" placeholder="your name" />
<label class="postcard__label" for="postcard-email">reply to</label>
<input class="postcard__field" id="postcard-email" name="email" type="email" autocomplete="email" placeholder="you@somewhere.net" />
<button class="postcard__send" type="submit">post it</button>
<p class="postcard__done" role="status"></p>
</div>
</form>
</section>
<style>
.postcard {
padding: var(--section-space) var(--edge);
max-width: 1040px;
margin: 0 auto;
}
.postcard__heading {
margin: 0 0 var(--space-l);
font-family: var(--font-hand);
font-size: var(--hand-m);
font-weight: 400;
line-height: 1;
rotate: -1deg;
}
.postcard__card {
display: grid;
grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
border: var(--rule) solid var(--ink);
border-radius: var(--radius-none);
rotate: 0.6deg;
}
.postcard__left,
.postcard__right {
display: grid;
align-content: start;
gap: var(--space-s);
padding: var(--space-l);
}
.postcard__left {
border-right: var(--rule) solid var(--ink);
}
.postcard__right {
position: relative;
padding-top: calc(var(--space-l) + 96px);
}
.postcard__label {
font-family: var(--font-hand);
font-size: 26px;
line-height: 1;
}
.postcard__message {
width: 100%;
min-height: 8.4em;
padding: 0 var(--space-xs);
border: 0;
border-radius: var(--radius-none);
background: repeating-linear-gradient(to bottom, transparent 0 calc(1.75em - 1px), var(--ink-faint) calc(1.75em - 1px) 1.75em);
color: var(--ink);
font: 400 var(--text-m)/1.75em var(--font-body);
resize: vertical;
}
.postcard__field {
width: 100%;
min-height: 44px;
padding: var(--space-xs);
border: 0;
border-bottom: var(--rule) solid var(--ink);
border-radius: var(--radius-none);
background: transparent;
color: var(--ink);
font: 400 var(--text-m) var(--font-body);
}
.postcard__field + .postcard__label {
margin-top: var(--space-s);
}
.postcard__message::placeholder,
.postcard__field::placeholder {
color: var(--ink-soft);
font-style: italic;
opacity: 1;
}
.postcard__message:focus-visible,
.postcard__field:focus-visible {
outline: var(--rule) solid var(--ink);
outline-offset: 2px;
background-color: var(--ink-wash);
}
.postcard__sign {
position: relative;
display: grid;
gap: var(--space-xs);
margin-top: var(--space-s);
}
.postcard__pad {
width: 100%;
height: 110px;
border-bottom: var(--rule) dashed var(--ink);
touch-action: none;
cursor: crosshair;
}
.postcard__clear,
.postcard__send {
justify-self: start;
min-width: 44px;
min-height: 44px;
padding: 0 var(--space-m);
border: 0;
border-radius: var(--radius-pill);
outline: var(--rule) solid transparent;
background-color: transparent;
color: var(--ink);
font-family: var(--font-hand);
font-size: 24px;
line-height: 1;
cursor: pointer;
transition: outline-color var(--quick) var(--ease), background-color var(--quick) var(--ease);
}
.postcard__clear {
position: absolute;
right: 0;
top: -10px;
font-size: 20px;
}
.postcard__send {
margin-top: var(--space-m);
outline-color: var(--ink);
font-size: var(--hand-s);
rotate: -3deg;
}
.postcard__clear:hover,
.postcard__clear:focus-visible,
.postcard__send:hover,
.postcard__send:focus-visible {
outline-color: var(--ink);
background-color: var(--ink-wash);
}
.postcard__stamp {
position: absolute;
top: var(--space-l);
right: var(--space-l);
width: 66px;
height: 80px;
fill: none;
stroke: var(--ink);
stroke-width: var(--stroke);
stroke-linecap: round;
stroke-linejoin: round;
rotate: 4deg;
}
.postcard__done {
min-height: 1.4em;
margin: 0;
font-family: var(--font-hand);
font-size: 24px;
}
@media (max-width: 44rem) {
.postcard__card {
grid-template-columns: 1fr;
rotate: 0deg;
}
.postcard__left {
border-right: 0;
border-bottom: var(--rule) solid var(--ink);
}
.postcard__left,
.postcard__right {
padding: var(--space-m);
}
.postcard__right {
padding-top: var(--space-m);
padding-right: 100px;
}
.postcard__stamp {
top: var(--space-m);
right: var(--space-m);
}
}
</style>
<script>
(() => {
for (const root of document.querySelectorAll('.postcard')) {
const form = root.querySelector('.postcard__card');
const pad = root.querySelector('.postcard__pad');
const done = root.querySelector('.postcard__done');
const pen = pad.getContext('2d');
let last = null;
const fit = () => {
const ratio = window.devicePixelRatio || 1;
const box = pad.getBoundingClientRect();
pad.width = Math.round(box.width * ratio);
pad.height = Math.round(box.height * ratio);
pen.setTransform(ratio, 0, 0, ratio, 0, 0);
pen.lineCap = 'round';
pen.lineJoin = 'round';
pen.lineWidth = 1.6;
pen.strokeStyle = getComputedStyle(root).color;
};
const point = (event) => {
const box = pad.getBoundingClientRect();
return { x: event.clientX - box.left, y: event.clientY - box.top };
};
pad.addEventListener('pointerdown', (event) => {
pad.setPointerCapture(event.pointerId);
last = point(event);
});
pad.addEventListener('pointermove', (event) => {
if (!last) return;
const next = point(event);
pen.beginPath();
pen.moveTo(last.x, last.y);
pen.lineTo(next.x, next.y);
pen.stroke();
last = next;
});
const lift = () => { last = null; };
pad.addEventListener('pointerup', lift);
pad.addEventListener('pointercancel', lift);
root.querySelector('.postcard__clear').addEventListener('click', fit);
form.addEventListener('submit', (event) => {
event.preventDefault();
done.textContent = 'posted! we read every one.';
});
new ResizeObserver(fit).observe(pad);
}
})();
</script>