Skip to main content

Interface: Block<Schema, Component>

Defined in: packages/core/src/block.types.ts:102

One block as registered: the name documents resolve through, the schema its props are judged against, the component that renders it, and the slots it accepts children in. Build one with defineBlock rather than by hand — the object literal alone runs no checks.

Example

import type { Block } from "@nubbin/core";
import { z } from "zod";

const cardSchema = z.object({ title: z.string() });

const card: Block<typeof cardSchema, null> = {
name: "Card",
schema: cardSchema,
component: null,
version: 2,
slots: {},
};

Type Parameters

Schema

Schema extends StandardSchemaV1 = StandardSchemaV1

The block's Standard Schema.

Component

Component = unknown

Whatever the consumer's renderer accepts.

Properties

category?

optional category?: string

Defined in: packages/core/src/block.types.ts:126

The palette section the block files under, wherever an editing surface groups blocks. An opaque label the consumer chooses — Nubbin holds no taxonomy of its own, and a surface may derive a grouping for a block that omits it. Editor metadata like description: compile never reads it.


component

component: Component

Defined in: packages/core/src/block.types.ts:144

What renders this block. core neither calls nor inspects it, which is why the component lives in the registry and never in the serializable catalog. @nubbin/react narrows it to a component type.


description?

optional description?: string

Defined in: packages/core/src/block.types.ts:113

One line saying what the block is for, shown wherever an editing surface lists blocks. Editor metadata with the same standing as editing hints: it sits beside the schema, never inside it, and compile never reads it — no artifact carries a description.


docs?

optional docs?: Record<string, string>

Defined in: packages/core/src/block.types.ts:132

Opaque links keyed by destination — docs: { figma: "…", storybook: "…" } — that an editing surface renders as "Open in {Key}" for the selected block. Nubbin never inspects a URL or knows what is behind it; the consumer supplies them. Compile never reads it.


icon?

optional icon?: string

Defined in: packages/core/src/block.types.ts:119

A single glyph — an emoji or short string the consumer chooses — shown beside the name wherever an editing surface lists blocks. A string rather than a component, so core stays render-agnostic. Editor metadata like description: compile never reads it.


name

name: string

Defined in: packages/core/src/block.types.ts:107

Stable identity, referenced by every node. Renaming it is a migration. Unique across a registry — two blocks sharing a name are refused.


schema

schema: Schema

Defined in: packages/core/src/block.types.ts:137

The schema props are validated against, through its own ~standard.validate. It must answer synchronously; compile refuses a schema that returns a promise.


slots

slots: Record<string, SlotConstraint>

Defined in: packages/core/src/block.types.ts:155

Slot constraints keyed by slot name. A slot the document fills but the block does not declare is a compile error (slot-not-allowed).


version

version: number

Defined in: packages/core/src/block.types.ts:150

Bumped when the schema changes incompatibly. An integer of 1 or more, stamped into the blockVersions of every artifact whose document uses the block — which is what checkRollback compares a stored artifact against.