IT技术博客大学习 共学习 共进步
全部 移动开发 后端 数据库 AI 算法 安全 DevOps 前端 设计 开发者

Prop For That

CSS-Tricks 2026-06-17 05:10:55 累计浏览 22 次
本机暂存

No secret that Adam’s all about props. Dude gave us Open Props a good while back for a slew of preconfigured variables for color, shadows, sizing, typography, among much much more. Now he’s back with Prop For That, a similar sorta idea, but mind-blowing in the sense that it creates live props based things CSS can’t normally see in the browser. Things like cursor position, progress values, certain form states, current time, scroll velocity — you know, the stuff that JavaScript sniffs and passes to CSS.

My understanding is that all the script-y stuff is already in the background. All that’s needed is to import the library, declare it in HTML, then style away in CSS.

Like, here’s Chris a long while back with custom properties registered in JavaScript to track cursor position:

CodePen Embed Fallback

Prop For That has that nicely covered. The difference is that we’re working with data attributes that trigger the scripts:

<div class="mover" data-props-for="pointer">...</div>

And plop the relevant props into the styles:

.mover {
  aspect-ratio: 1;
  width: 50px;
  background: red;
  position: absolute;
  left: calc(var(--live-pointer-x, 0) * 1px);
  top: calc(var(--live-pointer-y, 0) * 1px);
}
CodePen Embed Fallback

The demos are where it’s at. Good lord, can Adam put together some classy work.


Prop For That originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.

同分类推荐文章

  1. The Siren Song of ariaNotify() (2026-06-17 23:32:30)
  2. 把 hydration 从 React UI 里解耦:一次 SPA 启动期边界纠正 (2026-06-17 03:16:41)
  3. Why Isn’t My 3D View Transition Working? (2026-06-12 20:53:41)

查看更多 前端 文章 →

建议继续学习

  1. JQuery实现Excel表格呈现 (累计阅读 48,296)
  2. 50个活力和动感的网页设计-颜色的灵感 (累计阅读 34,395)
  3. 深入理解Javascript之执行上下文(Execution Context) (累计阅读 18,321)
  4. 从输入 URL 到页面加载完成的过程中都发生了什么事情? (累计阅读 15,856)
  5. 图片动态局部毛玻璃模糊效果的实现 (累计阅读 14,793)
  6. 天朝第二代身份证号码的验证机制 (累计阅读 14,714)
  7. HTML 5 的data-* 自定义属性 (累计阅读 14,286)
  8. 分享一个JQUERY颜色选择插件 (累计阅读 14,179)
  9. 什么是全栈工程师? (累计阅读 13,979)
  10. 视觉设计前瞻实用性研究(PNVD) 第二期 (累计阅读 12,934)