Components

Components are rectangular regions on the canvas that link to different Skala documents. They’re typically for reusing identical or similar portions of artwork. For example, components are handy way to have multiple instances of a button, with a single place to edit how the base button looks.

Rather than a giant document containing everything, Skala breaks components into separate files, making larger projects and libraries easier to manage. Components can even be shared between projects, if you’d like. Skala works in a way that probably matches how your team is already structuring code.

A single component can handle many states and permutations, all controlled via constants. Put simply, a slider can control the length of a progress bar component.

Components can contain other components, so a toolbar component can be built from button components.

Creating components #

The quickest way to make a component is from artwork you’ve already drawn. Select the layers you’d like to turn into a component, then choose Layer › Create Component. You’ll be asked where to save the new Skala document. The selected layers are moved into the new document, which is sized to fit them, and replaced by a single component layer named after the new document. It can all be undone in one step.

Components can also be added using the component tool (C). Drag on the canvas to create a component layer, then click Set in the component properties tab to choose which Skala document it shows. Choosing File › Insert Component (⌘I) lets you pick one or more Skala documents to insert directly. They’re placed in the center of the visible canvas.

Components are linked relative to the location of the document they’re placed in, so the document needs to be saved before a component can be added. If a document is untitled, clicking Set or choosing Insert Component will ask you to save it first.

Further reading: Project structure

Component properties #

When a component layer is selected, the component properties tab is shown. The top row contains the layer’s position, size, rotation, and shear, along with flip and rotate buttons, as well as opacity and blending options.

  • Path shows the location of the linked Skala document, relative to the current document. Click Set to choose a different document.
  • Reset Dimensions sets the layer to the size of the linked document.
  • Page sets which page of the linked document is shown. Pages are listed by name, and First Page is the default.
  • Fitting sets how the linked page fits within the component layer’s bounds. Native lays the page out at the size of the bounds, without scaling it (the default). Fill stretches it to fill the bounds. Contain scales it to fit inside the bounds while keeping its aspect ratio. Cover scales it to fill the bounds while keeping its aspect ratio, cropping anything that doesn’t fit. See components and resizing for more.
  • Guides sets whether the linked document’s guides are shown. None hides them, Clipped shows them within the component’s bounds, and Full shows them in their entirety.
  • Edit Component opens the linked document, so you can edit it. Layer › Edit Component (⌘U) does the same.

The component properties tab also includes a table listing the constants of the linked document. Changing a value in the table overrides that constant for this component only. Click Reset to stop overriding a constant, so it follows the linked document again.

Components and resizing #

A component layer can be any size, and the Fitting option controls what happens to the linked page when the layer is resized. There are two approaches: laying the page out again at the new size, or scaling it.

Native lays the page out again. The component’s size is passed to the linked document as its canvas size, so the built-in w and h constants inside the component return the size of the component layer.

Fill, Contain, and Cover scale the page. The linked document keeps its own canvas size, so w and h don’t change, and the whole page is scaled to suit the layer, like scaling an image.

Updating components #

Skala watches linked component documents for changes. When a linked document is saved, the components that use it are updated automatically, including components inside other components.