CxJS

Line

import { Line } from 'cx/svg'; Copied

The Line component is a CxJS version of the SVG line element designed for responsive layouts. The line is always rendered from the top-left corner to the bottom-right corner of its bounding box.

In CxJS, Line is a container element and allows other objects to be rendered within its boundaries, such as Text.

<Svg style="height: 200px; border: 1px dashed #ddd">
  <Line stroke="steelblue" style="stroke-width: 2">
    <Text dy="0.4em" textAnchor="middle">
      Diagonal Line
    </Text>
  </Line>
</Svg>

Positioning

Use anchors to control where the line appears:

  • anchors="0 1 1 0" — diagonal from top-left to bottom-right (default, full container)
  • anchors="0.5 1 0.5 0" — horizontal line at vertical center
  • anchors="0 0.5 1 0.5" — vertical line at horizontal center

Configuration

PropertyTypeDescription
anchorsstring/numberPosition within parent bounds. Format: "t r b l". See Svg for details.
offsetstring/numberTranslate edges in pixels. Format: "t r b l". See Svg for details.
marginstring/numberCSS-like margin. See Svg for details.
strokestringStroke color for the line.
colorIndexnumberIndex in the default color palette.