sveltelean
Version v0.18.0

The decision

  • The platform comes first; a primitive is JavaScript only when the platform cannot provide the interaction (ADR 0001).
  • 27 of the 50 primitives are native and ship no runtime: the package adds styles, contract types, documentation and development validation.
  • The production fixture with button, dialog and popover markup emits a Svelte Lean chunk of 0 B.
How a primitive is assigned its runtime tierCan the browser do it? Yes: native, Tier 0, no Svelte Lean JavaScript. No: is one shared listener per event type enough? Yes: shared behavior, Tier 1. No: lazy scoped controller, Tier 2, with state created on first interaction.Can the browser do it?yesnoNative · Tier 0no Svelte Lean JavaScriptIs one shared listener perevent type enough?yesnoShared behavior · Tier 1one listener per event typeTier 2lazy scopedcontroller How a primitive is assigned its runtime tierCan the browser do it? Yes: native, Tier 0, no Svelte Lean JavaScript. No: is one shared listener per event type enough? Yes: shared behavior, Tier 1. No: lazy scoped controller, Tier 2, with state created on first interaction.Can the browser do it?yesnoNative · Tier 0no Svelte Lean JavaScriptIs one shared listener perevent type enough?yesnoShared behavior · Tier 1one listener per event typeLazy scoped controller · Tier 2state created on first interaction
Native before JavaScript. Every primitive declares its tier in its contract; the budgets are on Runtime tiers.

Platform features relied on

FeaturePrimitiveWhat the browser provides
<dialog> with command="show-modal" and command="close"DialogTop layer, page inertness, Escape, focus return to the invoker, the backdrop
popover with popovertargetPopover, MenuTop layer, light dismiss, one auto popover open at a time, aria-expanded, implicit anchor
Invoker commands (command, commandfor)Dialog and Popover invokersOpen and close without a click handler
<details> with nameDisclosureThe open state, Enter and Space on the summary, exclusive groups
Native form controlsButton, Checkbox, Switch, Radio groupFocus, activation, checked state, arrow keys in a radio group, form participation
CSS anchor positioning (position-area)Popover and Menu placementPlacement against the invoker, with fallbacks
CSS state selectors (:open, :popover-open, :checked, :disabled, :focus-visible)Every stylesheetState for styling without a mirrored attribute

Baseline status and fallbacks: Browser support.

Ownership

For a modal dialog:

Svelte Lean ownsThe browser owns
The stylesheet (dialog.css)Open and close, through showModal() and the invoker commands
The contract: semantics, parts, keyboard, focus, SSR and JS-disabled behaviorThe modal top layer, the backdrop and page inertness
Development validation of the markupDialog semantics, Escape, focus return, Tab staying inside
Types (@svelte-lean/primitives/dialog)Form participation through method="dialog"

Not in the package: focus trap, portal, z-index manager, scroll lock, positioning engine, open mirror (Dialog).

Examples

Dialog · Tier 0

Settings

Changes apply to this device.

The rest of the page is inert while this dialog is open.

Code
<script lang="ts">
	// Nothing to import: the browser owns the dialog.
	// The styles are optional.
	import '@svelte-lean/styles/dialog.css';
</script>

<button type="button" data-slean="button" commandfor="settings"
	command="show-modal">Settings</button>

<dialog id="settings" data-slean="dialog" closedby="any"
	aria-labelledby="settings-title">
	<header>
		<h2 id="settings-title">Settings</h2>
		<p>Changes apply to this device.</p>
	</header>
	…
	<footer>
		<button type="button" data-slean="button" commandfor="settings"
			command="close">Close</button>
	</footer>
</dialog>
Press Escape: focus returns to the button. The interaction is the browser's.
Popover · Tier 0

Signed in as Amara Okafor.

Code
<script lang="ts">
	// Nothing to import: the Popover API owns the top layer and light dismiss.
	import '@svelte-lean/styles/popover.css';
</script>

<button type="button" popovertarget="account">Account</button>

<div id="account" popover data-slean="popover" data-slean-side="bottom" data-slean-align="start">
	<p>Signed in as Amara Okafor.</p>
</div>
Light dismiss, Escape and the top layer come from the Popover API; placement is CSS anchor positioning where supported.

Consequences

  • Each contract names the Baseline features it depends on and the fallback.
  • Native primitives work before hydration and without client JavaScript (tested).
  • Every primitive page opens with plain markup, never a wrapper component.
  • Native semantics sometimes limit customization; see Trade-offs.

Revisit when

No Baseline feature meets a required behavior; the primitive then moves up a tier, with the reason in its contract.

Source