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
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

CSS Houdini – The Paint API | CSS Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Course

Lesson 44 of 50

·css

CSS Houdini – The Paint API

10 mins

Course progress88%

What you'll learn

Keep this idea in mind as you work through the lesson.

1 point
  • Houdini is still experimental; works in Chrome‑based browsers. * Allows **custom drawing**, **layout**, and **animation** that were impossible before. * Pair with `@property` to animate custom properties.

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; }
Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS CourseBrowse activities
Previous lessonCSS‑in‑JS (Styled‑Components, Emotion)Continue to lesson 45Logical CSS for InternationalizationBack to CSS Course curriculum