Video

Shapes

Add, style, and generate vector shapes.

Shapes are vector graphics: rectangles, circles, stars, arrows, lines, and more. They stay sharp at every size. The user sets their fill, their outline, and how long they stay on screen.

Setup

The shape library, fill, and stroke work with no setup. AI shape generation needs an AI provider:

import { VideoEditor } from '@layermetry/media-editor/react';

export default function App() {
  return (
    <div style={{ position: 'fixed', inset: 0 }}>
      <VideoEditor
        licenseKey="YOUR_LICENSE_KEY"
        onClose={() => console.log('The editor was closed')}
        onExport={(file) => console.log(`Exported ${file.name}`)}
        // AI shape generation: your AI proxy.
        ai={{ endpointUrl: 'https://api.example.com/ai' }}
      />
    </div>
  );
}
OptionPropConfiguration page
AI shape generationaiAI providers

Shape library

Open Shapes in the tool rail and click a shape to add it. The filters above the library group the shapes as Basic, Geometric, Arrows, Lines, Organic, and Symbols.

The library has 42 shapes, among them Rectangle, Rounded Rectangle, Circle, Ellipse, Triangle, Pentagon, Hexagon, Polygon, Star, Heart, Diamond, Ring, Squircle, Soft Blob, Badge, Speech Bubble, Callout, and Pill.

The Shapes panel with its category filters and built-in shapesView full size

Add shape in the toolbar above the canvas also adds a shape. A new shape stays on screen for 5 seconds from the playhead.

Fill and stroke

Select a shape. The toolbar above the canvas shows Fill, Stroke, and Stroke width:

  • Fill sets the color inside the shape.
  • Stroke sets the color of the outline.
  • Stroke width sets the thickness of the outline. 0 removes it.

Opacity, under ⋯, makes the whole shape see-through. See Effects and filters for more options.

A selected rounded rectangle and its track in the video editorView full size

Lines and arrows

The library has six lines: Line, Divider, Dashed Line, Dotted Line, Arrow Line, and Double Arrow Line. It also has seven arrows: Thick Arrow, Arrow Up, Arrow Down, Arrow Left, Arrow Right, Double Arrow, and Curved Arrow. The Lines and Arrows filters show them.

A line has no inside, so Stroke and Stroke width set its color and thickness.

AI shape generation

Requires an AI provider, passed as ai. See AI providers.

Open Shapes and press Generate shape. The user describes the shape and presses Generate. The editor shows each outline that the model drew, as a small tile. Add to canvas adds the chosen outline as a shape.

The Generate shape form in the video editor, before a request is sentView full size

Your server answers with { items: [{ pathData }] }: SVG path data that starts with M. The editor drops an outline that draws nothing. See Custom AI endpoint.

Configuration

PropTypeDefaultDescription
aiobjectnoneThe AI provider. svgPath: false hides Generate shape.
uiobjectnoneui.toolRail.hidden: ['shapes'] removes the Shapes panel. See UI customization.

Events

Shapes have no events of their own. They reach you inside the exported video through onExport, and inside saved designs through onSaveTemplate. See Events.

Troubleshooting

Additional resources

On this page