Sanity Library Reference Docs
    Preparing search index...

    Interface PortableTextBlock<M, C, S, L>

    A Portable Text Block can be thought of as one paragraph, quote or list item. In other words, it is a container for text, that can have a visual style associated with it. The actual text value is stored in portable text spans inside of the childen array.

    interface PortableTextBlock<
        M extends PortableTextMarkDefinition = PortableTextMarkDefinition,
        C extends TypedObject = ArbitraryTypedObject | PortableTextSpan,
        S extends string = PortableTextBlockStyle,
        L extends string = PortableTextListItemType,
    > {
        _key?: string;
        _type: "block" | string & {};
        children: C[];
        level?: number;
        listItem?: L;
        markDefs?: M[];
        style?: S;
    }

    Type Parameters

    • M extends PortableTextMarkDefinition = PortableTextMarkDefinition

      Mark types that be used for text spans

    • C extends TypedObject = ArbitraryTypedObject | PortableTextSpan

      Types allowed as children of this block

    • S extends string = PortableTextBlockStyle

      Allowed block styles (eg normal, blockquote, h3 etc)

    • L extends string = PortableTextListItemType

      Allowed list item types (eg number, bullet etc)

    Hierarchy

    • TypedObject
      • PortableTextBlock
    Index

    Properties

    _key?: string

    A key that identifies this block uniquely within the parent array. Used to more easily address the block when editing collaboratively, but is also very useful for keys inside of React and other rendering frameworks that can use keys to optimize operations.

    _type: "block" | string & {}

    Type name identifying this as a portable text block. All items within a portable text array should have a _type property.

    Usually 'block', but can be customized to other values

    children: C[]

    Array of inline items for this block. Usually contain text spans, but can be configured to include inline objects of other types as well.

    level?: number

    If this block is a list item, identifies which level of nesting it belongs within

    listItem?: L

    If this block is a list item, identifies which style of list item this is Common values: 'bullet', 'number', but can be configured

    markDefs?: M[]

    Array of mark definitions used in child text spans. By having them be on the block level, the same mark definition can be reused for multiple text spans, which is often the case with nested marks.

    style?: S

    Visual style of the block Common values: 'normal', 'blockquote', 'h1'...'h6'