Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: added tabs
dev_wandryd5a668f99cff
diff --git a/components/docs/examples/index.tsx b/components/docs/examples/index.tsxindex 32bbb841..705d910c 100644--- a/components/docs/examples/index.tsx+++ b/components/docs/examples/index.tsx@@ -24,6 +24,7 @@ import {DropdownMenuExampleScene,dropdownMenuExampleCode,} from "./dropdown-menu-example";+import { TabsExampleScene, tabsExampleCode } from "./tabs-example";export interface ExampleEntry {Component: ComponentType;@@ -138,4 +139,13 @@ export const examples: Record<string, ExampleEntry> = {width: W,height: H,},+ "tabs-example": {+ Component: TabsExampleScene,+ code: tabsExampleCode,+ // Settings transition completes at 94 + dur 12 = 106; a short settle then loop.+ durationInFrames: 120,+ fps: FPS,+ width: W,+ height: H,+ },};diff --git a/components/docs/examples/tabs-example.tsx b/components/docs/examples/tabs-example.tsxnew file mode 100644index 00000000..b2d1ae72--- /dev/null+++ b/components/docs/examples/tabs-example.tsx@@ -0,0 +1,26 @@+"use client";++import { Tabs } from "@/registry/remocn-ui/tabs";+import { useTabsTransition } from "@/registry/remocn-ui/tabs/use-tabs-transition";++export const TabsExampleScene = () => {+ const style = useTabsTransition([+ { at: 18, state: "Account", duration: 16 },+ { at: 58, state: "Password", duration: 18 },+ { at: 94, state: "Settings", duration: 12 },+ ]);+ return <Tabs style={style} />;+};++export const tabsExampleCode = `import { Tabs } from "@/components/remocn/tabs";+import { useTabsTransition } from "@/components/remocn/use-tabs-transition";++export const Scene = () => {+ const style = useTabsTransition([+ { at: 18, state: "Account", duration: 16 },+ { at: 58, state: "Password", duration: 18 },+ { at: 94, state: "Settings", duration: 12 },+ ]);++ return <Tabs style={style} />;+};`;diff --git a/content/docs/ui/components/meta.json b/content/docs/ui/components/meta.jsonindex 5d101c9c..61ee6e08 100644--- a/content/docs/ui/components/meta.json+++ b/content/docs/ui/components/meta.json@@ -1,5 +1,5 @@{"title": "Components","collapsible": false,- "pages": ["accordion", "alert-dialog", "button", "checkbox", "dialog", "drawer", "sheet", "dropdown-menu", "input", "radio", "select", "spinner", "switch"]+ "pages": ["accordion", "alert-dialog", "button", "checkbox", "dialog", "drawer", "sheet", "dropdown-menu", "input", "radio", "select", "spinner", "switch", "tabs"]}diff --git a/content/docs/ui/components/tabs.mdx b/content/docs/ui/components/tabs.mdxnew file mode 100644index 00000000..df0e10ba--- /dev/null+++ b/content/docs/ui/components/tabs.mdx@@ -0,0 +1,144 @@+---+title: Tabs+description: A tabs widget whose active-tab state is a pure function of the timeline+---++<ComponentPreview name="tabs" />++A state atom whose appearance (which tab is active) is a pure function of the `state` prop. Pass a state directly or drive it from the Remotion timeline via `useCurrentState`. The component reads no frame — only the state value you give it.++## Installation++<InstallBlock name="tabs" />++<Note>+Installing `tabs` automatically installs the shared `remocn-ui` core (`lib/remocn-ui/`) via `registryDependencies`. You do not need to install it separately.+</Note>++## States++`TabsState` is:++```ts+type TabsState = string;+```++The `state` is the active tab's value — one of the strings in the `items` array. When the state changes, the active label brightens, the indicator (pill or underline) slides to that tab, and the matching panel crossfades in.++## Snap usage++Pass `state` directly — the component snaps instantly to that visual. Useful for static previews or when you drive state from your own logic:++```tsx+import { Tabs } from "@/components/remocn/tabs";++export const Scene = () => <Tabs state="Password" />;+```++To drive state from the timeline, use `useCurrentState`:++```tsx+import { useCurrentState } from "@/lib/remocn-ui";+import { Tabs } from "@/components/remocn/tabs";++export const Scene = () => {+ const state = useCurrentState(+ [+ { at: 18, state: "Account" },+ { at: 58, state: "Password" },+ { at: 94, state: "Settings" },+ ],+ "Account",+ );++ return <Tabs state={state} />;+};+```++Each `at` is a **Sequence-local authored frame**. State persists between steps: `Account` at frame 18 keeps that tab active until `Password` fires at frame 58. See [Concepts](/docs/ui/concepts) for the full `useCurrentState` API.++## Smooth transitions++State changes via `state` snap with no cross-fade. For animated transitions, use `useTabsTransition` from the copied `use-tabs-transition.ts` file. It reads the frame, interpolates between state presets, and returns a resolved `TabsStyle` — pass it to the `style` prop:++```tsx+import { Tabs } from "@/components/remocn/tabs";+import { useTabsTransition } from "@/components/remocn/use-tabs-transition";++export const Scene = () => {+ const style = useTabsTransition([+ { at: 18, state: "Account", duration: 16 },+ { at: 58, state: "Password", duration: 18 },+ { at: 94, state: "Settings", duration: 12 },+ ]);+ return <Tabs style={style} />;+};+```++The `duration` field on each step overrides the file's `DEFAULT_DURATION` for that specific transition. To globally tune timing and easing, edit `use-tabs-transition.ts` directly in your project — that file is yours (shadcn "own your code" philosophy).++`style` takes precedence over `state` when both are provided.++## Full lifecycle++A complete Account → Password → Settings run using the smooth transition path. Copy the code to drop it into your own composition.++<LiveExample name="tabs-example" />++## Props++<PropsTable+ rows={[+ {+ name: "state",+ type: "string",+ default: "\"Account\"",+ description: "Current visual state (snap path). One of the values in items. State changes snap — no automatic cross-fade.",+ },+ {+ name: "style",+ type: "TabsStyle",+ description: "Resolved animated visual (smooth path). Pass an interpolated TabsStyle from useTabsTransition. Takes precedence over state when provided.",+ },+ {+ name: "items",+ type: "string[]",+ default: "[\"Account\", \"Password\", \"Settings\"]",+ description: "Tab labels (and values). The active state is one of these strings.",+ },+ {+ name: "contents",+ type: "string[]",+ default: "Parallel strings for each tab",+ description: "Panel body text per tab — parallel to items. Displayed with opacity crossfade.",+ },+ {+ name: "contentHeight",+ type: "number",+ default: "72",+ description: "Authored panel height in px. Required because Remotion cannot measure auto height — set this to match the rendered height of your content.",+ },+ {+ name: "variant",+ type: "\"pill\" | \"underline\"",+ default: "\"pill\"",+ description: "Visual variant. pill wraps the indicator in a muted track; underline runs a bar along the bottom.",+ },+ {+ name: "theme",+ type: "Partial<RemocnTheme>",+ description: "Per-component theme override. Merges with the active RemocnUIProvider theme and the mode defaults. Must be concrete oklch/hex/rgb values — not CSS custom properties.",+ },+ {+ name: "mode",+ type: "\"light\" | \"dark\"",+ default: "\"light\"",+ description: "Sets the base palette. Overrides the mode on RemocnUIProvider when both are present.",+ },+ {+ name: "className",+ type: "string",+ description: "Optional className passed to the tabs element.",+ },+ ]}+/>diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex 7cdea199..25affea3 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -135,6 +135,8 @@ import { DropdownMenu } from "@/registry/remocn-ui/dropdown-menu";import { dropdownMenuConfig } from "@/registry/remocn-ui/dropdown-menu/config";import { DropdownMenuItem } from "@/registry/remocn-ui/dropdown-menu-item";import { dropdownMenuItemConfig } from "@/registry/remocn-ui/dropdown-menu-item/config";+import { Tabs } from "@/registry/remocn-ui/tabs";+import { tabsConfig } from "@/registry/remocn-ui/tabs/config";import { ZoomThroughTransition } from "@/registry/remocn/zoom-through-transition";import { zoomThroughTransitionConfig } from "@/registry/remocn/zoom-through-transition/config";@@ -325,6 +327,7 @@ const registry: Record<string, RegistryEntry> = {Component: DropdownMenuItem,config: dropdownMenuItemConfig,},+ "tabs": { Component: Tabs, config: tabsConfig },"spinner": { Component: Spinner, config: spinnerConfig },};diff --git a/registry/remocn-ui/registry.json b/registry/remocn-ui/registry.jsonindex 92f09fbf..5a9ce006 100644--- a/registry/remocn-ui/registry.json+++ b/registry/remocn-ui/registry.json@@ -317,6 +317,26 @@}]},+ {+ "name": "tabs",+ "type": "registry:component",+ "title": "UI Tabs",+ "description": "A tabs widget whose active-tab state is a pure function of the timeline; the sliding indicator, label colors, and panel crossfade are keyframed/derived presets.",+ "dependencies": ["remotion"],+ "registryDependencies": ["remocn-ui"],+ "files": [+ {+ "path": "tabs/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/tabs.tsx"+ },+ {+ "path": "tabs/use-tabs-transition.ts",+ "type": "registry:component",+ "target": "components/remocn/use-tabs-transition.ts"+ }+ ]+ },{"name": "dropdown-menu","type": "registry:component",diff --git a/registry/remocn-ui/tabs/__tests__/README.md b/registry/remocn-ui/tabs/__tests__/README.mdnew file mode 100644index 00000000..ab98bd22--- /dev/null+++ b/registry/remocn-ui/tabs/__tests__/README.md@@ -0,0 +1,120 @@+# `tabs` — verification tests++Pure / deterministic verification for the `tabs` component+(`registry/remocn-ui/tabs/`). The RENDER path needs `useRemocnTheme()`+and the Remotion render tree and cannot run headless, so the render is NOT+exercised here. This suite covers the pieces that ARE pure: `TabsState`+type / state options, `tabsConfig.controls` wiring, `tabsConfig.snippet`+codegen, `tabsStyle` presets, `tweenTabsStyle` interpolation, and+`DEFAULT_DURATION`.++## Animation model — pure snap + opt-in smooth path++Tabs ships two complementary paths:++**Snap path** (`state?: TabsState` prop):+`Tabs` is a frame-free pure renderer. The `state` prop drives all visuals.+Each state maps to a complete resting visual via the exported pure function+`tabsStyle(state, ctx) => TabsStyle`. State changes snap instantly — no+tweening inside the component.++**Smooth path** (`style?: TabsStyle` prop):+Callers opt in to smooth transitions by passing a pre-interpolated+`TabsStyle` to the `style` prop. The caller — typically+`useTabsTransition` — reads `useCurrentFrame()` and calls+`useStateTransition` from `core/timeline.ts` to compute+`{ from, to, progress }`, then blends the two presets via+`tweenTabsStyle(from, to, t)`. The `Tabs` component itself remains+frame-free; it simply renders whatever `TabsStyle` it receives.++This design keeps `Tabs` pure-testable (no Remotion render context needed)+while still supporting smooth sliding-indicator transitions for production+use.++## How to run++The repo uses **Bun**, which has a built-in test runner — runs TypeScript+natively, no test-framework dep.++```bash+bun install+bun test registry/remocn-ui/tabs/__tests__+```++`tabs.test.ts` imports `bun:test` (not `vitest`/`jest`), so no test script+or framework dep is added to `package.json`.++## What is covered++- **`TabsState` / state options** — asserts `controls.state` is a `select`+ with options exactly `["Account", "Password", "Settings"]` in order,+ default `"Account"` (so the preview opens on the first tab), and that+ every option is present in the fixture array (no typos).+- **`tabsConfig.controls.variant`** — asserts a `select` control with+ options `["pill", "underline"]`, default `"pill"`.+- **`tabsConfig.snippet`** — REAL pure string builder (high value). Asserts:+ always emits `state="<state>"` for every option; NEVER emits `steps`;+ includes `import { Tabs }` from `@/components/remocn/tabs`; omits+ default-equal props (`variant="pill"`, `mode="light"`); EMITS non-default+ `variant="underline"` and `mode="dark"`; structural round-trip (starts+ with the import line, contains `<Tabs`, ends `/>`).+- **`tabsStyle` presets** — exported pure `(state, ctx) => TabsStyle` map.+ A `TabsStyleContext` is built from+ `tabsStyleContext(["Account","Password","Settings"], "pill", defaultLightTheme)`+ — the same call the component makes internally. Asserts per-state+ `indicatorOffset` (`"Account"→0`, `"Password"→1`, `"Settings"→2`).+ Asserts unknown state (e.g. `"Nope"`) → `0` (the documented safe+ fallback). A loop asserts each item maps to its own index. Also verifies+ the invariant holds for the `"underline"` variant via a second context.+- **`tweenTabsStyle`** — exported pure `(a, b, t) => TabsStyle`. Asserts:+ at t=0 `indicatorOffset` equals `a.indicatorOffset`; at t=1 equals+ `b.indicatorOffset`; at t=0.5 between offset 0 and 2 gives 1 (exact+ midpoint). Both directions (Account→Settings and Settings→Account) are+ verified. Uses `toBeCloseTo`.+- **`DEFAULT_DURATION`** — sanity-checks the exported constant is a+ positive number equal to 14.++**Tabs render** is a pure `(style | state) => visual` observable only via+Remotion render, not unit-tested here.++## Import strategy++`tabs.test.ts` imports via a mix of **relative paths** and the+**`@/lib/remocn-ui` tsconfig alias**:++- `../index` — relative, for `TabsState`, `tabsStyle`, `tabsStyleContext`+- `../use-tabs-transition` — relative, for `tweenTabsStyle`,+ `DEFAULT_DURATION`+- `../config` — relative, for `tabsConfig`+- `@/lib/remocn-ui` — alias (resolves to `registry/remocn-ui/core/index.ts`),+ for `defaultLightTheme`++Importing `index.tsx` and `use-tabs-transition.ts` pulls the `remotion`+module (and React), but neither `tabsStyle`, `tabsStyleContext`, nor+`tweenTabsStyle` call `useCurrentFrame()` at import time or at call time —+they are pure value functions. `bun test` resolves tsconfig `paths`, so the+alias works without additional config.++## Determinism grep checklist (run manually; must print NOTHING)++Tabs is a state atom and must be frame-free. The component's `index.tsx`+must contain **none** of the following:++```bash+grep -nE "useCurrentFrame|useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \+ registry/remocn-ui/tabs/index.tsx+```++Expected: no output. Any match is a determinism violation.++`use-tabs-transition.ts` is the CALLER hook that intentionally reads+`useCurrentFrame()` (via `useStateTransition`). It is not a render+component; the smooth-path design isolates all frame-reading to the hook,+keeping `Tabs` pure.++Tier-wide sweep:++```bash+grep -nE "useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \+ registry/remocn-ui/tabs/index.tsx registry/remocn-ui/core/*.ts+```diff --git a/registry/remocn-ui/tabs/__tests__/tabs.test.ts b/registry/remocn-ui/tabs/__tests__/tabs.test.tsnew file mode 100644index 00000000..d36549f1--- /dev/null+++ b/registry/remocn-ui/tabs/__tests__/tabs.test.ts@@ -0,0 +1,340 @@+/**+ * Verification tests for the PURE / DETERMINISTIC parts of `tabs`.+ *+ * Scope:+ * - registry/remocn-ui/tabs/index.tsx — TabsState type, tabsStyle presets,+ * tabsStyleContext+ * - registry/remocn-ui/tabs/config.ts — tabsConfig.controls wiring+ * + tabsConfig.snippet output (the state → JSX codegen)+ * - registry/remocn-ui/tabs/use-tabs-transition.ts+ * — tweenTabsStyle interpolation, DEFAULT_DURATION+ *+ * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.+ * `<Tabs>` reads `useRemocnTheme()` internally — that hook is pure at+ * call-time in test context, but the JSX render tree is not exercised here.+ * The pure-testable surface is: the style presets + tween + customizer wiring+ * + snippet codegen.+ *+ * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).+ * bun test registry/remocn-ui/tabs/__tests__+ *+ * --------------------------------------------------------------------------+ * IMPORT STRATEGY+ * --------------------------------------------------------------------------+ * `config.ts` imports `TabsState` from `@/registry/remocn-ui/tabs` and the+ * pieces under test never CALL a Remotion runtime API at import time —+ * `tabsConfig` is a plain object; `.snippet` is a pure string builder;+ * `tabsStyle` and `tweenTabsStyle` are pure value functions.+ * We import via RELATIVE paths (matching the existing test suite pattern),+ * annotating each import with the source it corresponds to.+ * --------------------------------------------------------------------------+ */++import { describe, expect, it } from "bun:test";+import {+ type TabsState,+ tabsStyle,+ tabsStyleContext,+} from "../index";+import { tweenTabsStyle, DEFAULT_DURATION } from "../use-tabs-transition";+import { tabsConfig } from "../config";+import { defaultLightTheme } from "@/lib/remocn-ui";++// ===========================================================================+// Shared fixtures+// ===========================================================================++/**+ * The canonical tab label list — mirrors DEFAULT_ITEMS in index.tsx and the+ * config.controls.state.options list. Must stay in sync.+ */+const VALID_STATES: readonly TabsState[] = ["Account", "Password", "Settings"];++/** Minimal shape mirroring the customizer's value bag passed to snippet(). */+type SnippetValues = {+ state?: string;+ variant?: string;+ mode?: string;+};++const snippet = (values: SnippetValues): string =>+ tabsConfig.snippet(values as Record<string, unknown>);++/**+ * A shared TabsStyleContext built from the default items + "pill" variant ++ * default light theme. Mirrors how the component builds its own context+ * internally.+ */+const ctx = tabsStyleContext(["Account", "Password", "Settings"], "pill", defaultLightTheme);++// ===========================================================================+// 1. TabsState / state options+// ===========================================================================++describe("TabsState / state options", () => {+ it("controls.state is a select control", () => {+ expect(tabsConfig.controls.state.type).toBe("select");+ });++ it("contains exactly the three documented states", () => {+ const control = tabsConfig.controls.state;+ if (control.type !== "select") throw new Error("state control must be a select");+ expect(control.options).toEqual(["Account", "Password", "Settings"]);+ });++ it("defaults to 'Account' so the preview opens on the first tab", () => {+ expect(tabsConfig.controls.state.default).toBe("Account");+ });++ it("every VALID_STATES entry is present in the options list (no typos in fixture)", () => {+ const control = tabsConfig.controls.state;+ if (control.type !== "select") throw new Error("state control must be a select");+ expect(VALID_STATES).toHaveLength(3);+ for (const s of VALID_STATES) {+ expect(control.options).toContain(s);+ }+ });+});++// ===========================================================================+// 2. tabsConfig.controls.variant — customizer control wiring+// ===========================================================================++describe("tabsConfig.controls.variant", () => {+ it("is a select control", () => {+ expect(tabsConfig.controls.variant.type).toBe("select");+ });++ it("has exactly the two variant options in order", () => {+ const control = tabsConfig.controls.variant;+ if (control.type !== "select") throw new Error("variant control must be a select");+ expect(control.options).toEqual(["pill", "underline"]);+ });++ it("defaults to 'pill'", () => {+ expect(tabsConfig.controls.variant.default).toBe("pill");+ });+});++// ===========================================================================+// 3. tabsConfig.snippet — pure string builder+// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.+// It NEVER emits `steps`.+// ===========================================================================++describe("tabsConfig.snippet: state prop emission", () => {+ it("emits state=\"Account\" for the Account option", () => {+ expect(snippet({ state: "Account" })).toContain('state="Account"');+ });++ it("emits state=\"Password\" for the Password option", () => {+ expect(snippet({ state: "Password" })).toContain('state="Password"');+ });++ it("emits state=\"Settings\" for the Settings option", () => {+ expect(snippet({ state: "Settings" })).toContain('state="Settings"');+ });++ it("emits the correct state for every control option", () => {+ const control = tabsConfig.controls.state;+ if (control.type !== "select") throw new Error("state control must be a select");+ for (const state of control.options) {+ const out = snippet({ state });+ expect(out).toContain(`state="${state}"`);+ }+ });+});++describe("tabsConfig.snippet: NEVER emits steps", () => {+ it("never emits `steps` for any state option", () => {+ for (const state of VALID_STATES) {+ expect(snippet({ state })).not.toContain("steps");+ }+ });+});++describe("tabsConfig.snippet: import line", () => {+ it("includes `import { Tabs }` from the correct path", () => {+ const out = snippet({ state: "Account" });+ expect(out).toContain('import { Tabs }');+ expect(out).toContain('from "@/components/remocn/tabs"');+ });+});++describe("tabsConfig.snippet: default props are omitted", () => {+ // Defaults: variant="pill", mode="light"+ const allDefaults = snippet({+ state: "Account",+ variant: "pill",+ mode: "light",+ });++ it("omits variant when it equals the default 'pill'", () => {+ expect(allDefaults).not.toContain("variant=");+ });++ it("omits mode when it equals the default 'light'", () => {+ expect(allDefaults).not.toContain("mode=");+ });+});++describe("tabsConfig.snippet: non-default props are emitted", () => {+ it("emits a non-default variant='underline'", () => {+ expect(snippet({ state: "Account", variant: "underline" }))+ .toContain('variant="underline"');+ });++ it("emits a non-default mode='dark'", () => {+ expect(snippet({ state: "Account", mode: "dark" }))+ .toContain('mode="dark"');+ });+});++describe("tabsConfig.snippet: structural round-trip", () => {+ const out = snippet({ state: "Account" });++ it("starts with the import line", () => {+ expect(out.startsWith('import { Tabs }')).toBe(true);+ });++ it("contains a <Tabs JSX opening", () => {+ expect(out).toContain("<Tabs");+ });++ it("ends with a self-closing />", () => {+ expect(out.trimEnd().endsWith("/>")).toBe(true);+ });+});++// ===========================================================================+// 4. tabsStyle presets — pure (state, ctx) => TabsStyle+// tabsStyleContext and tabsStyle are exported and frame-free.+// Build one ctx from the default items + "pill" variant + default light+// theme, then assert indicatorOffset for every named state.+// Unknown state → 0 (the documented safe fallback).+// ===========================================================================++describe("tabsStyle: Account state", () => {+ it("indicatorOffset is 0 (first tab)", () => {+ expect(tabsStyle("Account", ctx).indicatorOffset).toBe(0);+ });+});++describe("tabsStyle: Password state", () => {+ it("indicatorOffset is 1 (second tab)", () => {+ expect(tabsStyle("Password", ctx).indicatorOffset).toBe(1);+ });+});++describe("tabsStyle: Settings state", () => {+ it("indicatorOffset is 2 (third tab)", () => {+ expect(tabsStyle("Settings", ctx).indicatorOffset).toBe(2);+ });+});++describe("tabsStyle: unknown state", () => {+ it("returns indicatorOffset 0 as the safe fallback for an unknown state", () => {+ expect(tabsStyle("Nope", ctx).indicatorOffset).toBe(0);+ });++ it("returns indicatorOffset 0 for an empty-string state", () => {+ expect(tabsStyle("", ctx).indicatorOffset).toBe(0);+ });+});++describe("tabsStyle: each item maps to its own index", () => {+ const items = ["Account", "Password", "Settings"];+ // Loop asserting index round-trip+ for (let i = 0; i < items.length; i++) {+ const item = items[i];+ it(`${item} → indicatorOffset ${i}`, () => {+ expect(tabsStyle(item, ctx).indicatorOffset).toBe(i);+ });+ }+});++describe("tabsStyle: indicatorOffset invariant across variants", () => {+ const underlineCtx = tabsStyleContext(+ ["Account", "Password", "Settings"],+ "underline",+ defaultLightTheme,+ );++ it("Account → 0 in underline variant", () => {+ expect(tabsStyle("Account", underlineCtx).indicatorOffset).toBe(0);+ });++ it("Password → 1 in underline variant", () => {+ expect(tabsStyle("Password", underlineCtx).indicatorOffset).toBe(1);+ });++ it("Settings → 2 in underline variant", () => {+ expect(tabsStyle("Settings", underlineCtx).indicatorOffset).toBe(2);+ });+});++// ===========================================================================+// 5. tweenTabsStyle — pure linear interpolation between two TabsStyles.+// `indicatorOffset` is the ONLY field; it lerps linearly.+// Concrete expectations: offset 0 (Account) → offset 2 (Settings)+// and the reverse direction.+// ===========================================================================++describe("tweenTabsStyle: t=0 returns values equal to `a`", () => {+ const a = tabsStyle("Account", ctx); // indicatorOffset: 0+ const b = tabsStyle("Settings", ctx); // indicatorOffset: 2+ const r = tweenTabsStyle(a, b, 0);++ it("indicatorOffset equals a.indicatorOffset at t=0", () => {+ expect(r.indicatorOffset).toBeCloseTo(a.indicatorOffset, 10);+ });+});++describe("tweenTabsStyle: t=1 returns values equal to `b`", () => {+ const a = tabsStyle("Account", ctx); // indicatorOffset: 0+ const b = tabsStyle("Settings", ctx); // indicatorOffset: 2+ const r = tweenTabsStyle(a, b, 1);++ it("indicatorOffset equals b.indicatorOffset at t=1", () => {+ expect(r.indicatorOffset).toBeCloseTo(b.indicatorOffset, 10);+ });+});++describe("tweenTabsStyle: t=0.5 midpoint numeric lerp (Account → Settings)", () => {+ // Account: indicatorOffset=0, Settings: indicatorOffset=2+ // Midpoint: 1+ const a = tabsStyle("Account", ctx);+ const b = tabsStyle("Settings", ctx);+ const r = tweenTabsStyle(a, b, 0.5);++ it("indicatorOffset midpoint: 0 → 2 gives 1", () => {+ expect(r.indicatorOffset).toBeCloseTo(1, 10);+ });+});++describe("tweenTabsStyle: t=0.5 midpoint numeric lerp (Settings → Account)", () => {+ // Settings: indicatorOffset=2, Account: indicatorOffset=0+ // Midpoint: 1+ const a = tabsStyle("Settings", ctx);+ const b = tabsStyle("Account", ctx);+ const r = tweenTabsStyle(a, b, 0.5);++ it("indicatorOffset midpoint: 2 → 0 gives 1", () => {+ expect(r.indicatorOffset).toBeCloseTo(1, 10);+ });+});++// ===========================================================================+// 6. DEFAULT_DURATION — sanity check the exported constant+// ===========================================================================++describe("DEFAULT_DURATION", () => {+ it("is a positive number", () => {+ expect(typeof DEFAULT_DURATION).toBe("number");+ expect(DEFAULT_DURATION).toBeGreaterThan(0);+ });++ it("equals 14 (the authored value)", () => {+ expect(DEFAULT_DURATION).toBe(14);+ });+});diff --git a/registry/remocn-ui/tabs/config.ts b/registry/remocn-ui/tabs/config.tsnew file mode 100644index 00000000..411da9ff--- /dev/null+++ b/registry/remocn-ui/tabs/config.ts@@ -0,0 +1,48 @@+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";+import type { TabsState } from "@/registry/remocn-ui/tabs";++export const tabsConfig: ComponentConfig = {+ componentName: "Tabs",+ importPath: "@/components/remocn/tabs",+ controls: {+ state: {+ type: "select",+ default: "Account",+ options: ["Account", "Password", "Settings"],+ label: "State",+ },+ variant: {+ type: "select",+ default: "pill",+ options: ["pill", "underline"],+ label: "Variant",+ },+ mode: {+ type: "select",+ default: "light",+ options: ["light", "dark"],+ label: "Mode",+ },+ },+ durationInFrames: 120,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ snippet: (values) => {+ const state = (values.state as TabsState) ?? "Account";+ const variant = values.variant as string | undefined;+ const mode = values.mode as string | undefined;++ const props: string[] = [` state="${state}"`];+ if (variant !== undefined && variant !== "pill")+ props.push(` variant="${variant}"`);+ if (mode !== undefined && mode !== "light")+ props.push(` mode="${mode}"`);++ return `import { Tabs } from "@/components/remocn/tabs";++<Tabs+${props.join("\n")}+/>`;+ },+};diff --git a/registry/remocn-ui/tabs/index.tsx b/registry/remocn-ui/tabs/index.tsxnew file mode 100644index 00000000..2733e7d5--- /dev/null+++ b/registry/remocn-ui/tabs/index.tsx@@ -0,0 +1,248 @@+"use client";++import { mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";++/** Active tab — one of the `items` VALUES (the label string). */+export type TabsState = string;++type TabsVariant = "pill" | "underline";++export interface TabsProps {+ /** Current visual state (snap path). State changes snap (no enter-tweens). */+ state?: TabsState;+ /**+ * Resolved animated visual (smooth path). When provided, takes precedence over+ * `state` — feed it an interpolated `TabsStyle` from `useTabsTransition`.+ */+ style?: TabsStyle;+ /** Tab labels (and values). The active `state` is one of these. */+ items?: string[];+ /** Panel body text per tab — parallel to `items`. */+ contents?: string[];+ /**+ * Natural height (px) of the panel body box. The panels stack in a fixed+ * `contentHeight` box — Remotion's headless render can't measure auto height,+ * so the resting height is authored, not measured.+ */+ contentHeight?: number;+ variant?: TabsVariant;+ theme?: Partial<RemocnTheme>;+ mode?: "light" | "dark";+ className?: string;+}++/** Widget width (px) of the rendered tabs. */+const WIDTH = 440;++/** Default tab labels. */+const DEFAULT_ITEMS = ["Account", "Password", "Settings"];++/** Default panel body text, parallel to `DEFAULT_ITEMS`. */+const DEFAULT_CONTENTS = [+ "Make changes to your account here.",+ "Change your password here.",+ "Manage your notification settings.",+];++// ===========================================================================+// Tabs visual — the COMPLETE animated look for a moment in time. A `state` is a+// named preset of this visual (`tabsStyle`); the smooth path feeds an+// interpolated `TabsStyle` straight through. The component is a pure renderer of+// whichever `TabsStyle` it receives. Everything else (indicator x/width,+// per-label color, panel crossfade) DERIVES from `indicatorOffset` in render.+// ===========================================================================++export interface TabsStyle {+ /**+ * Float index (0,1,2…) of where the active indicator sits. The only animated+ * field — the indicator position, label colors, and panel opacities all+ * derive from it inside the pure render.+ */+ indicatorOffset: number;+}++/** Concrete colors for the active variant/theme, resolved once per render. */+export interface TabsStyleContext {+ /** Tab labels/values — the indicator and panels are indexed against this. */+ items: string[];+ variant: TabsVariant;+ /** Track background behind the pill indicator (underline: unused). */+ trackBg: string;+ /** Active label color. */+ activeFg: string;+ /** Inactive label color. */+ inactiveFg: string;+ /** Indicator fill (pill: card bg; underline: the bar color). */+ indicatorBg: string;+ border: string;+ radius: number;+ /** Panel body text color. */+ panelFg: string;+}++/**+ * Derive the concrete colors for a variant/theme. Pure — call it once and reuse+ * the result for every `tabsStyle(state, ctx)` preset.+ */+export function tabsStyleContext(+ items: string[],+ variant: TabsVariant,+ theme: RemocnTheme,+): TabsStyleContext {+ return {+ items,+ variant,+ trackBg: theme.muted,+ activeFg: theme.foreground,+ // Pill: muted-foreground for the resting labels. Underline: same.+ inactiveFg: theme.mutedForeground,+ // Pill: a concrete card bg lifts the active tab off the muted track.+ // Underline: the primary bar along the bottom edge.+ indicatorBg: variant === "underline" ? theme.primary : theme.background,+ border: theme.border,+ radius: theme.radius,+ panelFg: theme.mutedForeground,+ };+}++/**+ * The COMPLETE resting visual for a state — a pure `(state, ctx) => TabsStyle`+ * map. `indicatorOffset` is the index of `state` in `ctx.items` (safe lookup:+ * unknown state → 0).+ */+export function tabsStyle(state: TabsState, ctx: TabsStyleContext): TabsStyle {+ const i = ctx.items.indexOf(state);+ return { indicatorOffset: i < 0 ? 0 : i };+}++export function Tabs({+ state = DEFAULT_ITEMS[0],+ style,+ items = DEFAULT_ITEMS,+ contents = DEFAULT_CONTENTS,+ contentHeight = 72,+ variant = "pill",+ theme: themeOverride,+ mode,+ className,+}: TabsProps) {+ const theme = useRemocnTheme(themeOverride, mode);++ const ctx = tabsStyleContext(items, variant, theme);+ const v = style ?? tabsStyle(state, ctx);++ const isPill = ctx.variant === "pill";+ // Pill rests on a padded muted track; underline runs flush to the edges.+ const trackPad = isPill ? 4 : 0;+ const innerWidth = WIDTH - trackPad * 2;+ const segmentWidth = innerWidth / items.length;+ const rowHeight = 40;+ const indicatorX = trackPad + v.indicatorOffset * segmentWidth;++ return (+ <div+ className={className}+ style={{+ position: "absolute",+ inset: 0,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ // OPAQUE wrapper — tabs is a self-contained widget, not a modal layer.+ background: theme.background,+ fontFamily:+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",+ }}+ >+ <div style={{ width: WIDTH }}>+ {/* Tab row — equal-width segments with the sliding indicator behind. */}+ <div+ style={{+ position: "relative",+ height: rowHeight,+ padding: trackPad,+ boxSizing: "border-box",+ display: "flex",+ background: isPill ? ctx.trackBg : "transparent",+ borderRadius: isPill ? ctx.radius : 0,+ borderBottom: isPill ? undefined : `1px solid ${ctx.border}`,+ }}+ >+ {/* Sliding indicator — pill: a rounded card; underline: a 2px bar. */}+ <div+ style={+ isPill+ ? {+ position: "absolute",+ top: trackPad,+ left: indicatorX,+ width: segmentWidth,+ height: rowHeight - trackPad * 2,+ background: ctx.indicatorBg,+ borderRadius: ctx.radius - 3,+ boxShadow: "0 1px 2px rgba(0,0,0,0.1)",+ }+ : {+ position: "absolute",+ bottom: 0,+ left: indicatorX,+ width: segmentWidth,+ height: 2,+ background: ctx.indicatorBg,+ }+ }+ />+ {/* Labels stay in normal flow defining the segment widths. */}+ {items.map((item, i) => {+ const proximity = Math.max(0, 1 - Math.abs(i - v.indicatorOffset));+ return (+ <span+ key={item}+ style={{+ position: "relative",+ width: segmentWidth,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ fontSize: 14,+ fontWeight: 500,+ letterSpacing: "-0.01em",+ color: mixOklch(ctx.inactiveFg, ctx.activeFg, proximity),+ }}+ >+ {item}+ </span>+ );+ })}+ </div>+ {/* Panel — all panels stacked in a fixed box; opacity crossfades them. */}+ <div+ style={{+ position: "relative",+ height: contentHeight,+ marginTop: 16,+ }}+ >+ {items.map((item, i) => {+ const proximity = Math.max(0, 1 - Math.abs(i - v.indicatorOffset));+ return (+ <div+ key={item}+ style={{+ position: "absolute",+ inset: 0,+ opacity: proximity,+ fontSize: 14,+ lineHeight: 1.5,+ color: ctx.panelFg,+ }}+ >+ {contents[i]}+ </div>+ );+ })}+ </div>+ </div>+ </div>+ );+}diff --git a/registry/remocn-ui/tabs/use-tabs-transition.ts b/registry/remocn-ui/tabs/use-tabs-transition.tsnew file mode 100644index 00000000..7fa5b167--- /dev/null+++ b/registry/remocn-ui/tabs/use-tabs-transition.ts@@ -0,0 +1,72 @@+"use client";++import {+ easings,+ type RemocnTheme,+ type Step,+ useRemocnTheme,+ useStateTransition,+} from "@/lib/remocn-ui";+import {+ tabsStyle,+ tabsStyleContext,+ type TabsState,+ type TabsStyle,+} from "@/components/remocn/tabs";+// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.++/** Default tab labels — mirrors the component's default `items`. */+const DEFAULT_ITEMS = ["Account", "Password", "Settings"];++/** Default transition length (frames) when a step omits `duration`. Tune to taste. */+export const DEFAULT_DURATION = 14;++/** Blend two tabs visuals: `indicatorOffset` lerps (it's the only field). */+export function tweenTabsStyle(+ a: TabsStyle,+ b: TabsStyle,+ t: number,+): TabsStyle {+ return {+ indicatorOffset:+ a.indicatorOffset + (b.indicatorOffset - a.indicatorOffset) * t,+ };+}++export interface TabsTransitionOptions {+ items?: string[];+ variant?: "pill" | "underline";+ theme?: Partial<RemocnTheme>;+ mode?: "light" | "dark";+ speed?: number;+ defaultDuration?: number;+}++/**+ * Timeline → resolved (eased, tweened) TabsStyle. The CALLER invokes this; it+ * reads the frame, the `<Tabs>` component does not. Feed the result to+ * `<Tabs style={...} />` for a smooth sliding indicator.+ */+export function useTabsTransition(+ steps: Step<TabsState>[],+ opts: TabsTransitionOptions = {},+): TabsStyle {+ const {+ items = DEFAULT_ITEMS,+ variant = "pill",+ theme: themeOverride,+ mode,+ speed = 1,+ defaultDuration = DEFAULT_DURATION,+ } = opts;+ const theme = useRemocnTheme(themeOverride, mode);+ const ctx = tabsStyleContext(items, variant, theme);+ const { from, to, progress } = useStateTransition(+ steps,+ items[0],+ speed,+ defaultDuration,+ );+ const t = easings.out(progress);+ return tweenTabsStyle(tabsStyle(from, ctx), tabsStyle(to, ctx), t);+}