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

What is Framer? Join the Community
Return to index
Jason Lang
Posted Aug 10 - Read on Facebook

Question:

I'm trying to create something that has dynamic text content, which I'm inserting in to a layer via layer.html.

Is there a way that the width of the layer can dynamically adjust to the content inside of it?

9 Comments

Alexandre Lordelo

Hi Jason Lang, searching the forum archives I found your post!

I'm looking to do something similar, but instead I need the text to be dynamically adjusted (spacing), according to the width of the text box.

Do you believe it's possible to do this?
https://gyazo.com/8b405c2536eb60da697301e58b42a106

Mike Feldstein

Do you need the background color the layer?

Jason Lang

Nope I can easily set that color, just want the shape to expand or contract to fit the HTML content.

Mike Feldstein

there's no super clean way that I know of to do this, though i hear murmurings of better solutions. A hack can be found here: http://share.framerjs.com/izh5zujyn1nn/ I style the background color onto the child html element itself, and take the background off of the framer layer.

My first approach was to watch the change:html event, and change the size of the layer based on the new value of the child, but i couldn't quite get that to work. I left the code in because the change:property events are a really cool thing people often don't know about yet.

Jason Lang

Yea I'm attempting to use framer for something it's not entirely meant for. I have everything working in html, CSS, and some mustache templates. I was toying with doing some layout in framer and then injecting some text via HTML. Basically looking for an HTML box model type situation.

Jordan Robert Dobson

May the source be with you.

Mike Feldstein

oh wait Layer.style ={width: "auto"}

Calvin Wilson

Excellent!

Read the entire post on Facebook