Platform
VaultVault
  • Free15
  • Navigation19
  • Buttons9
  • Scroll55
  • Text27
  • Sliders & marquees19
  • Gallery & images67
  • Cursor24
  • Page transitions10
  • Loaders2
  • Backgrounds10
  • UI components33
ButtonsPart of ProButtons
IconsPart of ProIcons
  • Interface Essentials144
  • Social Icons69
  • Payment Badges41
SavedPart of ProSaved
Support
DocumentationDocumentation
MCP serverMCP server
SettingsSettings
VaultButtonsArrow Swap Button
3D Spiral GalleryBrowse all 182Expanding Pill Nav
  • Free15
  • Navigation19
  • Buttons9
  • Scroll55
  • Text27
  • Sliders & marquees19
  • Gallery & images67
  • Cursor24
  • Page transitions10
  • Loaders2
  • Backgrounds10
  • UI components33
  • Interface Essentials144
  • Social Icons69
  • Payment Badges41
Sign inSign in

Start free. The code for 15 components, no card needed.

Get 15 free

Arrow Swap Button

This one is locked. Become a member to open the code for it and the rest of the Vault.

See plansTry the 15 free ones

What you'll need.

Install

  • gsap

Setup

npm i gsap

More like this

  • Fill

Features.

  • The arrow slides diagonally out of its window while a twin slides in from the opposite corner
  • The round swatch behind the arrow stretches until it floods the whole pill
  • Leaving plays it backwards from wherever it is, so a quick in-and-out never jumps
  • Icon on the right (sliding up and right) or on the left (sliding down and left)
  • Keyboard focus plays it too, and it stays while the button keeps focus
  • The script makes the twin arrow itself: one icon in the markup
  • Respects prefers-reduced-motion: the swap is instant
  • GSAP only, plain CSS for the look

How to get it right.

Use a directional icon

The slide reads as "go": arrows, chevrons, an external-link mark. A symmetrical icon (a plus, a dot) slides out and back in looking the same, which loses the point.

Pick the side by meaning

Right for forward actions ("Find a hill", "Book now"), left for back ones ("Last season", "Back to all").

Keep the label short

The pill is sized by its content and doesn't wrap. The flood covers any length, but two or three words keep it a pill.

Variations.

  • Icon right — the default
  • Icon left — data-au-side="left": the row flips and the arrow points and slides down-left
  • Slow — data-au-duration="0.8" for a heavier, more deliberate flood
  • Your icon — swap the <svg> inside .isb_window for any 20×20 icon; keep data-isb-glyph on it
  • Your colours — override --isb-bg, --isb-text, --isb-fill, --isb-ink and --isb-focus

Where it fits.

  • Calls to action — "Get started", "Book a call"
  • Card footers — "Read the story" at the end of a card
  • Pagination — a left button for back, a right one for next
  • External links — with an outward arrow

Frequently asked.

Yes. Swap <button> for <a href> with the same class and root attribute, and drop type="button".

The script clones it into the twin that slides in, so you only change the icon in one place. destroy() removes the twin.

Set font-size on the button. Padding, gap and the icon are in em.

Each [data-au-icon-swap-button] is its own instance. window.au.IconSwapButton.refresh() picks up ones added later.

No. Load gsap before the script; nothing else is needed.

Related components.

Pro

Gooey Fan Menu

Click

Free

Rising Fill Button

Hover

Free

Circle Fill Button

Hover