Skip to content
This is the alpha v4 version website. Looking for the v3 documentation?

defineSigmaOptions

defineSigmaOptions<P>(options): SigmaOptionsInput<P>

Defined in: packages/sigma/src/types/options.ts:291

Factory function for creating type-safe sigma options.

This function provides type safety for sigma options with automatic inference:

  • Shapes/paths are inferred from primitives and enforced in styles
  • Custom variables declared in primitives become available in styles

Type Parameters

P

P extends PrimitivesDeclaration

Parameters

options

SigmaOptionsInput<P>

Returns

SigmaOptionsInput<P>

Example

const options = defineSigmaOptions({
primitives: {
nodes: {
shapes: [sdfCircle(), sdfSquare()],
variables: {
borderSize: { type: "number", default: 2 },
borderColor: { type: "color", default: "#fff" },
},
layers: [layerFill()],
},
edges: { paths: [pathLine(), pathCurved()] },
},
styles: {
nodes: {
color: "#666",
shape: "circle", // Only names from declared shapes allowed
borderSize: 2, // Inferred from variables
borderColor: "#fff",
},
},
});