Plucky: a standing wave underline

A little zero-dependency Web Component for the standing wave underline I’m using for the hover effect on the main nav of this site.

Example

It’s a zero-dependency, componentized version of what I described in detail in a previous blog post.

Installation

This isn’t on NPM because who else would want something so oddly specific? If you really want it, download Plucky.js and add it to your project.

Basic usage

Import the script and wrap any content you want in the custom element.

import { Plucky } from "/path/to/Plucky.js";
<plucky-underline>Some text</plucky-underline>

When using it for a hover effect on a link, put this component inside the link rather than outside. This is because the component defaults to coloring the underline with currentcolor, which is your link color when inside the link, but the default text color when outside.

<a href="example.html"><plucky-underline>Example</plucky-underline></a>

Styling

Basic styling is done with CSS custom properties:

For more advanced styling, it exposes two parts:

Options

You can control the wave itself with several options:

Known issues

This won’t work if the underline wraps across multiple lines, so probably shouldn’t be used for inline text.