Skip to main content

CSS

The various components and plugins in JsPlumb offer a rich set of CSS classes and attributes that you can use to customize your UI. The Toolkit ships several CSS files (inside the /css directory of the @jsplumbtoolkit/browser-ui package) that contain sane defaults.

  • jsplumbtoolkit.css

    Styles for the UI core, including such things as absolute positioning for nodes/groups, styles to setup a surface widget and its various plugins, etc. You should include this stylesheet in your cascade when you start working with JsPlumb.

  • jsplumbtoolkit-controls.css

    Styles assigned by the controls component

  • jsplumbtoolkit-connector-editors.css

    Styles for the connector editors for Orthogonal and Bezier connectors

  • jsplumbtoolkit-dialogs.css

    Styles for the dialogs helpers

  • jsplumbtoolkit-edge-type-picker.css

    Styles for the edge type picker, as seen in the flowchart builder starter app


UI Core

Nodes & Groups

Classes assigned to nodes and groups in your UI.

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-nodeAssigned to any element representing a node in your data model.
jtk-groupAssigned to any element representing a group in your data model.

Edges

Classes assigned to edges in your UI

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-connectorAssigned to the SVG element that is the parent of the path element used to draw an edge. A common setup using this class is to assign it a z-index which is lower than the z-index set for `.jtk-node` and `.jtk-group`. You can target the path element directly using `.jtk-connector path`, for instance for setting a `stroke-width` or `stroke`
jtk-surface-selected-connectionAssigned to the SVG element of some edge that is currently selected, ie. has been added to a Toolkit instance's current selection. See docs regarding selections and edge styling for further information.

Element dragging

Classes used during the lifecycle of dragging an element (node / group)

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-surface-element-draggingAssigned to a node/group thatis currently being dragged
jtk-most-recently-draggedAssigned to the node/group that was most recently dragged. One common use for this class is to bump the z-index of the most recently dragged element to ensure it sits on top of any other nodes/groups.
jtk-drag-activeAssigned to a group element that is a candidate drop target for a node or group that is currently being dragged
jtk-drag-hoverAssigned to a group element that is the current drop target for a node or group that is being dragged
jtk-drag-original-groupAssigned to a group element when one of its children is being dragged. This can be useful to help manage z-index: we recommend using this class to set a z-index for the drag parent group above that of the other groups, which will ensure that the element you are dragging will appear on top of other groups.

Surface

Classes assigned by the Surface component

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-surfaceAssigned to an element that is acting as a surface widget
jtk-surface-touch-deviceAssigned to an element that is acting as a surface widget when the device supports touch events
jtk-surface-pointer-deviceAssigned to an element that is acting as a surface widget when the device supports pointer events
jtk-surface-direct-renderAssigned to an element that is acting as a surface widget in 'direct render' mode, ie. readonly.
jtk-surface-nopanAssigned to a surface for which `enablePan` was set to `false` in the render args
jtk-surface-canvasAssigned to the work area of a surface widget. This canvas element will have been created automatically by the surface and is not normally something you will need to style. If you do attach some styles, you should be careful to ensure that this element always has `position:relative;` set.
jtk-surface-selected-elementAssigned to any element representing a node/group/port that is part of some surface's current selection.
jtk-surface-selected-connectionAssigned to any element representing an edge that is part of some surface's current selection.
jtk-lassoAssigned to the selection lasso element

Edge path editors

Classes used by the edge path editors.

Default values specified in the jsplumbtoolkit-connector-editors.css stylesheet

ClassDescription
jtk-orthogonal-handleAssigned to segment drag handles in the orthogonal editor
jtk-orthogonal-segment-dragAssigned to segment drag handles in the orthogonal editor
jtk-orthogonal-segment-drag-nsAssigned to segment drag handles on horizontal segments in the orthogonal editor. Indicates a segment can be dragged in the Y axis
jtk-orthogonal-segment-drag-ewAssigned to segment drag handles on vertical segments in the orthogonal editor. Indicates a segment can be dragged in the X axis
jtk-bezier-handleAssigned to control point drag handles in bezier editor. Control points can be dragged by these handles
jtk-bezier-handle-control-pointAssigned to control point drag handles in the Bezier and StateMachine editors. Control points can be dragged by these handles
jtk-bezier-handle-control-point-1Assigned to the first control point handle in the Bezier editor only. In the StateMachine editor this is not assigned
jtk-bezier-handle-control-point-2Assigned to the second control point handle in the Bezier editor only. In the StateMachine editor this is not assigned
jtk-bezier-guidelineAssigned to guidelines in the Bezier/StateMachine editors
jtk-anchor-placeholderAdded to the element placed at the location of an anchor for a connection that is being edited. This applies to both dynamic and continuous anchors
jtk-anchor-candidateAdded to the elements drawn to show where a certain anchor may be relocated to (only applicable for dynamic anchors)
jtk-edge-deleteAssigned to the optional delete button overlay that the edge path editor can add

