Border Animation
At rest the field has no frame; on focus its four sides draw one after another like a pen going round it, then unwind when you leave.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Forms has 21 effects, including 2 free. Explore the category →
3 usage examples



How it works
The .bda-input field sits in a .bda-box set to position: relative, followed by four empty <span class="bda-edge">. Each is a 2 px stroke pinned to one edge: .bda-top anchored top-left, .bda-right top-right, .bda-bottom bottom-right, .bda-left bottom-left. At rest their length is zero, hence a field with no border, just a rgba(255, 255, 255, .03) fill.
On focus, the .bda-input:focus ~ .bda-… selector takes the horizontal strokes to width: 100% and the vertical ones to height: 100%. Since each stroke grows from its anchor point, the top runs left to right, the right side goes down, the bottom comes back left and the left side climbs up. Each segment lasts 0.3 s and starts after a 0, 0.1, 0.2 then 0.3 s delay: the frame is complete in 0.6 s.
The same delays apply when the field is left, the strokes withdraw into their original corner in the same order. The colour comes from --bda-color (default #6366f1). The .bda-caption text above the field is its visible label; the .fx-0283-root root is only a 300 px tall presentation background.
Accessibility
- Label: "Your first name" sits in the
<label>that contains the field, stays visible while typing and gives screen readers its name. The four strokes carryaria-hidden="true". - Inside a form:
name="given-name"andautocomplete="given-name"are supplied, the value is submitted and the browser offers the saved first name. - Focus indicator: the full frame (2 px, indigo on dark, 4.4:1) is the focus indicator. It only exists during focus, which is the expected behaviour.
- Reduced motion:
prefers-reduced-motion: reduceremoves the transition, the whole frame appears on focus. - Limit: at rest, with no border and an almost transparent fill, the field is hard to make out on a light page. Give it a stronger background in that case (see settings).
Browser compatibility
width and height transitions, the ~ selector and one CSS variable: Chrome 49, Firefox 31, Safari 9.1. Checked in Chromium, Firefox and WebKit with two copies in one form, by click, Tab and touch, at 390 px and with reduced motion. The example captures are driven by the scene script (simulated focus and typing, capture clicks that sometimes remove focus): that driving is not part of the code you buy.
Without CSS variables the strokes lose their colour and focus becomes invisible: replace var(--bda-color, #6366f1) with the plain colour if you target very old browsers.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0283-root">
<label class="bda-field">
<span class="bda-caption">Your first name</span>
<span class="bda-box">
<input class="bda-input" type="text" name="given-name" autocomplete="given-name">
<span class="bda-edge bda-top" aria-hidden="true"></span>
<span class="bda-edge bda-right" aria-hidden="true"></span>
<span class="bda-edge bda-bottom" aria-hidden="true"></span>
<span class="bda-edge bda-left" aria-hidden="true"></span>
</span>
</label>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Frame colour (CSS — --bda-color) |
#6366f1 |
Applies to all four strokes at once. Set it on the root, the form or a single field. |
Width (CSS — --bda-width) |
280 px | 100% to fill the column; the field never exceeds its parent thanks to max-width: 100%. |
Duration per side (CSS — transition of .bda-edge) |
0.3 s | Down to 0.2 s gives a snappier stroke; keep the gap between sides shorter than the duration, or the stroke pauses at every corner. |
Offset between sides (CSS — transition-delay) |
0 / 0.1 / 0.2 / 0.3 s | Setting all four to 0 makes the frame appear in one go, each side from its corner. |
Thickness (CSS — height of .bda-top/.bda-bottom, width of .bda-right/.bda-left) |
2 px | Four values to change together. |
Resting field fill (CSS — background of .bda-input) |
rgba(255, 255, 255, .03) |
On a light page, switch to #f1f5f9 and make the text colour dark, so the field stays visible before focus. |
Visible label (HTML — .bda-caption) |
shown above | Can be removed in a table cell or on a screen where the question is already written; then put aria-label on the field. |
FAQ
border-radius: 8px. For a consistent look, set border-radius: 0 on .bda-input, or keep that contrast, which is part of the original design.:focus rule and on the resting rule.<input> with <textarea class="bda-input"> and keep the four strokes right after it. The vertical strokes take height: 100% of the box, so they follow the area's real height.