Skip to content

Slot

Slot renders no element of its own: it merges the props passed via Attributes (plus any attributes captured directly on it) and hands the resulting dictionary to ChildContent, which the consumer must splat onto exactly one root element with @attributes. A true 1:1 port of the spec’s Slot is not possible in Blazor (RenderFragment does not expose its child element’s props), so this is the idiomatic approximation used internally by primitives that need to project behavior onto an arbitrary element the consumer controls.

@using Navius.Primitives.Components.Slot
<NaviusSlot Attributes="@props">
@(attrs =>
@<button @attributes="attrs">Click me</button>)
</NaviusSlot>
Prop Type Default Description
Attributes IReadOnlyDictionary<string, object>? - The props to forward onto the single child element.
UnmatchedAttributes IDictionary<string, object>? - Additional attributes captured directly on NaviusSlot (e.g. when a parent primitive splats onto it). Wins over Attributes on key collision.
ChildContent RenderFragment<IReadOnlyDictionary<string, object>>? - The single child. Receives the merged attribute dictionary; the consumer must splat it onto exactly one root element.

Slot has no element of its own to mark, so it renders no data attributes. The merge it performs onto the forwarded dictionary:

Part Attribute Description
Root class / className Normalized to one class attribute and concatenated (space separated).
Root style Merged per CSS property; the child’s value wins per property, no duplicate declarations.
Root on* handlers Composed: the child handler runs first, then the forwarded handler. Never dropped.
Root everything else Last-wins: attributes splatted onto NaviusSlot override the forwarded Attributes.

Slot is a composition utility with no semantics or keyboard behavior of its own: it adds nothing and removes nothing. Accessibility is governed entirely by the element the consumer splats onto and the props they forward — ARIA roles, tabindex, and event handlers on that element are merged, not clobbered. Covered by the Playwright browser test suite.