Dotted or dashed lines can be a great design element and easy to achieve with a bit of CSS, but creating a lot of them in Photoshop mockups can be time consuming and frustrating. There are 3 simple ways to create dotted or dashed lines in Photoshop. The first one is the way a lot of people probably do it and that’s by doing it with the pencil tool dot by dot and then duplicating the layer. This is slow but there are ways to speed up the process. The 2nd method is achieved by using the brush palette spacing settings. The 3rd method is uses custom patterns. This tutorial will cover all three methods with the Mac/Windows shortcut keys needed to speed up the process.
Method 1: Dot by dot
The dot by dot method is exactly as it sounds, grab a brush and draw your line out. Depending on your layout this could take forever and end up being less than perfect if you make a mistake. A quick way to speed up the process is by duplicating and merging the layers as you go.
Start with a blank canvas of 500×500 pixels. Go to your layers window and create a new layer. Now zoom in about 500% and create two horizontal dashes or dots with the pen tool ( b ). Once you have completed this switch to the move tool (v). Now drag your two dots while holding down the ( alt ) key, this will turn your move tool into a double arrow which means you are duplicating the layer. As you drag the layer line it up so the spacing is correct with the previous two dots. You should now have 4 dots/dashes. Once you have lined them up merge them ( command/control e ). Now repeat the whole process again, each time you will double the length of your dotted/dashed line. If you use this method, although clunky, you can created many lines very quickly and then trim them to your desired size with the marquee tool. If you need a vertical line all you have to do is rotate ( command/control t ) the layer while holding the ( shift ) key to get a perfectly straight vertical line.
Need to change the colour? No problem, select the dashed/dotted lines layer in your layers palette and click “Lock transparent pixels”. Now select your brush tool ( b ) and increase the size ( ] ) to a large enough brush to paint over the dots/dashes quickly. Select the colour you wish to use and scribble over top of your lines.
This method while not overly eloquent is often the easiest method for a quick dashed line. If you need to use many dotted/dashed lines you might want to look at one of the other methods below.
Method 2: Brush palette
The brush method is fairly fast. Create a new 500×500 pixel canvas. Open your brushes ( F5 ) palette and select the 1 px brush. Uncheck Shape Dynamices, then select Brush Tip Shape. Slide the Spacing slider to the far right and then hold shift while drawing a line. You should have a perfect dotted line.
You can mess around with the spacing and roundness options, but there is only so much you can do with the default brushes, if you use rounded brushes are will get rounded dots, which may or may not be what you want. If you need larger dashes you can create your own brush. Say you want a 10×8 dash, all you have to do is created a 10×8 square dash and crop the canvas to that size. A quick way is to trim the document in the image menu. ( Image -> Trim… and select ok ).
Once you have your brush ready go to the edit menu and define a brush. ( Edit -> Define Brush Preset… ). Name it can click ok. When you return to the brushes menu it should be selected. Now if you apply the spacing settings to this brush you should have a much thicker dashed line.
The brush method is probably one of the most robust methods for creating dotted/dashed lines in photoshop.
Method 3: Pattern palette
The pattern method is similar in some ways to the brush method. This is by far the most complex of the 3 methods, but if you plan on changing the size of dotted boxes a lot then this method is the most flexible. When I create Photoshop mockups for web, I use a lot of layer shapes for sidebars, boxes, headers and what not and constantly nudge them into place with the arrow keys and the direct selection tool. With this method you will apply a pattern via the styles to a shape layer and then work with the vector mask to only show the edges of the pattern. Once completed you will now have a dotted or dashed line that you can move and nudge with the direct selection tool as much as you like without ever worrying about recreating the dotted lines again.
For this example we will create a 1 pixel dotted line, but this will work with thicker lines too. Create a new 2×2 document, add a new layer to it and hide the background layer so the image is completely transparent. Now put one pixel in the top left corner. Your document should look like the zoomed in example to the left. If you were to create a 3 pixel dash, your document would be 6×6 with a 3 pixel black box in the top left corner.
Now go to the edit menu and define a pattern. ( Edit -> Define Pattern… ). You are ready to create your box shape now. Create a large new document ( command/control N ) to play around with. Select the rectangle tool ( u ) and create a rectangular shape.
Now select the newly created shape and reduce it’s fill to 0%. The difference between Opacity and Fill is that Fill will hide the shape but not the Blending Options that you will be applying next. You can leave this a solid colour too, but make sure it’s not the same colour as your pattern, otherwise you will not see the dotted line. Now right click your new shape layer and select Blending Options…
In the blending options click Pattern Overlay and then select your pattern in the Pattern: section. Your pattern should be the last one added. Click OK.
Now you should have a box full of 1 pixel dots. Select the shape tool again ( u ) and make sure Shape layers and Subtract from shape area are selected in the toolbar as shown below.
Now select the Vector mask of your shape in the layers palette and draw a mask over your shape. The key here is to draw it right to the edges. You can use the Direct Selection Tool ( a ) to tweak your anchor points.
You should now have a nice box with dotted lines like the one to the right. You can continue to use the Direct Selection Tool by selecting the entire edge of the shape to manipulate this rectangle without worrying about the borders again. If you wanted the border only on one side then you would manipulate the inner vector mask so that it covered the top, right and bottom sides of the rectangle.
Although this method is more time consuming than the first two, it’s also very powerful if you are going to have a lot of dotted or dashed boxes in several layouts. Now you can just duplicate this one over and over and resize it without worrying about re-drawing the dots/dashes. As mentioned this can also be used for straight lines, just make sure the other sides of the rectangle are masked. Remember that the pattern is the colour of your border, so if you want a different colour you need to change the pattern colour.
If you have other tips on how to achieve the same examples as above with different methods, I would love to hear about them in the comments below.