# Auto Layout

**Auto Layout** automatically arranges a group of components without overlaps, and let’s you specify the spacing between them. This is a convenient way of creating cut files with components that change in size as you customize the project, and it saves you from having to manually reposition the parts.

## How to use it

We’ll use this layered gift tag as an example.

![](https://cuttle-content.imgix.net/learn/auto-layout/32011af178f8fa2eba4dda15df8888d980fd1881d4588babbca4eb6ab79d0682.jpg?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

The tag has 3 different components: `Name`, `Backer` and `Outline`

![](https://cuttle-content.imgix.net/learn/auto-layout/81c074a2d1999c9440a007c1f4c256ade564dc75114bceb9924d2b32a37cf70e.jpg?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

Start by creating a new component (usually called `Cut`), now go to to the search bar, type “auto layout”, and you’ll find it in the Advanced section, then drag it to the center of the canvas.

![](https://content.cuttle.xyz/learn/auto-layout/3ce4dede082ff8f9bd609a54327b090f31c550fdbfecb64af34fc52bfdcacc98.gif)

As a default Auto Layout will have a list of pieces including Circle, Rectangle, Polygon and Star.

![](https://cuttle-content.imgix.net/learn/auto-layout/653fd3ede8bfcd7b7e2c24ce3091c433803cdca15c2ed9e49b55a88aa53947f3.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

Notice that in the `pieces` parameter rows of elements are organized inside square brackets and everything is separated by commas. So `[Circle, Rentangle]` corresponds to the first row, and `[Polygon, Star]` to the second row.

For the layered tag example we can organize the `Name`, `Backer` and `Outline` components in a single column with this expression:

\[ Name, Backer, Outline, \]

![](https://cuttle-content.imgix.net/learn/auto-layout/b2c2dbb0ae3243939de94345f52417d278bde9184ce9e228023304c587f2b156.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

But you can always use square brackets to organize the components in other ways, for example with the `Name` in a row and the `Backer` and `Outline` components in a separate row defined by the square brackets.

\[ Name, \[Backer,Outline\], \]

![](https://cuttle-content.imgix.net/learn/auto-layout/67ece0d22e9af482fb87ea0a80ffa8a02f28ad50c1d3c2692e6376188ae80bf6.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

When the size of the name and tags changes, Auto Layout will space the components accordingly.

![](https://content.cuttle.xyz/learn/auto-layout/ec4d4ff32d80c3010cbe61b2507d830ebe7ec9a420e96e5b10ff8171ee67b625.gif)

## Transforming Auto Layout elements

You can use the `.transform` method inside Auto Layout, for example if you need to rotate or scale any of the elements (read more about other transformations in [Scripting Fundamentals](https://cuttle.xyz/learn/scripting-fundamentals)).

For example, to rotate the `Backer` by 90 degrees we can use this expression.

Backer().transform({rotation: 90})

Here it is inside Auto Layout with both `Backer` and `Outline` rotated by 90 degrees.

\[ Name, \[ Backer().transform({rotation: 90}), Outline().transform({rotation: 90}), \] \]

![](https://cuttle-content.imgix.net/learn/auto-layout/6edad271acd43731b4c7b082b9ed11809bbb5fe80be79ac17f2438630200d48d.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

## Modifying Component Parameters

It’s also possible to change the value of component parameters within Auto Layout. For example the `Polygon` component in Cuttle has a parameter that specifies the number of sides. So we can call different instances of `Polygon` with different parameter values.

\[ Polygon({sides:3}), Polygon({sides:6}), Polygon({sides:9}), \]

![](https://cuttle-content.imgix.net/learn/auto-layout/44e4bbcaf7d11c4566fb94af143171286151dfeb4e9e19bf2964cd3392bb2c4e.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

And this applies to any component you create that has Component Parameters. Here is an example with a simple `Keychain` component that adds a hole to some connected text, and it has a Component Parameter called `name` . Each instance of the `Keychain` component gets a different name assigned to it.

\[ Keychain({name:"Maria"}), Keychain({name:"Rose"}), Keychain({name:"Eduardo"}), \]

![](https://cuttle-content.imgix.net/learn/auto-layout/4828890d74a0502dba93537c23f465be6148ddf34242b24f1b1d9013b6a63487.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

## Creating a bulk production option with Auto Layout

Many of Cuttle’s templates have a bulk production feature where you can type multiple names and instantly generate a cut file in one go. For example the [Layered Keychain](https://cuttle.xyz/@cuttle/Layered-Keychain-raPMzJ6Otltm), [Reindeer Ornament](https://cuttle.xyz/@cuttle/Reindeer-Ornament-9ebM5o7VrZlF) , and [Stocking Tags](https://cuttle.xyz/@cuttle/Stocking-Tags-7pAoHPuvL0YT) templates.

Here is one way to implement this feature:

1.  You need to start with a component that has a Component Parameter, like the `Keychain` component from the previous example. One way to test things are working is to use it inside **Auto Layout** with a basic expression where we assign a value to the parameter `name` .
    
    \[ Keychain({name:"Maria"}), Keychain({name:"Rose"}), \]
    
    ![](https://cuttle-content.imgix.net/learn/auto-layout/ca865be6d02f83d4d62747e678eda90b3c694e51db8ac5c7bf6882958275892a.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)
    
2.  Now we can create a new component called `Bulk` with a component parameter called `names` , change the parameter type of this component to be **Text** and type a list of names separated by newlines (that is, press enter after typing each name).
    
    ![](https://cuttle-content.imgix.net/learn/auto-layout/d805c1979b578d435210f1e8417cca42758690d9c0f9169f19a64fc35599a8b6.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)
    
3.  Create an additional parameter called `namesList` and use the following expression.
    
    names.split("\\n")
    
    ![](https://cuttle-content.imgix.net/learn/auto-layout/c503fdd01f43ad3bde7755bb414b2745ac910093f783c08e2b34f76c230b6fbf.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)
    
    This turns the `names` parameter into a comma separated list of strings, using the newline `\n` as the point of separation.
    
4.  Now to map the `namesList` onto the `Keychain` component we can use this expression inside Auto Layout.
    
    \[ \[namesList.map(name =>Keychain({name}))\] \]
    
    ![](https://cuttle-content.imgix.net/learn/auto-layout/ccbf2d5d00e5cd45034454f98d2ae30d4e3be2f1f2365c372305fe4759006428.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)
    
    This effectively loops over each element of the `namesList` array, and applies it to the `Keychain` `name` parameter, then returns a new array containing the results.
    

Watch this video has a more detailed walk through and explanation of the process

[YouTube video](https://www.youtube.com/watch?v=It_opBaW68c)