How to right-align text in After Effects (with responsive background)

How do you right-align a text with a background in Adobe After Effects so that the background grows to the left when you add more text?
That’s what I will show you in this tutorial.

How to right-align text in After Effects

First, we have a composition with two layers. A text layer at the top (with right-aligned text) and a shape layer underneath.

Now open the Shape Layer, go to Contents, Rectangle 1, and open Rectangle Path.
Here, you want to add 2 expressions.

Hold down “option” or “alt” while clicking the stopwatch next to "Size".
Copy and paste the following "Size-expression" into this text field. (Replace the text that is already in there.)

s =thisComp.layer("Example123"); x = s.sourceRectAtTime(time-s.inPoint,true).width; y = s.sourceRectAtTime(time-s.inPoint,true).height; [x,y]

Make sure to change the example text to the EXACT name of your text layer.

(Notice that this is case sensitive, so use uppercase and lowercase letters accordingly.)

Now hold down “option” or “alt” again and click the stopwatch next to “Position”. Copy and paste the following “Position-expression” into this field.

content("Rectangle 1").content("Rectangle Path 1").size/2

Now, go down to transform and set the rotation to 180.

And finally, adjust the shape layers position and size to the text and now when you change the length of any of the rows of text, the background will adapt to it.

But if you add or remove rows, you need to reposition the background.

🎞 Watch the tutorial here!

Don’t forget to subscribe to my YouTube channel for hundreds of short tutorials just like this one.

Thanks for reading!

Click the image below to check out my digital products 👇

Previous
Previous

Did you know this about YouTube?

Next
Next

What EVERY creator has (without knowing it)