In addition to these classes, when an anchor is `Continuous`, the edge path editor uses an attribute on the anchor's element to indicate the current face of the element on which a dragged anchor would be located:

AttributeTypeDescription
jtk-anchor-face'left'|'right'|'top'|'bottom'Indicates the current face of the element on which a dragged anchor would be located

You can target the `jtk-anchor-face` attribute with a selector:

SelectorDescription
[jtk-anchor-face='left']Indicates the current target face is the left face
[jtk-anchor-face='right']Indicates the current target face is the right face
[jtk-anchor-face='bottom']Indicates the current target face is the bottom face
[jtk-anchor-face='top']Indicates the current target face is the top face

Plugins

Miniview

These are the classes you can use to style the Miniview. Note that vertices in the Miniview are sized to be identical to their mapped vertices in the related Surface (but the Miniview is zoomed out, so they are not 1:1 in size with their related vertices). You could of course use CSS to force a size for vertices in the Miniview, but this is not recommended: if your Surface contains vertices of various sizes but the Miniview uses a uniform size, the user may experience a certain discontinuity between the two views.

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-miniviewAssigned to an element that is acting as a Miniview's container
jtk-miniview-canvasAssigned to the work area in the Miniview
jtk-miniview-pannerAssigned to the element used to pan the Surface from the Miniview
jtk-miniview-panningAssigned to the element used to pan the surface as it is being dragged
jtk-miniview-elementAssigned to all elements on the Miniview's canvas
jtk-miniview-group-elementAssigned to all group elements on the miniview's canvas (they also get `.jtk-miniview-element`)
jtk-miniview-collapseAssigned to a miniview's collapse/expand element
jtk-miniview-collapsedAssigned to a miniview when it is collapsed
jtk-miniview-click-to-centerAssigned to a miniview's container when `clickToCenter` is enabled on the miniview. The default stylesheet uses this to set a pointer cursor on miniview elements.

Drawing Tools

Classes used by the DrawingTools plugin

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-draw-skeletonAssigned to the outline of the drawing tools attached to some element
jtk-draw-handleAssigned to the individual resize handles
jtk-draw-handle-tlAssigned to the top left resize handle
jtk-draw-handle-trAssigned to the top right resize handle
jtk-draw-handle-brAssigned to the bottom right resize handle
jtk-draw-handle-blAssigned to the bottom left resize handle

Snaplines

Classes used by the Snaplines plugin.

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-snaplineAssigned to both horizontal and vertical snaplines when active
jtk-snapline-horizontalAssigned to horizontal snaplines when active
jtk-snapline-verticalAssigned to vertical snaplines when active
jtk-snapline-exactAssigned to both horizontal and vertical snaplines when the elements are exactly aligned
jtk-snapline-activeAssigned to an element attached to an active snapline
jtk-snapline-active-exactAssigned to an element attached to an active snapline and the elements on the snapline are exactly aligned

Active Filtering

Attributes assigned by the ActiveFiltering plugin

AttributeTypeDescription
data-jtk-enabledbooleanSet to false when the given element is not a valid drag target for the current edge

Pan buttons

Classes assigned by the PanButtons plugin

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-surface-panningAssigned to the surface's canvas when it is panning in response to one of the buttons having been clicked
jtk-surface-pan-activeAssigned to a pan button when it has been clicked and the surface is panning
jtk-surface-panAssigned to all 4 pan buttons
jtk-surface-pan-leftAssigned to the pan button on the left of the canvas
jtk-surface-pan-topAssigned to the pan button on the top of the canvas
jtk-surface-pan-rightAssigned to the pan button on the right of the canvas
jtk-surface-pan-bottomAssigned to the pan button on the bottom of the canvas

