Components

CartesianGrid

Add grid lines to cartesian charts

<CartesianGrid> renders horizontal and vertical grid lines behind chart content.

Add a grid

<AreaChart :width="500" :height="300" :data="data">
  <CartesianGrid stroke-dasharray="3 3" />
  <XAxis data-key="name" />
  <YAxis />
  <Area data-key="value" fill="#8884d8" />
</AreaChart>

Hide horizontal or vertical lines

<CartesianGrid :horizontal="false" />

<CartesianGrid :vertical="false" />

Add stripe fills

Use horizontal-fill or vertical-fill for alternating background colors:

<CartesianGrid :horizontal-fill="['#f5f5f5', '#fff']" />

Customize grid lines with slots

Use #horizontal or #vertical slots for custom line rendering:

<CartesianGrid>
  <template #horizontal="props">
    <line v-bind="props" stroke="#eee" stroke-dasharray="5 5" />
  </template>
</CartesianGrid>

CartesianGrid props

PropTypeDefaultDescription
horizontalboolean | objecttrueShow horizontal lines
verticalboolean | objecttrueShow vertical lines
horizontal-fillstring[]—Alternating horizontal stripe colors
vertical-fillstring[]—Alternating vertical stripe colors
stroke-dasharraystring—Dash pattern for grid lines
sync-with-ticksboolean—Align grid lines with axis ticks

CartesianGrid slots

SlotPropsDescription
#horizontal / #verticalCartesianGridLineSlotPropsLine endpoints (x1, y1, x2, y2), index and SVG attributes

Both slots are optional and return VNodeChild.

Copyright © 2026