Skip to main content
Renders an SVG element that serves as the root container for SVG content. All Recharts charts already include a Surface component internally, so you would not normally use this component directly. However, it can be useful when building custom visualizations outside of the standard chart components. This component wraps the standard SVG element.

Props

Size

number | string
required
The width of the SVG surface. Can be a number (pixels) or a string (e.g., “100%”).
number | string
required
The height of the SVG surface. Can be a number (pixels) or a string (e.g., “100%”).

Viewport

{ x: number, y: number, width: number, height: number }
The SVG viewBox attribute, defining the position and dimension of the viewport.If not provided, defaults to { x: 0, y: 0, width, height } based on the width and height props.

Appearance

string
CSS class name to apply to the SVG element.
CSSProperties
Inline styles to apply to the SVG element.

Accessibility

string
The title of the SVG, rendered as a <title> element for accessibility.
string
The description of the SVG, rendered as a <desc> element for accessibility.

Content

ReactNode
SVG elements to render inside the Surface.

SVG properties

This component accepts all standard SVG element properties including:
  • xmlns - XML namespace
  • xmlnsXlink - XLink namespace
  • preserveAspectRatio - How to scale the viewBox
All SVG element event handlers are also supported.

Examples

Basic surface

With custom viewBox

With accessibility attributes