Charts - Title & Caption

Add a title and caption to any chart with control over position, alignment, font, and floating overlay mode.

#Usage

import { ChartCaption, ChartSvg, ChartTitle } from '@primeui/vue-chart';
<ChartSvg>
    <ChartTitle text="Title" />
    <ChartCaption text="Caption" />
    <!-- series and axes -->
</ChartSvg>

Titles and captions add text labels to the chart. Both reduce the chart area to make room for themselves by default. Set floating to overlay them without consuming layout space, and use position and alignment to control placement.

#Basic

Add ChartTitle to display a title above the chart. Set text to the label to show. The title reduces the chart area height to make room for itself.

Loading Demo...

#Caption

Add ChartCaption alongside ChartTitle to display a descriptive line. By default it stacks directly adjacent to the title and inherits its alignment. Set position on ChartCaption to place it independently. For example, position="bottom" with a top title puts the title above the chart and the caption below it.

Loading Demo...
Loading Demo...

#Alignment

Set alignment to start, center, or end to control horizontal placement within the title area. Both ChartTitle and ChartCaption accept alignment independently.

Loading Demo...

#Position

Set position="bottom" to place the title below the chart area. When positioned at the bottom, ChartCaption sits between the chart and the title.

Loading Demo...

#Styling

Customize font size, weight, family, style, and color using the font props. Set color to any CSS color value to override the default theme text color. Use lineHeight to adjust the line height multiplier applied to the font size. Use padding to control the space above and below the title or caption. Pass a number for uniform spacing or { top, bottom } for independent control.

Loading Demo...

#Floating

Set floating to render the title as an overlay without reducing the chart area height. Use offsetX and offsetY combined with alignment to position it within the chart bounds. This works for compact charts and dashboard tiles.

Loading Demo...

#Offsets

Use offsetX and offsetY to fine-tune the title position after alignment is applied. Accepts positive or negative pixel values.

Loading Demo...

#Responsive Scaling

When fontSize is omitted, title and caption font sizes adapt to the container width across four tiers. Resize the chart to see the text scale down on smaller containers.

Loading Demo...

#API

#ChartTitle

PropTypeDefaultDescription
textstringrequiredTitle text
position'top' | 'bottom''top'Placement relative to the chart
alignment'start' | 'center' | 'end''center'Horizontal alignment within the title area
fontSizenumberauto-adaptiveFont size in pixels. Omit to use responsive auto-scaling
fontWeight'normal' | 'bold' | number600Font weight
fontFamilystring'system-ui, sans-serif'Font family
fontStyle'normal' | 'italic''normal'Font style
lineHeightnumber1.2Line height multiplier applied to font size
colorstringtheme text colorText color. Any CSS color value
paddingnumber | { top?: number; bottom?: number }theme defaultSpace above and below the title
floatingbooleanfalseOverlay the title on the chart without reducing the plot area height
offsetXnumber-Horizontal offset in pixels applied after alignment
offsetYnumber-Vertical offset in pixels

#ChartCaption

PropTypeDefaultDescription
textstringrequiredCaption text
position'top' | 'bottom'stacks with titlePlacement relative to the chart. Omit to stack adjacent to ChartTitle. Set independently to place the caption on the opposite side, e.g. title on top, caption on bottom
alignment'start' | 'center' | 'end'inherits title alignmentHorizontal alignment
fontSizenumberauto-adaptiveFont size in pixels. Omit to use responsive auto-scaling
fontWeight'normal' | 'bold' | number'normal'Font weight
fontFamilystring'system-ui, sans-serif'Font family
fontStyle'normal' | 'italic''normal'Font style
lineHeightnumber1.2Line height multiplier
colorstringtheme text colorText color
paddingnumber | { top?: number; bottom?: number }theme defaultSpace above and below the caption
offsetXnumber-Horizontal offset in pixels applied after alignment
offsetYnumber-Vertical offset in pixels

#Auto-Adaptive Font Scaling

When fontSize is omitted, font sizes scale based on container width.

Container WidthTitle FontCaption Font
XS (< 300px)12px10px
SM (300–499px)13px11px
MD (500–699px)14px12px
LG (≥ 700px)17px13px

Set fontSize explicitly to opt out of auto-scaling and use a fixed size at all container widths.