Discover how to create and manage reusable elements in Sketch, control symbol overrides, and define custom data sources for text and images for rapid prototyping in our comprehensive tutorial.
This exercise is excerpted from Noble Desktop’s past web design training materials and is compatible with Sketch updates through 2021. Noble Desktop now teaches Figma as the primary tool for web and UX & UI design. To learn current skills in web design, check out our Figma Bootcamp and graphic design classes in NYC and live online.
Note: These materials are provided to give prospective students a sense of how we structure our class exercises and supplementary materials. During the course, you will get access to the accompanying class files, live instructor demonstrations, and hands-on instruction.
Topics covered in this Sketch tutorial:
Controlling Symbol Overrides, Overriding Images Within a Symbol, Custom Data Sources, Masks vs. Image Fills
Exercise Preview
Exercise Overview
Symbols let you create reusable elements which can be globally updated, yet at the same time have customized content for each instance. In this exercise you’ll see how to define custom data sources for text and images, which you can use to populate content into multiple instances quickly! This allows for rapid prototyping.
Getting Started
- In Sketch, go to File > Open Local Document.
- Navigate into Desktop > Class Files > Sketch Class > Pulse and double–click on Symbol Overrides.sketch to open it.
-
On the Autumn Collection artboard we have created the content we need for each product. Select the following items:
- photo
- Product
- Price
- Add to Bag button
- In the Toolbar, click the Create Symbol button (or choose Layer > Create Symbol).
-
In the dialog that appears:
- Name it Product
- Set the menu below the name to Top to Bottom Layout.
- Check on Send Symbol to “Symbols” Page.
- Click Create.
- We need 4 products (in a 2 by 2 grid). Go into the Arrange menu and choose Make Grid.
-
In the Inspector, set the following:
- Cells: 2 and 2
- Spacing: 15 and 30
Click Finish when done.
-
The top left instance of our new Product symbol should still be selected. In the Inspector on the right, notice:
- There’s an option to override the text in Add to Bag. We’d never want to do that, so we’ll be removing this option shortly.
- There’s an option to override the photo, which we’ll look at in a moment.
- The Price override is above Product in the Inspector, which is the opposite order found in our layout. It would be nice if the Inspector’s order matched the layout.
Controlling Symbol Overrides
- With the symbol’s instance still selected, hit Return to edit the symbol (you could also double–click on it, as long as you aren’t double–clicking on text).
- The symbol’s artboard should already be selected, so in the Inspector on the right, find the Manage Overrides section.
- Under Add to Bag, uncheck Text Value.
- The top to bottom layer order affects the order that overrides appear in the Inspector. In the Sidebar on the left, drag Price down below Product.
- At the top left of the canvas, click the Back to Instance button.
-
In the Inspector, notice two things:
- You should no longer see an override for Add to Bag (which is good because we don’t want that to change).
- The top to bottom order of the overrides for Photo, Product, and Price now match the visual order on the artboard. This will be more intuitive when we’re customizing their content.
- Select all 4 products on the artboard (drag a selection over them).
- In the Inspector on the right, under Price type $79 and hit Return to apply it.
- Click somewhere outside the artboard so nothing is selected.
- On the canvas select the top right product.
In the Inspector on the right, change the Price to $89 and hit Return to apply it.
Overriding an Image Within a Symbol
- Click once on the top left product to select that instance of the symbol.
- In the Inspector, under Photo click Choose Image.
-
Navigate into Desktop > Class Files > Sketch Class > Pulse > Clothing Photos - Women and double–click on blue-top.jpg to choose it.
NOTE: Unfortunately we cannot change the size, cropping, or position of the image within its mask. So this technique is useful for rapid prototyping and preliminary design, but it’s not suitable for image production. That is often best done in Photoshop anyway once you know how large the photos need to be, or some content management system (CMS) will do that part as well.
Data Sources for Text & Images
- Let’s add some product names, but we don’t want to do it manually. Select all 4 products on the artboard (drag a selection over them).
-
In the Inspector on the right, to the right of Product, click on the Override with Data button and from the menu choose Sketch Data > Names.
-
Notice in the canvas that we now have random people’s names instead of product names.
Sketch only includes a couple examples of custom data, but we can define our own by making a plain text file (.txt) with one piece of data on each line of text. We’ve already made a text file with our product names.
- To define our own data source, go into the Sketch menu and choose Preferences.
- Switch to the Data tab.
- At the bottom click Add Data.
- Navigate to Desktop > Class Files > Sketch Class > Pulse and double–click on Clothing Titles - Women.txt to choose it.
- Close the preferences window.
-
In the Inspector on the right, to the right of Product, click on the Override with Data button and:
- Uncheck Insert Data at Random.
- In the menu choose Clothing Titles - Women.
This is better because it’s now the proper kind of content.
- Click somewhere outside the artboard so nothing is selected.
-
In the top left product, double–click on the product placeholder name and type in Denim Jacket.
NOTE: There’s no difference between typing overrides directly on the artboard and the Inspector on the right.
- Select all 4 products on the artboard (drag a selection over them).
-
In the Inspector on the right, to the right of Photo, click on the Override with Data button and choose Unsplash > Search Photo.
NOTE: Unsplash offers free photos for commercial use. Sketch has integrated a search that will download the images without even having to go to their website! This can be great for placeholder images until you get the final artwork from a client.
-
In the dialog that appears, type in ladies fashion and click OK.
- Give it time to download the images, which can take some time depending on your internet speed.
- After it’s done, you may notice some of the images have been stretched or squished. This happens if they do not match your symbol image’s aspect ratio. For a better fit we could use a custom image data source (which we’ll see in a moment). Alternatively, we could fill a vector shape with the image instead of using a mask, so let’s see how to do that.
Switching From a Mask to an Image Fill
- Click somewhere outside the artboard so nothing is selected.
- Double–click on the photo of the top left product to edit the symbol.
- In the Sidebar on the left, expand the Product Photo group.
- Right–click (or Control–click) on the Mask layer and at the bottom of the menu choose Mask (to uncheck it).
- Above the Mask layer click on Photo.
- Hit the Delete key to delete it.
- Click on the Product Photo group.
- Hit Cmd–Shift–G to ungroup it (you could also choose Arrange > Ungroup or click the Ungroup button in the Toolbar).
- In the Sidebar double–click on Mask and rename it Photo.
- With the Photo shape still selected, in the Inspector under Fills, click on the color box to open the color picker.
- At the top of the color picker click the right-most icon for Pattern Fill .
- Below the top row of icons, if the Images section is collapsed, click the arrow at the far right to expand that section.
-
As shown below, in the Images section hover over the thumbnail and click the Choose Image button that appears.
- Navigate into Desktop > Class Files > Sketch Class > Pulse > Clothing Photos - Women and double–click on blue-top.jpg to choose it.
- Below the thumbnail set Type to Fill Image.
-
On the artboard you should see the image looking nice.
NOTE: One limitation of this technique is you cannot customize the crop, size, or position of the image… which you can’t do when customizing symbols anyway, so this will be fine for our use.
- At the top left of the canvas, click the Back to Instance button.
- Select all 4 products on the artboard (drag a selection over them).
- In the Inspector on the right, to the right of Photo, click on the Override with Data button and from the menu choose Unsplash > Search Photo.
- In the dialog that appears, type in ladies fashion and click OK.
Now the photos should not be distorted because they will automatically fill our shape regardless of their aspect ratio.
Custom Data Sources for Images
- Now let’s define a custom data source for our own images. Go into the Sketch menu and choose Preferences.
- Switch to the Data tab.
- At the bottom click Add Data.
- Navigate to Desktop > Class Files > Sketch Class > Pulse, select the folder Clothing Photos - Women and click Open to choose it.
- Close the preferences window.
-
With the 4 products still selected on the artboard, in the Inspector on the right, to the right of Photo, click on the Override with Data button and:
- Make sure Insert Data at Random is unchecked.
- In the menu choose Clothing Photos - Women.
Removing Custom Data Sources
We’re done with our data sources, so let’s remove them.
- Go into the Sketch menu and choose Preferences.
- Switch to the Data tab.
- Right–click (or Control–click) on Clothing Photos - Women and choose Remove “Clothing Photos - Women”.
- When it confirms, click Remove.
- Right–click (or Control–click) on Clothing Titles - Women and choose Remove “Clothing Titles - Women”.
- When it confirms, click Remove.
Close the preferences window.
Save the file and close it.