Sanity Library Reference Docs
    Preparing search index...

    Class ListItemBuilder

    Class for building list items

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    "[serializableMarker]": true

    Brand consumed by isSerializable (avoids circular instanceof imports)

    Methods

    • Set if list item should show a live document count.

      The badge counts every document of the item's schema type. It is withheld, with a development warning, unless the item resolves a document schema type and its child is proven to list every document of that type: the built-in document type child, or a document list carrying the default whole-type query at the default api version.

      Parameters

      • enabled: boolean = true

      Returns ListItemBuilder

      list item builder based on showCount provided. See ListItemBuilder

    • Configure the list item to render a singleton.

      Sugar for declaring a list item with sensible defaults derived from the singleton definition:

      • id defaults to the singleton definition id.
      • title defaults to the definition's title, falling back to the schema type's title. Singletons sharing a schema type therefore share a title unless their definitions set one—list item ids must be unique, titles need not be.
      • icon defaults to the definition's icon, falling back to the schema type's icon.
      • child defaults to a S.document().singleton(<id>) node.
      • schemaType is set to the definition's schema type.

      Each default can be overridden via the standard list-item chain (.title(...), .icon(...), .id(...), .child(...))—before or after this call.

      A SerializeError is thrown immediately if no singleton definition exists for the provided id.

      Parameters

      • singletonId: string

        the singleton definition id

      Returns ListItemBuilder

      list item builder configured for the singleton