#cy.style()
// Get the style engine
cy.style(): StyleEngineRead the style engine for this graph.
StyleEnginethis graph's style engine
#cy.style(sheet)
// Install a stylesheet
cy.style(sheet: Stylesheet<NodeData, EdgeData>): StyleEngineGet the style engine, or set the stylesheet and return it.
The sheet is a plain { nodes, edges, parents, core } object of prop objects — there are no selector blocks and no style functions. All per-element variation is declarative: mapper objects ({ data, scale, … }) and case conditionals, which is what keeps every value analyzable, serializable and GPU-evaluable.
Inside a batch the sheet is compiled and validated immediately (so errors still throw at the call site) but applied once at the outermost endBatch().
| Name | Description |
|---|---|
sheet: Stylesheet<NodeData, EdgeData> | the stylesheet to install |
Fields of sheet
| Name | Description |
|---|---|
nodes: StyleProps<NodeData>? | node props; typed, a mapper's field is a node field |
edges: StyleProps<EdgeData>? | edge props; typed, a mapper's field is an edge field |
parents: StyleProps<NodeData>? | Compound-parent overlay: node props that apply to parent nodes on top of
the nodes group and the parent defaults (rectangle, #eee fill, 1px
#ccc border, padding 10) — constants or mappers — plus the compound props
|
core: StyleProps? | Core (viewport-level) theming props (A2), constants only:
|
bypasses: Record<string, StyleProps>? | Per-element bypasses: id → prop → constant. A bypass beats everything —
the user's group blocks and the default sheet's state conditionals
included — and is an id-keyed declaration rather than
element state: it survives remove/re-add of its element, may name an id
that does not exist yet (inert until it does), and round-trips through
|
StyleEnginethe style engine (also reachable as the return value when setting, so calls chain)
Example
cy.style({ nodes: { 'background-color': '#369', width: 40 } });console.log(cy.nodes().first().numericStyle('width')); // 40if the sheet references an unknown property or an invalid value