@affino/tabs-core
v0.1.0
Published
Headless tabs controller for Affino primitives
Downloads
114
Maintainers
Readme
@affino/tabs-core
Headless tabs primitive for single-value selection.
Installation
pnpm add @affino/tabs-coreQuick start
import { TabsCore } from "@affino/tabs-core"
const tabs = new TabsCore<string>("overview")
tabs.select("settings")
tabs.clear()
const snapshot = tabs.getSnapshot()API
new TabsCore(defaultValue?)select(value)clear()getSnapshot()subscribe(listener)destroy()
Behavioral guarantees
- Selecting the same value is a no-op.
- Clearing when already empty is a no-op.
- Subscribers are notified only on meaningful state changes.
getSnapshot()returns a frozen immutable object (runtime-enforced, not type-only).
Adapter guidance
- Keep one canonical tabs state source in adapter state.
- Treat snapshots as immutable values.
- Wire framework events (
click, keyboard shortcuts) toselect/clearonly.
