Skip to content
Journey to Code

Series

JOURNEY TO WEB COMPONENTS / TRACK 02

Build Your First Web Components

Start with an unknown tag. Finish with a component whose content, styles, and events have clear boundaries.

BEFORE WE DEFINE THE TAG

Do you need the foundations first?

If HTML structure, CSS selectors, and JavaScript event listeners are already familiar, start here. If any of those still feel slippery, the foundations track builds them in seven smaller steps.

Review the Web Foundations track →

START AT THE PROBLEM YOU HAVE

I want to ... then read

Build the component

  1. 01 / Define the element

    Introduction to Web ComponentsBuild a custom tag like info-card that carries its own look and behavior, and see how Shadow DOM keeps its styles from leaking. · 8 min read
  2. Getting Started with Custom ElementsDefine a custom element, change an attribute and watch its text update, and see how it learns when it is added or removed. · 6 min read
  3. Lifecycle Callbacks & Component CommunicationReact when a custom element is added, removed or changed with lifecycle callbacks, then pass messages between components. · 7 min read
  4. 02 / Build the boundary

    Exploring the Shadow DOMAttach a private shadow tree to an element, choose open or closed mode, and learn which page styles can reach inside. · 6 min read
  5. How Templates and Slots WorkUse template for a fixed layout and slot for the blanks a page fills in, then combine them in a web component. · 5 min read
  6. 03 / Expose the contract

    Mastering the Art of Web Component StylingStyle a web component from outside through four doors in its wall: :host, ::slotted, CSS custom properties and ::part. · 10 min read