Prop For That is worth copying before it’s worth shipping

The take going around since Adam Argyle released Prop For That is that you import one module, put a data attribute on an element, and your stylesheet starts reacting to things CSS has never been able to see. I came to it through a short link post on CSS-Tricks, and the demos do look that simple. The story leaves out the part I get paid for: on a WordPress site the HTML is generated rather than hand-written, and a good chunk of what the library exposes is already visible to CSS.

Things like cursor position, progress values, certain form states, current time, scroll velocity.

None of that is wrong. But the rest of the job, deciding where this applies and wiring it so it survives, is what I want to talk about.

Why I’d copy the pattern before shipping the library

The pattern itself is old and good. Some JavaScript observes one thing and writes a custom property, and CSS consumes it with var() and calc(). It shows up in most themes I open, usually as a small anonymous script handling a sticky header, a mega menu, or a product gallery. Adam’s reason for building the library, in his announcement, is that he got tired of watching people write the same little script to set one property on one component. That rings true.

The part worth copying is the batching. The README describes values written to –live- and –const- custom properties, batched and diffed down to one setProperty per frame. Hand-rolled code rarely manages that, because the hand-rolled version is usually a pointermove handler per element, and every write triggers style work on whatever depends on that property. One coordinated write per frame keeps an effect cheap in a way twelve scattered handlers don’t.

What CSS already sees without any help

Before adding a script to feed CSS live values, I cross out the ones CSS covers on its own, because that list has grown a lot:

  • Scroll progress: scroll-driven animations handle progress bars and reveal effects, and I’ve been replacing scroll listeners with them on real builds.
  • Viewport and container size: container queries and query units, no script.
  • Form state: :user-invalid and :focus-within work in all major browsers.
  • Open state: details and dialog carry an open attribute you can select.

What’s left is a short list: pointer coordinates, scroll velocity (CSS gets progress, not velocity), colors sampled from an image or a video, battery, network, CPU pressure. On a store I usually want one of those, at most a pointer-reactive gallery. For the rest of the jobs I used to hand to small scripts, CSS handles them by itself now.

The WordPress wiring is where the work is

data-props-for is a markup attribute, and in WordPress markup has an owner. Put it on a Paragraph or a Group block in the editor, then adjust that block again through the visual controls, and the markup is regenerated from the block’s save function, which knows nothing about your attribute. So the attribute goes where you control the output: your own block’s save markup, a template part rendered from PHP, or a classic template file. For theme work I render it from PHP, because the editor can’t eat what it didn’t generate.

Loading it is the other half. The auto entry, prop-for-that/auto per the README, binds every data-props-for element, loads plugin sources on demand, and stays in sync with the DOM, so one module is all you point at. Modules load deferred by default, which suits effects that shouldn’t block anything. Core has had wp_enqueue_script_module since 6.5 for this, and it lets you load the module only on the templates that use it:

add_action( 'wp_enqueue_scripts', function () {
    if ( ! is_front_page() && ! is_product() ) {
        return;
    }

    // vendor the auto entry locally so it's not a CDN dependency
    wp_enqueue_script_module(
        'bbioon-prop-for-that',
        get_theme_file_uri( 'assets/vendor/prop-for-that/auto.js' ),
        array(),
        false
    );
} );

Two details from the CSS-Tricks example are worth keeping. The fallback inside var(), as in var(–live-pointer-x, 0), is your no-JS state, because these values exist only after the script runs. And the values are unitless, so the example multiplies by 1px in calc(); drop that convention and the math fails quietly.

Where Prop For That earns its keep

The pairing with style queries is what I find new. Adam says @container style() support in all major browsers is what made the library viable, and I agree: a component that adapts to a custom property on its ancestor beats toggling a class on body from a script. One inheritance detail in the README will cost you an hour if you miss it, though. Custom properties inherit downward, and style() matches against an ancestor, so an element can’t style-query values written on itself, and its siblings never see them. The escape hatch is data-props-to, which writes the properties onto a matching ancestor instead. Miss that and your first demo does nothing, which is how people conclude the library is broken.

The Chromium-only props, network, battery and CPU pressure, don’t exist in other browsers. Treat absence as a designed state rather than an error, or the effect will look broken to a lot of visitors.

To be fair, pulling it into an art-directed landing page is defensible. It’s zero dependencies and SSR-safe per the README, so the risk of adding it is small, and on pages built for spectacle the demos are the point. My line is stores and long-lived themes, where I want as few moving parts as I can get. I also haven’t run it on a heavy WooCommerce archive yet, and a large DOM full of observed elements is the first thing I’d test.

If you want one of these live-prop effects on a shop, a gallery that follows the pointer or a progress treatment CSS can’t cover on its own, that’s the kind of small front-end build I take on alongside the theme work. Tell me the page and I’ll tell you whether it needs this library or ten lines of your own JavaScript.

Search your theme and plugins for scripts that already write custom properties, because every hit is a candidate for this treatment.

grep -rn "setProperty" wp-content/themes wp-content/plugins --include="*.js"

For each match, one of three things applies: the library replaces it, ten clean lines replace it, or CSS already covers that value and the script goes away.

author avatar
Ahmad Wael
I'm a WordPress and WooCommerce developer with 15+ years of experience building custom e-commerce solutions and plugins. I specialize in PHP development, following WordPress coding standards to deliver clean, maintainable code. Currently, I'm exploring AI and e-commerce by building multi-agent systems and SaaS products that integrate technologies like Google Gemini API with WordPress platforms, approaching every project with a commitment to performance, security, and exceptional user experience.

Leave a Comment