This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
JinJu Jang
Posted Feb 01 - Read on Facebook

I found a really simple way to make the width of a button dynamic! just one line of code.

layerName.html.length <-- Tells you how many characters in the layer(When you use html: "something something").

So you can apply that value to many cases. Not a fancy prototype, but this is so userful! :)


Eelco Lempsink

Ha, clever! It will start to become a bit less precise if you add HTML tags, because those will be added to the character count too. If you want to be more exact, there’s a hidden utility method (consider it ‘beta’ quality) that will calculate the size of a piece of HTML. As a second argument (not demonstrated in my prototype) you can pass it a dictionary with styles (such as font, font size, etc.)

JinJu Jang

Aha, Utils.textSize(string) & Utils.frameInset(string, padding?) makes the same effect when you apply some inline styling. Nice one!

Read the entire post on Facebook