User Manual Quickstart General Concepts Buyer Side Snippets Styles and Form Fields Children’s Book Pin to Frame Conditional Styles Flex Designs Sub Documents Scripting Print Workflow Tutorial Videos Frame Features Resources Style Reference Change Log Glossary Acknowledgements Api Reference Authorization Iframe Api Js Api Backend Api

Styles and Form Fields

Wherever one wants to control color, appearance or content via form fields or logic, Styles are a powerful option to use.
Basically, every aspect of a Frame can be controlled with Styles. Since one Frame can use several Styles, you can solve pretty complex problems with them.

Another good use for Styles are documents where one would like to change the appearance of several Frames at once.

Each Frame can have one or more Styles applied.

Children’s Book

Let’s have a look at a children’s book example, where all the complex personalization options for selectable hair and skin color are built with just a few simple Styles.

(Please try it yourself here)

Childbook Styles Example

We have switched on Show Styles in the top menu bar Settings menu to present us with small colored badges that show us the various Style names. (See how its done!)

As one can see, eyebrows and hairdo have the Style ‘hair’ assigned and all skin elements have the Style ‘skin’. (See how Styles are assigned!)

Looking into the Styles tab, we can see that both styles set the fillColor and are connected to a form field via the so called “literal”.

A literal starts with ‘${’ and ends with ‘}’. In the literal you can access form field values and as we’ll see later, also do some handy calculations.

But in this case its pretty easy… fillColor:${form.SkinColor}; simply sets the fill color of all skin elements to the color selected in the form field. Lets have a look at what the form field looks like:

Childbook Skin Form Field

The form field User Interface is set to Image-List, creating a selection of nice color patches from small images. The Value of the form field is simply a color value (could be also one of your pre-existing named color swatches).

So whenever the Buyer selects one of the available skin colors the applied Style will make sure that everywhere where there are skin portions in the document the skin color changes.

This even works (as long as a Template Style is used) in Sub Documents. In this children’s book, everywhere where the hair is used a Sub Document containing the hair in different Styles is also used.

Lets have a look at this document. It’s a document containing separate pages for each hairstyle. For each page the spreadName has been set to the name of the hairstyle (Hair short, Hair very short, …).

.hair {   
 	fillColor: ${form.HairColor}; 

Each hairstyle shape also has the Style ‘hair’ assigned, which in this case will set the fill color for the hair (fillColor: ${form.HairColor};).

Childbook Hair Subdoc

The same Style is also assigned to all places where this ‘Hair’ Sub Document is used in the children’s book (have a look above). In this example, the Style Property spreadName (spreadName: ${form.HairColor};) comes additionally into effect by choosing the right page from the Sub Document to show the selected hairstyle.

In this case the form field to control the Styles spreadName property simply has the names of the pages in its values and looks like this:

Childbook Hair Form Field

Not only can properties like color be controlled via Styles but also content like a text or an image can be changed by a Style. Throughout this document the name of the child is also populated through a Style.

Childbook Hair Subdoc

Because we use a Style to set the text for each Frame with the Style ‘name’ assigned, the input field for the text is also disabled and the name of the Style which controls it is displayed above.

Adding the ‘Pajama’ Style and form field, which pretty much works the same as the skin color, we get an easy to use user interface and a simple to maintain yet feature rich personalizable document.

Pin to Frame

A nice use of form fields in conjunction with styles are Pinned Form Fields. Lets create an example where we control the colorization of an image frame by a form field which only appears once the buyer clicks on the image.

Start by creating an image frame with any image. use sepia (100) to colorize it monochromatic. Next create yourself a Document form field named ‘HueRotate’ and set it to a number value list. Make sure you create a Document type Form Field as Template Form Fields don’t have this option. Now enter the samll value list and the corresponding labels by selecting the small + on top left of the table.

Hue Rotate Form Field

Now we will connect it to the Frame, by selecting the image frame and then selecting Pin to Frame in the Form Fields context menu:

Pin to Form Field

A small pin will appear on top of the form field to indicate that its pinned to a frame.
Pin to Form Field

If you like you can test drive that the form filed only appears when the image frame is selected by switching to the buyer side.

Next we will connect the form field and the image frame by using a style. open the styles tab and create yourself a simple document style as follows:

.hueRotate {
	hueRotate: ${form.HueRotate};

This will now change the color angle of the image based on the users selection in the drop down. Now go to the buyer side to proudly test your creation.

Hue Rotate Form Field

Conditional Styles

Conditional Styles are useful in cases where one would like to create Styles which only come into effect at the moment a condition is met.

A Conditional Style contains an if: statement followed by a Boolean statement in the first line of the Style:

.inside-image {  
 	if: ${1 === 1};  
  	property1: value;  
  	propertyx: value;  

A good example for conditional Styles is switching Frame positions and sizes based on document formats where a Flex Design is pushed to its limits e.g. changing between landscape and portrait formats.

Let us have a look into the Calendar Grid Style Demo document. It has two different aspect ratios controlled by a DOCUMENT_SIZE form field. (Learn more about changing document size with form fields.)


Now we create Conditional Styles which control the position and size of the main image in the calendar. As one can see, we used only percentage values which will keep the document size flexible even as we change dimensions.

.inside-image { 
  	if: ${info.DOCUMENT_SIZE === "A4"};  
	left: 0%; 
 	width: 100%; 
 	top: 0%; 
.inside-image {  
 	if: ${info.DOCUMENT_SIZE === "DESK"};  
  	left: 0%;  
  	width: 50%;  
  	top: 0%;  

This is how the calendar looks if the DOCUMENT_SIZE form field is switched to A4:

Calendar A4

And this is how it looks when switched to DESK:

Calendar DESK

Another use case of Conditional Styles is switching visibility of certain Frames in a document. In the Style example below, the ‘hide’ Style is assigned a Frame that will only be visible if the form field ‘hide’ is set to ‘Show’.

.hide { 
 	visible: ${form.hide === "Show"}; 

With the same method one could control drop shadows, effects and essentially every other aspect of a Frame. To discover more examples we strongly recommend to use the Style Wizard which will create Frames, Styles and their corresponding form fields. Our Style Wizard is a great way to have fun learning about the superpowers of Styles.
(Start using the Style Wizard)

Additionally, we recommend exploring the available Style properties in the comprehensive Style Reference Manual. (Overview on all available Style properties)