Overview
Containers group display objects and control their position, visibility, and layer order. Graphics components let you draw shapes programmatically using the PixiJS graphics API.Coordinate system
PixiJS uses a top-left origin —x=0, y=0 is the top-left corner of the canvas. The x axis increases to the right, and the y axis increases downward.
The anchor prop on shape components shifts the pivot point of the object. anchor={0} (default) places the origin at the top-left of the object. anchor={0.5} centres it. anchor={1} places it at the bottom-right.
<Container>
A transparent display-object group. Nest other components inside it to control their collective position, scale, alpha, and z-order.<Container> accepts all props from PIXI.ContainerOptions. The most commonly used props are listed below.
Props
Horizontal position in pixels from the parent’s origin. Default
0.Vertical position in pixels from the parent’s origin. Default
0.Override the container’s width. Scales child content to fit.
Override the container’s height. Scales child content to fit.
Uniform scale (
number) or per-axis scale ({ x, y }). Default 1.Opacity from
0 (invisible) to 1 (fully opaque). Default 1.When
false, the container and all its children are hidden and excluded from rendering. Default true.Sort order within the parent container. Higher values render on top. Default
0.Rotation in radians. Default
0.The pivot point used for rotation and scaling, in local coordinates.
When
true, children are automatically sorted by zIndex before each render. Default false.When
false, pointer events are disabled for all children. Default true.CSS cursor string shown when the pointer is over this container. Accepts standard CSS cursor values.
Child components to render inside this container.
Example
<Graphics>
Renders arbitrary shapes using a draw callback. The callback receives aPIXI.Graphics instance and is re-run reactively whenever the draw prop changes.
Props
A function called with the
PIXI.Graphics object. Use the full PixiJS graphics API inside this function to draw shapes, lines, fills, and strokes. The graphics context is cleared before each call.When
true, this graphics object is applied as a mask to the parent container. When false or omitted, the mask is removed. Default undefined.Horizontal position. Default
0.Vertical position. Default
0.Opacity from
0 to 1. Default 1.Whether the graphic is rendered. Default
true.Sort order within the parent. Default
0.CSS cursor string for pointer interaction.
Example
<Circle>
A convenience wrapper around<Graphics> that draws a filled circle with an optional border. Supports the anchor prop to control the pivot point.
Props
The diameter of the circle in pixels.
Controls the pivot point.
0 = top-left, 0.5 = centre, 1 = bottom-right. Accepts a number (uniform) or { x, y }. Default undefined (top-left).Fill colour. Accepts hex numbers (
0xff0000), CSS colour strings ('#ff0000'), or RGB arrays. Default 0x000000.Fill opacity from
0 to 1. Default 1.Stroke colour. Default
0x000000.Stroke width in pixels. Default
0 (no border).Stroke opacity from
0 to 1. Default 1.Horizontal position. Default
0.Vertical position. Default
0.Object opacity. Default
1.Whether the circle is rendered. Default
true.Sort order within the parent. Default
0.Apply this circle as a mask on the parent container.
CSS cursor string.
Example
<Rectangle>
A convenience wrapper around<Graphics> that draws a filled rectangle with optional rounded corners and border. Supports the anchor prop.
Props
Width of the rectangle in pixels.
Height of the rectangle in pixels.
Controls the pivot point.
0 = top-left, 0.5 = centre. Default undefined (top-left).Corner radius for rounded rectangles.
0 = sharp corners. Default 0.Fill colour. Default
0x000000.Fill opacity from
0 to 1. Default 1.Stroke colour. Default
0x000000.Stroke width in pixels. Default
0 (no border).Stroke opacity from
0 to 1. Default 1.Horizontal position. Default
0.Vertical position. Default
0.Object opacity. Default
1.Whether the rectangle is rendered. Default
true.Sort order within the parent. Default
0.Apply this rectangle as a mask on the parent container.
CSS cursor string.
Example
Using Graphics as a mask
SetisMask={true} on any <Graphics>, <Circle>, or <Rectangle> to clip the parent container to that shape.
