Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 44 of 50 · css

CSS Houdini – The Paint API

Duration: 10 mins

Houdini opens the browser for developer‑defined rendering.

  • Paint API lets you draw with JavaScript directly onto an element’s background.
if ('paintWorklet' in CSS) {
  CSS.paintWorklet.addModule('bg-paint.js');
}

bg-paint.js

registerPaint('bg', class {
  static get inputProperties(){ return ['--color']; }
  paint(ctx, size, props){
    ctx.fillStyle = props.get('--color').toString();
    ctx.fillRect(0,0,size.width,size.height);
  }
});

Example usage

.box { background-image:paint(bg); --color:#ff6600; }
Previous: CSS‑in‑JS (Styled‑Components, Emotion)Next: Logical CSS for Internationalization