← Graph

Prefer extending ViewComponent classes/attrs over multiplying variants

takeaway 2 connections

A ViewComponent should define a fixed set of variants (sizes, colors) but let callers append additional CSS classes and data attributes to the component's defaults, rather than growing a new variant or forking a component every time a caller needs a tweak. Keeps components flexible without combinatorial explosion. Same principle applies to Stimulus data attributes.

type
recommendation
takeaway Prefer extending ViewComponent classes/attrs over multiplying variants
about
Design guideline for ViewComponent APIs.
takeaway Prefer extending ViewComponent classes/attrs over multiplying variants
from_talk
Key learning from building the badge component.

Provenance