Dynamic Text Box in After Effects

How to create a dynamic text box?

    1. Create a text layer and rename it to textLayer.
    2. Create a rectangular shape.
    3. Alt-click on the Size property and paste the expression below.
// edit horizontal padding in pixels
var horizontalPadding = 100; 
// edit vertical padding in pixels
var verticalPadding = 50;
// text layer
var textLayer = thisComp.layer("textLayer"); 
// bounding box around text
var bbox = textLayer.sourceRectAtTime(time,true); 
// box's width + padding
[bbox.width * textLayer.scale[0] / 100, 
bbox.height * textLayer.scale[1] / 100] + 
[horizontalPadding, verticalPadding] 
    1. Alt-click on the Position property and paste the expression below.
var textLayer = thisComp.layer("textLayer"); 
var box = textLayer.sourceRectAtTime(time, false);
textLayer.position - textLayer.anchorPoint + 
[box.left*textLayer.scale[0] / 100, 
box.top * textLayer.scale[1] / 100] + 
[box.width * textLayer.scale[0] / 100, 
box.height*textLayer.scale[1] / 100] / 2;

How to make a box round?
Open Roundness property of the shape box and increase the value.

How to change padding?
Change horizontalPadding and verticalPadding in the first expression.

-50%
-50%
00hrs : 00mins : 00sec
Cyber MondaySale sitewide
Shop now

Get 10% off when you subscribe to our newsletter

By subscribing you agree to your email being stored and used to receive the emails in accordance to our Privacy Policy
descount