Text Elements
Complete reference for text elements in the Zvid Package, including styling options, HTML support, and positioning.
Overview
Text elements allow you to add static text or HTML to your videos. It supports HTML content with extensive styling options including custom fonts, colors, alignment, and text effects.
TextItem Interface
interface TextItem {
type: "TEXT";
text?: string;
html?: string;
style?: CSS.Properties;
x?: number;
y?: number;
width?: number;
height?: number;
anchor?: Anchor;
position?: PositionPreset;
enterBegin?: number;
enterEnd?: number;
exitBegin?: number;
exitEnd?: number;
track?: number;
opacity?: number;
angle?: number;
flipV?: boolean;
flipH?: boolean;
enterAnimation?: string | null;
exitAnimation?: string | null;
}
Properties
Required Properties
| Property | Type | Description |
|---|---|---|
type | "TEXT" | Element type identifier |
Content Properties
| Property | Type | Default | Description |
|---|---|---|---|
text | string | "" | Plain text content (required if no html) |
html | string | "" | HTML formatted text content (takes priority over text) |
style | CSS.Properties | Default style | Text styling configuration |
Position & Size Properties
| Property | Type | Default | Description |
|---|---|---|---|
x | number | 0 | Horizontal position in pixels |
y | number | 0 | Vertical position in pixels |
width | number | Auto-calculated | Text box width in pixels |
height | number | Auto-calculated | Text box height in pixels |
anchor | Anchor | top-left | Anchor point for positioning, scaling and rotation |
Timing Properties
| Property | Type | Default | Description |
|---|---|---|---|
enterBegin | number | 0 | Start time for entrance (seconds) |
enterEnd | number | 0 | End time for entrance animation (seconds) |
exitBegin | number | project.duration | Start time for exit animation (seconds) |
exitEnd | number | project.duration | End time for exit (seconds) |
Visual Properties
| Property | Type | Default | Description |
|---|---|---|---|
track | number | 0 | Layer/track number (higher = on top) |
opacity | number | 1 | Transparency (0-1) |
angle | number | 0 | Rotation in degrees |
flipV | boolean | false | Flip Vertically |
flipH | boolean | false | Flip Horizontal |
Animation Properties
| Property | Type | Default | Description |
|---|---|---|---|
enterAnimation | string | null | null | Entrance animation name |
exitAnimation | string | null | null | Exit animation name |
Click here to see Supported Animations
Anchor
PositionPreset
type PositionPreset =
| "top-left"
| "top-center"
| "top-right"
| "center-left"
| "center-center"
| "center-right"
| "bottom-right"
| "bottom-center"
| "bottom-left"
| "custom";
type Anchor =
| "top-left"
| "top-center"
| "top-right"
| "center-left"
| "center-center"
| "center-right"
| "bottom-left"
| "bottom-center"
| "bottom-right";
Basic Examples
Simple Text
{
type: "TEXT",
text: "Hello World",
x: 640,
y: 360,
style: {
fontSize: "48px",
color: "#000000",
textAlign: "center"
}
}
Styled Text with Animation
{
type: "TEXT",
text: "Welcome to Zvid",
position: "center-center"
enterBegin: 0,
enterEnd: 1,
exitBegin: 9,
exitEnd: 10,
style: {
fontSize: "36px",
color: "#ff6b35",
textAlign: "center",
fontWeight: "bold",
letterSpacing: "2px"
},
enterAnimation: "fade",
exitAnimation: "fade"
}
HTML Content
{
type: "TEXT",
html: `
<div style="text-align: center;">
<h1 style="color: #ff6b35; margin: 0;">Big Title</h1>
<p style="color: #666; font-size: 18px;">Subtitle text</p>
</div>
`,
position: 'center-center',
enterBegin: 0,
enterEnd: 2,
exitBegin: 8,
exitEnd: 10,
}
Advanced Examples
Multi-line Text with Custom Styling
{
type: "TEXT",
html: "<div><p>Line 1</p><p>Line 2</p><p>Line 3</p></div>",
position: "center-center",
style: {
fontSize: "24px",
color: "#2c3e50",
fontFamily: "Roboto",
textAlign: "left",
lineHeight: 1.5,
letterSpacing: "1px"
},
enterBegin: 1,
enterEnd: 2,
exitBegin: 4,
exitEnd: 5,
enterAnimation: "slideleft",
exitAnimation: "slideright"
}
Rotated Text with Transparency
{
type: "TEXT",
text: "WATERMARK",
x: 660,
y: 340,
angle: 45,
opacity: 0.3,
style: {
fontSize: "72px",
color: "#000000",
fontFamily: "Anton",
textAlign: "center",
letterSpacing: "5px"
},
track: 10, // High track to appear on top
anchor: "center-center" // try "top-left" or "bottom-right" to change rotation/scale origin
}
HTML with Rich Formatting
{
type: "TEXT",
html: `
<div style="
background: linear-gradient(45deg, #ff6b35, #f7931e);
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
">
<h2 style="color: white; margin: 0 0 10px 0;">Special Offer!</h2>
<p style="color: white; margin: 0; font-size: 16px;">
Get <strong>50% OFF</strong> on all products
</p>
</div>
`,
x: 640,
y: 360,
width: 400,
height: 120,
enterEnd: 1.5,
exitBegin: 8.5,
exitEnd: 10,
enterAnimation: "fade",
exitAnimation: "fade"
}
Font Handling
The package automatically downloads and caches Google Fonts when specified in the fontFamily property. Popular fonts include:
- Sans-serif: Roboto, Open Sans, Lato, Montserrat, Poppins
- Serif: Playfair Display, Merriweather, Lora
- Display: Oswald, Bebas Neue, Righteous
- Monospace: Roboto Mono, Source Code Pro
{
type: "TEXT",
text: "Custom Font Example",
style: {
fontFamily: "Montserrat", // Automatically downloaded from Google Fonts
fontSize: "32px",
fontWeight: "bold"
}
}
Best Practices
Positioning and Sizing
- Center Positioning: For centered text, use
x: width / 2 - elementWidth / 2andy: height / 2 - elementHeight / 2 - Auto-sizing: Let width and height auto-calculate for simple text
- Manual Sizing: Set explicit dimensions for multi-line or HTML content
Animation Coordination
- Timing: Ensure
enterEnd≤exitBeginfor continuous visibility - Staggering: Use different timing for multiple text elements
- Track Layering: Use higher track numbers for text that should appear on top
Related Pages
- Animation Effects - Learn about text animations
- Video Elements - Combining text with video
- Image Elements - Text overlays on images
Next Steps
- Image Elements - Add images to your videos
- Animation Effects - Animate your text elements