liveBook · Manning

Component

As explained in Web Components in Action

A component is a reusable, standalone unit of interface code that combines structure, styling, behavior, and optionally a customization API.

A component is a reusable, standalone unit of interface code that combines structure, styling, behavior, and optionally a customization API. Its purpose is to adapt across contexts instead of forcing users to modify internal implementation. section 3.0 section 6.7

Build a component around a small public surface:

  • Expose configuration through properties, getters, setters, or reflected attributes rather than hard-coded values. section 3.2 section 11.5
  • Separate the component’s template, styles, and behavior so each part can be reused or customized. section 6.7
  • Choose styling boundaries deliberately, using Shadow DOM, CSS variables, or importable CSS modules according to the surrounding system. section 11.0 section 15.1

A configurable slider

A slider becomes shareable when its template and behavior move into separate modules, while size and background remain configurable from the page. The host can use <wcia-slider backgroundcolor="#ff0000" value="50"></wcia-slider> without editing the component’s internal files.

How Web Components in Action covers it

How deep it goes
Explains APIs, modules, reflection, styling boundaries, and event behavior through implementations, while deferring some internals as unchanged code.
Examples
Demonstrates configurable search and a modular slider with external attributes, templates, styling, event handlers, and mapped DOM elements.
What it assumes
Assumes basic HTML, CSS, JavaScript, DOM, and custom-element familiarity while teaching configuration and reuse incrementally.
What you can do after
Build it from scratch as a shareable custom element with a planned API, separated modules, configurable attributes, and reusable styling.
How it connects
Connects components with Web Components, Custom Elements, Shadow DOM, modules, reflection, CSS variables, and design systems.

Also explained in

Compare how 10 books explain component →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Components in Action. The section links point to the parts of the book it draws on.