Stay up to date with new components!
Error!
Success! Thanks so much 🥰

Web Components On Fire

View the source

Split Flap

We live in the 21st century folks and we no longer have signs that work like this:

The split flap board in Philadelphia’s 30th Street Station, which was removed in 2019.

This board, while obviously inferior to a digital display in many ways, has a certain appeal to it. Instead of projecting pixelated LED light into your retinas, it’s actually moving and reflecting natural light. There’s something to the infinite resolution on this thing.

As an ode to the train stations of my childhood, I bring you a skeuomorph split-flap web component:

Split Flap

The <hotfx-split-flap> custom element animates the text inside of it. To use it, first add this script to your page:

Then just wrap your message in the custom element, like so:

<hotfx-split-flap>Your message here</hotfx-split-flap>

That’s all it takes and the transition will start as soon as your readers scroll the component into the viewport.

Set Some Attributes

The custom element accepts a few attributes to control the output:

Here’s a playground for you to build your own split flap board.

Custom Split Flap
50 1000
speed= 150

If you don’t specify height and width for your board, the element will take the height and width of the first message inside of it. If you later change out the message, it will be truncated to fit. The first demo gets around this by creating a new element when the text doesn’t fit.

Internationalization

There’s another attribute named characters which lets you control the alphabet of characters shown on the flaps. Here’s one in Russian, showing the titles of some of Tolstoy’s novels.

Tolstoy’s Novels

You can see that I’ve changed some of the colors on this board using the ::part(flap) selector. Also, I’m swapping out the message on the board every few seconds using a simple callback scheduled with setInterval.

Rolling Forward

There’s not much of a roadmap for this component, but I would love to see whole words shown on one flap just like the destinations on the train station board at the top of the post.

Can you think of other improvements? Of course, if you find bugs or have feature requests, please file a new issue on GitHub.