Reusable UI with Web Components

Arjay Elbore

Frontend Developer

Aivan Monceller

Frontend Developer

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" 
    type="button" id="dropdownMenuButton" 
  <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
<b-dropdown label="Dropdown">
 <b-dropdown-item>Another Action</b-dropdown-item>
 <b-dropdown-item>Something Else here</b-dropdown-item>

Web Components

set of web platform APIs that allow you to create new custom, reusable, encapsulated HTML tags to use in web pages and web apps. Custom components and widgets build on the Web Component standards, will work across modern browsers, and can be used with any JavaScript library or framework that works with HTML.

Custom Elements

Shadow DOM

HTML Template

ES Modules

Shadow DOM

Advantages of Web Components

  • Developer Experience
    • You want to speed up development
    • Less code
    • Easy to maintain
    • Can use to any javascript framework or libraries
  • Consistency¬†
    • Reuse components across teams, other projects/environments/frameworks
    • Encouraging all of your engineers to reuse components will make the site more enjoyable for its users

Browser Support



  • LitElement - A simple base class for creating fast, lightweight web components
  • CSS Custom Properties - variables in CSS
  • Parcel - Blazing fast, zero configuration web application bundler


Reusable UI with Web Components

By aelbore

Reusable UI with Web Components

  • 318

More from aelbore