Mixins / Inside-out composition
Why Slots beat className props
A plain className prop only injects CSS strings without saying what element it targets, which events exist, or which attributes are structural. A Slot contract specifies:
- Capability: Whether the slot is a
Container,Interactivecontrol,Focusableitem, orTextInput. - Published events and attributes: Which events (such as
Event.Input) and ARIA attributes (such asAttr.AriaInvalid) attachments may rely on or supply. - Protected members: Structural roles or attributes (like
role) that external attachments cannot overwrite.
When a Behavior declares requires: { capability: Capability.TextInput, attributes: [Attr.AriaInvalid] }, attaching it to an incompatible slot fails at definition time rather than silently breaking at runtime. Contracts also export serializable metadata for DevTools, tests, and documentation.