Create Advanced Adaptive Buttons Using Layers In Sketch

Travis Folck
Jan 7, 2019 · 8 min read

Note: With Sketch 58, this method is no longer needed. Check out my new article on how to easily create adaptive buttons using Sketch’s Smart Layout.

This is the second method for creating adaptive buttons in Sketch. Be sure to check out the first method: Create Adaptive Buttons Using Combined Shapes In Sketch.

This method allows you to create adaptive buttons with a drop shadow, ability to change the button surface color and text color; even when nested in other symbols.

This method allows adaptive solid buttons with optional drop shadow

⬇︎ Download Sketch File

As mentioned in the Combined Shapes article, symbol dimensions do not respond to text length. Thus, solid button dimensions do not adapt to their override text length. Let’s fix that.

Introducing the Layer Method

How this method works

This method uses a layer to hide the solid button’s surface color. The layer is the same color as the surface that the buttons resize on.

Step-by-step instructions

Tip: To make the button respond to override text length, we’ll be using the method described in: Create an Adaptive Sketch Symbol for Material Design’s Outlined Text Field.

Create the symbol

  • Symbol name: Button Row — Solid and Text/Left Aligned — No Shadow
  • Width: 140
  • Height: 36

Add the surface layer

Add a new rectangle shape:

  • Layer name: Solid Button Color
  • Width: 500
  • Height: 36
  • Radius: 4;0;0;4 (for the left-side rounded corners)
  • Color: 2E73E7 (or any color)

Tip: If you create a layer style, you’ll be able to change the button color when it’s nested in a symbol.

Add text for the solid button

Add a text layer above the surface layer:

  • Layer name: Solid Button Text (this will be the name in the override)
  • Pin to edge: left
  • Fixed size: Height
  • Font: Roboto
  • Size:14
  • Weight: Medium
  • Color: White, 87% opacity
  • Line: 36
  • Alignment: Left
  • Text Transform: Upper case (optional)
  • Text: OK

Tip: The override text will push neighboring layers, revealing the surface color as the text lentgh grows. Line height is used to increase the text height. Check out this post for more information on adaptable text.

Add the surface overlay layer

Add a rectangle layer:

  • Name: Solid Button Overlay
  • X: 42 (immediately after the text layer)
  • Width: 458
  • Height: 36

Tip: To maximum flexibility, consider applying a layer style to this layer. This will allow you to change the color to match the the color behind the button.

Complete the solid button

Above Solid Button Overlay, add a new rectangle layer:

  • Layer name: Cutout
  • X: 42 (Note: it should not overlap the surface layer.
  • Width: 9
  • Height: 36
  • Radius: 0;4;4;0
  • Fixed size: horizontal

Combine Shapes

  • Combined shape layer name: Solid Button Overlay
  • Fixed size: horizontal

Test your progress

If you used a layer style for the color, the button surface color can also be changed in the Solid Button Color layer.

Add the text button

  • Layer name: Text Button Text
  • Fixed size: Height
  • Font: Roboto
  • Size:14
  • Weight: Medium
  • Color: Black, 87% opacity
  • Line: 36
  • Alignment: Left
  • Text Transform: Upper case (optional)
  • Text: Cancel

Add the mask

Add a new rectangle layer as the last layer and give it the dimensions of the art board:

  • Layer name: Button Row Mask
  • Width: 140
  • Height: 36
  • Pin: all sides

Test your progress


If you have been following these steps, you should have a fully functioning button row with a solid button (without a shadow) and a text-only button. You can use the symbol by itself and add it to other symbols.

If you only need adaptable buttons without a drop shadow, you can stop here. But why stop here? Let’s create a version with a drop shadow.


About adding a drop shadow

We’ll duplicate the button symbol we just created and slightly modify it.

Copy the button row symbol

Button Row — Solid and Text/Left Aligned — With Shadow

Resize mask layer

Resize and reposition Button Row Mask:

  • Width: 142
  • Height: 42
  • X: -2
  • Y: -3

Add button shadow

  • Layer name: Solid Button Shadow
  • Width: 500
  • Height: 36
  • Radius: 4;0;0;4
  • Fix size: Horizontal
  • Fill: Any color; 0% opacity
  • Shadow 1: #000000 12% opacity; blur: 2
  • Shadow 2: #000000 24% opacity; blur: 2

Mask the shadow

Expand the Solid Button Overlay layer, select the Solid Button Overlay layer within and change Y coordinate and height to:

  • Y: -2
  • Height: 41

Add the right-side shadow

Above Solid Button Text layer, add a new rectangle:

  • Layer name: Solid Button Right Side
  • Width: 16
  • Height: 36
  • X: 35
  • Radius: 0;4;4;0
  • Fix size: width
  • Fills: Any color; 0% opacity
  • Shadow 1: #000000 12% opacity; blur: 6
  • Shadow 2: #000000 24% opacity; blur: 2

Mask the right-side shadow

Above Solid Button Text, create a new rectangle layer:

  • Layer name: Solid Button Right Side Shadow Mask
  • Width: 11
  • Height: 41
  • X: 42
  • Y: -2
  • Fix size: horizontal

Done!

This method can be used anywhere you need to make adaptive solid-color shapes. I’d love to hear how you’ve used this method to solve some of your challenges in Sketch. Drop a comment below!

⬇︎ Download Sketch File


Design + Sketch

The best collection of articles, tips, tutorials, and…

Travis Folck

Written by

I love technology and design. I find great satisfaction when they come together to create a great experience.

Design + Sketch

The best collection of articles, tips, tutorials, and stories on designing and prototyping with Sketch and beyond

Travis Folck

Written by

I love technology and design. I find great satisfaction when they come together to create a great experience.

Design + Sketch

The best collection of articles, tips, tutorials, and stories on designing and prototyping with Sketch and beyond

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight.
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox.
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store