Semana de lanzamiento50 % de descuento en un año de AuteurVer planes
MCP
EspaciosHazte Pro
Blueprint · N.º 05

Icons that change their mind

Why a menu button should fold into a close button rather than swap for one, and the three-line trick that lets any icon become any other.

· 6 min de lectura · Las notas están escritas en inglés.

When a button's job changes, most interfaces swap its icon: the menu fades out, a cross fades in. It works. It also tells you the wrong story. A crossfade says something else is here now. What actually happened is that this button became that one, and the icon can say so by changing shape in front of you.

menu
Fig. 1Twenty-two icons, any of which can become any other. Tap the big one, or pick from the grid.

One skeleton for everything

The trick is to stop thinking of icons as pictures and start thinking of them as positions. Every icon in the set is drawn with exactly three straight lines in a 24 by 24 box. A menu is three bars. A plus is two lines crossing, with the third folded away to a point in the middle. A check is a short leg and a long one. Play is three lines sharing their corners.

Because every icon is made of the same three parts, turning one into another is just moving the ends of those lines somewhere new. A line an icon doesn't need folds down to a point and fades. A line it gains grows out of where it will sit.

menu
Fig. 2The grid under every icon. Watch the same three lines keep rearranging themselves.

Arrows turn, they don't warp

The first version morphed everything, and an arrow pointing right becoming an arrow pointing down looked broken: the head bent and the shaft stretched on the way. Your eye knows that's the same arrow turning a corner. So icons that are one shape pointing different ways (arrows, chevrons, plus and close) rotate instead, always the short way round.

That opens a small puzzle. If an arrow is pointing down and becomes a check, the check would arrive sideways. So before any morph, the current turn is baked into plain coordinates, and only then do the line ends move. Nobody sees that step, which is the point.

The numbers

Lines per icon
3, with round caps
Morph
spring, bounce 0.22, about 0.5 s
Turns
the shortest way, tracked as a running angle
Lines folding away
fade in 0.14 s so no dot is left
Reduced motion
switches instantly
A morph should answer a tap. An icon that changes on its own is just movement.

Use it where a control's meaning changes: menu and close, play and pause, send and sent, a sort order flipping. Don't use it for detailed icons (three lines can't draw a camera) or to decorate a list. Every line ends up computed in code rather than rotated with CSS, because browsers still disagree about where an SVG turns from, and Safari won't animate SVG geometry at all.

import { MorphIcon } from '@/components/velvo/morph-icon'

<button onClick={() => setOpen(!open)} aria-label={open ? 'Close menu' : 'Open menu'}>
  <MorphIcon name={open ? 'close' : 'menu'} />
</button>

Hecho en esta nota

Cada figura de arriba es un componente de Velvo. Añádelos a tu app y dale a tu agente las skills que hay detrás.

$npx velvo add morph-icon button accordion
Más notasLive data should breathe