Grid background

Generated grids are SVG elements, and each part of the grid is assigned a unique CSS class, allowing you to apply your own styles.

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-background-borderAssigned to the rect element that provides the background border, if present
jtk-background-gridAssigned to both the major and minor grid lines
jtk-background-grid-minorAssigned to the minor grid lines
jtk-background-grid-majorAssigned to the major grid lines

Vertex Drawing

Classes assigned by the vertex drawing plugin

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-vertex-drawing-lassoAssigned to the lasso. The lasso also has its normal `jtk-lasso` class, so you can use this class to override anything from the normal class that you don't want when drawing vertices
jtk-group-candidate-childWhen drawing a group, assigned to any group/node elements that will end up as children of the new group

Components

Dialogs

Classes used by the Dialogs manager.

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-dialog-underlayThe element that acts as the modal mask
jtk-dialog-overlayThe element that acts as the parent for dialog content
jtk-dialog-overlay-visibleAssigned to an overlay when the dialog is visible
jtk-dialog-overlay-xAssigned to dialogs appearing in the `top` or `bottom` positions.
jtk-dialog-overlay-yAssigned to dialogs appearing in the `left` or `right` positions.
jtk-dialog-overlay-topAssigned to dialogs appearing in the `top` position
jtk-dialog-overlay-bottomAssigned to dialogs appearing in the `bottom` position
jtk-dialog-overlay-leftAssigned to dialogs appearing in the `left` position
jtk-dialog-overlay-rightAssigned to dialogs appearing in the `right` position.
jtk-dialog-buttonsButton container element
jtk-dialog-buttonAn individual button in a dialog
jtk-dialog-titleThe titlebar of a dialog
jtk-dialog-contentThe content of a dialog (does not contain the titlebar)

Controls

Classes assigned by the controls component

Default values specified in the jsplumbtoolkit-controls.css stylesheet

ClassDescription
jtk-controlsAssigned to the component root
jtk-selected-modeAssigned to the button that toggles the current mode of the surface
jtk-zoom-to-fitAssigned to the Zoom to fit button
jtk-select-modeAssigned to the Select mode button
jtk-pan-modeAssigned to the Pan mode button
jtk-undoAssigned to the Undo button
jtk-redoAssigned to the Redo button
jtk-clear-datasetAssigned to the Clear dataset button

Additionally, the controls component uses several attributes to reflect the current state:

AttributeTypeDescription
can-undo'true'|'false'Assigned to the `.jtk-controls` element, given a value of true or false depending on the undo stack.
can-redo'true'|'false'Assigned to the `.jtk-controls` element, given a value of true or false depending on the redo stack.
data-undoblankAssigned to the undo button.
data-redoblankAssigned to the redo button.

SVG/PNG/JPG export

Classes used by the SVG/PNG/JPG exporter ui.

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-export-underlayAssigned to the element that acts as an underlay for the export preview
jtk-export-overlayAssigned to the element presents the export preview
jtk-export-cancelAssigned to the 'X' button on the export preview window

You can target various parts of the export UI with these selectors:

SelectorDescription
.jtk-export-overlay canvasTargets the canvas into which the preview is painted.
.jtk-export-overlay aTarget the 'download' link.

Shape library palette

Classes assigned by the shape library palette component

Default values specified in the jsplumbtoolkit.css stylesheet

ClassDescription
jtk-shape-library-palette-setAssigned to the parent element for one set of icons in the shape library palette
jtk-shape-library-paletteAssigned to the root element for a shape library palette
jtk-shape-library-palette-shapeAssigned to each shape icon in the palette
jtk-shape-library-palette-set-titleAssigned to the title element for a set of icons
jtk-shape-library-palette-labelAssigned to the label for each shape icon, if you have `showLabels:true` set.
jtk-shape-library-palette-selected-shapeWhen in `tap` mode, assigned to the currently selected shape.
jtk-shape-library-palette-lassoWhen in `tap` mode, this class is added to the lasso used to draw new vertices
jtk-shape-library-palette-filterAssigned to the drop-down that is shown when there are multiple shape sets in the palette