g3-toolkit API Reference
    Preparing search index...

    Interface SpecLegendProps

    interface SpecLegendProps {
        className?: string;
        collapsible?: boolean;
        defaultCollapsed?: boolean;
        elements?: readonly LegendElement[];
        labelFor?: (value: string, channel: LegendChannel) => string;
        onResetOverrides?: () => void;
        overrides?: readonly { scope: { nodeId: string } | { type: string } }[];
        sectionTitle?: (channel: LegendChannel, driver: string) => string;
        spec: EncodingSpec;
        title?: string;
        ugm?: UGM;
    }
    Index

    Properties

    className?: string
    collapsible?: boolean

    When true, render a header with a collapse/expand toggle so the legend can be tucked away (it can otherwise cover the canvas).

    defaultCollapsed?: boolean

    Initial collapsed state when collapsible (default false = open).

    elements?: readonly LegendElement[]

    R-13.3: element descriptors for renderers without a UGM.

    REFERENTIAL STABILITY CONTRACT (same one the fixture graphs carry): the row memos depend on this array's IDENTITY, because on the ugm-less path it is the only thing they can key on. Hold it in a useMemo or module constant. A fresh literal per render is correct but recomputes the rows every render; the alternative, omitting it from the dependencies, froze the legend at its first render and is the defect this contract replaces.

    labelFor?: (value: string, channel: LegendChannel) => string

    Display transform for categorical values (e.g. shorten IRIs to prefixed names). Affects labels only; resolution keys are raw. The second argument names the section (issue #38), so one host function can label node types and relation types differently; a one-argument function keeps working unchanged.

    onResetOverrides?: () => void

    Shown as a reset control beside the disclosure.

    overrides?: readonly { scope: { nodeId: string } | { type: string } }[]

    R-13 (register, 2026-08-05): the manual style overrides in scope. The legend asserts that a colour means a class; a reader repainting one node makes that assertion FALSE, and the legend had no way to know. Passing them lets it disclose rather than mislead.

    sectionTitle?: (channel: LegendChannel, driver: string) => string

    Wording for each section heading (issue #38). The default prints the encoding internals, color: <code>types</code>, which reads as a developer tool in an end-user view; a host returns the audience's words instead ("Node type", "Relation"). Scale qualifiers that describe data rather than naming the channel (the size domain, the ramp marker) stay appended either way.

    title?: string

    Header label shown when collapsible (default "Legend").

    ugm?: UGM

    Omit when rendering for a structural scene and pass elements instead (R-13.3).