Dynamic Text Box in After Effects

6 min
Dynamic Text Box in After Effects
Details (6 min read)

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.

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
// edit horizontal padding in pixels
var horizontalPadding = 100;
// edit vertical padding in pixels
var verticalPadding = 50;
// text layer
var textLayer = thisComp.layer("textLayer");

-50%
-50%
00hrs : 00mins : 00sec
Happy HolidaysSale sitewide
Shop now

// 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]

-50%
-50%
00hrs : 00mins : 00sec
Happy HolidaysSale sitewide
Shop now
    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] +

    -50%
    -50%
    00hrs : 00mins : 00sec
    Happy HolidaysSale sitewide
    Shop now

    [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.

    Our Bestsellers

    Summary ( min read)

    Our Bestsellers