v151 · dom · shadow-dom
Declarative Shadow DOM: shadowrootslotassignment attribute
The <template shadowrootmode="open" shadowrootslotassignment="manual"> attribute lets declarative shadow roots use manual slot assignment — previously only available via attachShadow({slotAssignment: "manual"}). Components that need programmatic slot assignment can now be fully declarative.
concepts
-
Manual vs Named Slots
Side-by-side comparison: a component with named slots (default
namedassignment) and one withshadowrootslotassignment="manual". Drag children between slots and observe how manual assignment requiresassign()while named relies onslotattributes. -
Feature Detection Probe
Probe whether the browser parses the
shadowrootslotassignmentattribute on a declarative shadow root template, and read back the shadow root'sslotAssignmentmode live.
why it shipped
Manual slot assignment gives component authors precise control over which children render in which slot at runtime — essential for reorderable lists, tab panels, and data grids. Until now, components using slotAssignment: "manual" couldn't be declaratively parsed from HTML; they required JavaScript to attach the shadow root. This attribute closes that gap.