Skip to the content

Card fan

A deck of cards, each one a link: projects, products, articles, samples.

Become a member to unlock the full effect today.

Join now

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Geist and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    The stylesheet stacks the cards of the deck in one cell, so the deck is as tall as one card: the open fan spills over it, above by the lift and below by the foot of the arc. Give the deck that room, padding or margin, and keep overflow: visible on it and on its parents, or the fan is clipped. The deck's width is the room the fan may take.
  3. Add custom JS

  4. Use it on your own elements

    Custom attributes
    Select the element on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-card-fan Marks the deck, the box that holds the cards. It takes no value: leave the value field empty. That box is what the effect is mounted on, what carries the settings, and its width is the room the open fan may take. Without it on any box of the page, the embed marks the parent of the first card it finds next to itself, and says so in the console when there is none.
    data-card-fan-card Marks one card, a direct child of the deck. It takes no value. A card is what lifts under the pointer and what takes the focus, so in the preview it is the link itself. Without it on any card, nothing is mounted and the console says so. [ Required ]
    data-card-fan-state Written by the engine: idle, open, closing or still on the deck, active on the lifted card. Never written by hand; the stylesheet reads it for the pile and for the strip under the lifted card. [ Optional ]
    Settings
    Every setting is a custom attribute too, added the same way and on the same element. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-card-fan-shadow #15100c Tint of the shadow under each card and of its hairline, the ink in the cream and ink look. Options: any CSS colour, transparent for no shadow at all; taken out of this block, --card-fan-shadow on the deck takes over.
    data-card-fan-spread 46 Angle between the first card and the last one of the open fan, in degrees.
    data-card-fan-radius clamp(420px, 56vw, 900px) Radius of the arc the cards sit on, any CSS unit: how far below the cards the hand that holds them is. Shortened by the script when the deck is too narrow for the fan.
    data-card-fan-lift clamp(22px, 3.2vw, 52px) How far the card under the pointer rises out of the arc, any CSS unit.
    data-card-fan-room clamp(12px, 1.8vw, 30px) How far its two neighbours slide along the arc to make room, any CSS unit; each next card moves half as far.
    data-card-fan-grow 1.06 Size of the lifted card, in times its own size.
    data-card-fan-stagger 0.035 Delay between two cards as the fan opens and as it folds, in seconds.
    data-card-fan-duration 0.55 Time a card takes to settle after it is sent somewhere, in seconds.
    data-card-fan-bounce 0.22 Overshoot of the spring, 0 to 1.
    data-card-fan-peek 3 How many cards show in the pile at rest, counted from the top one; the others sit hidden right under the last one that shows.
    data-card-fan-tilt 5 Largest lean of a card in the pile, in degrees; each card that shows takes its own share of it.

What it does

Card fan is a cursor animation for Webflow and vanilla JavaScript, with no library. Also called card fan hover effect, fan out cards on hover or card stack hover effect.

A deck of cards, each one a link: projects, products, articles, samples. At rest the cards sit in a tight pile, a few of them leaning out from under the top one. When the pointer reaches the pile, or the deck takes the focus, or a finger taps it, the cards spread into an arc like a hand of playing cards, each on its own delay and its own spring. The card under the pointer lifts, straightens, grows a little and comes to the front, its shadow lengthening as it rises, while its neighbours slide along the arc to make room. Leaving folds the fan back into the pile, in order. A click on a card follows its link. No library: a small spring per card, transforms only, and no frame asked for at rest. On a narrow screen the same hand is held tighter, so the fan always fits the deck's width. Under reduced motion there is no pile and no fan: the cards are laid in a plain row.

Updated

Questions

Put the custom attribute data-card-fan on the deck and data-card-fan-card on each card, a direct child of the deck. Settings are attributes on the deck, for instance data-card-fan-spread="60". On the Designer canvas the cards show in a row, because the Designer never runs the Embed: the pile and the fan show in preview and on the published site.

Neither. Each card runs on a small spring written in the engine, with transforms only and no library, so a card sent somewhere else in mid flight curves towards its new place instead of restarting. The loop stops as soon as every card is settled, open or closed.

Raise data-card-fan-spread, the angle in degrees between the first card and the last one of the open fan, 46 by default. Lower gives a flat row of barely leaning cards; past 90 the end cards lie on their side. data-card-fan-radius is the arc the cards sit on, and the script shortens it when the deck is too narrow for the fan.

Something around the deck clips it: overflow: hidden on the deck, on the section or on a parent cuts the lifted card and the two ends of the fan. The deck is only as tall as one card, and the open fan spills above it by lift and below it by the foot of the arc, so give the deck a padding. Give each card a width of its own too, since a card at width: 100% leaves the fan no room to open.

On touch each step takes a tap: one on the pile opens it, one on a card lifts it, one on the lifted card follows its link, and a tap anywhere else folds the fan. From the keyboard the deck is one Tab stop, the arrows move from card to card, Enter follows the card and Escape folds the fan. Under prefers-reduced-motion there is no pile and no fan, and the cards are laid in a plain row.