How to Make a Line Adjust to Text in After Effects

Опубликовано: 23 Март 2026
на канале: Masd*Lab
2,450
54

"If you enjoyed this tutorial, consider supporting my work for just $1 at https://bit.ly/3ZNu6fL – you'll also get free scripts and working files as a thank you!"

Welcome to my channel! In this video, I'll show you how to create an auto-resizing underline in After Effects that dynamically adjusts to fit your text, with customizable distance. Whether you're new to expressions or looking to add a sleek touch to your designs, you're in the right place!

In this tutorial, we'll use expressions to resize and position a shape layer based on the dimensions of a text layer. Here's what you'll learn:

Setting up text and shape layers in your composition.
Writing an expression to dynamically resize the underline to match the text width.
Positioning the underline at a custom distance below the text.
Expressions used:

Rectangle Size Property:

var textLayer = thisComp.layer("hello");
var textLength = textLayer.sourceRectAtTime(time).width;
var lineHeight = 5; // Adjust this value to set the thickness of the underline
[textLength, lineHeight]


Shape Position Property:


var textLayer = thisComp.layer("hello");
var textPos = textLayer.transform.position;
var textRect = textLayer.sourceRectAtTime(time);
var lineDistance = 10; // Adjust this value to set the distance between the text and the underline
var rectPos = [textPos[0] + textRect.left + textRect.width / 2, textPos[1] + textRect.top + textRect.height + lineDistance];
rectPos


With these simple yet powerful expressions, you'll have a dynamically adjusting underline that enhances your text animations.

Please feel free to change the distance and line height values to suit your design needs. If you found this video helpful, don't forget to like, comment, and subscribe for more After Effects tips and tricks. Thanks for watching, and I'll see you in the next video!

Follow me for more After Effects Expressions and Tutorials!

#AfterEffects #Animation #Expressions #MotionGraphics #Tutorial #DesignTips #TextAnimation