DEV Community

Cover image for <pride-flag> Web Component
Danny Engelman
Danny Engelman

Posted on • Updated on

<pride-flag> Web Component

Ain't the world a great place; 33 years active on the Internet and this post got me my very first hate mail. To the sender: I love you too!

In his blog-post Pride Flags Josh Comeau does an excellent job creating an animated pride flag.

  • He creates good HTML
  • He adds cool CSS gradients
  • He writes native JavaScript
  • And then, to put the Pride Flag in the DOM, he spoils it all with the line:

He was just three lines from creating a native JavaScript Web Component <pride-flag> that would run in every Framework, in every modern browser, without! ANY dependencies

customElements.define("pride-flag", class extends HTMLElement {
    this.innerHTML = PrideFlag();
Enter fullscreen mode Exit fullscreen mode

All credits to Josh, I refactored his code a bit, so delivers a native JavaScript Web Component <pride-flag>


Extending <pride-flag> itself with:

  class extends customElements.get('pride-flag') {
    connectedCallback() {
        super.connectedCallback([[331, 100, 55], [50, 100, 50], [200, 100, 55]]);
  class extends customElements.get('pride-flag') {
    connectedCallback() {
        super.connectedCallback([[200, 85, 70], [350, 85, 85], [0, 0, 100], [350, 85, 85], [200, 85, 70]]);
Enter fullscreen mode Exit fullscreen mode

adds 2 more Web Components.

All required HTML:

<script src=""></script>

  flags {display:grid; grid: 1fr/1fr 1fr 1fr; gap:1em}

  <pride-flag columns="10">
  <pride-pan-flag columns="100" delay="20" billow="1">
  <pride-trans-flag columns="200" delay="20" speed="1700" billow="2">
Enter fullscreen mode Exit fullscreen mode


Flag Configurator at:

Top comments (3)

dannyengelman profile image
Danny Engelman • Edited

[James now deleted his comment, but there was a screenshot made]

Hi James, which is most likely not your real name, you signed on today.

I am leaving your comment for all to read. A reminder there are people who care for each other no matter religion, race or color of hair. And there are people like you, who think they are superior and only dare to voice that opinion anonymously.

durbonca profile image
Manuel Duran

Wonderful contribution 🏳️‍🌈🏳️‍⚧️