How can I create a slice-like area within a shape in Photoshop and apply a gradient to it. Here is an example - the black area:

enter image description here

I've tried to create one light grey shape and one black shape on a layer below and then subtracting a rectangular area from the top layer. However if I then apply a gradient to the black shape it starts at A and goes to C (in the background). I'd like the gradient to start at A and finish at B.

  • It kind of depends what you want to do with the black area. If it is just a black area, you might just want go to the blending options of the grey box shape and add a gradient where the top is black and the bottom is grey.
    – Joonas
    Commented May 9, 2012 at 7:16
  • Thanks for reply. I'd like to learn how to do it with shapes and/or paths - that way I could wireframe a layout and then work on the details including gradients.
    – user4485
    Commented May 9, 2012 at 7:29

1 Answer 1


Here’s how I’d build an element like that:

Clipping group

The Main shape with solid fill layer contains the main shape, including all the layer styles. The Gradient layer above is a rectangle with a gradient fill, and a clipping mask with the layer below. That means the fills of the layers are combined before being masked with the Main shape with solid fill's shape.

Note that Main shape with solid fill is a solid colour layer — that's important, because if you use a colour overlay layer style, gradient overlay layer style or pattern overlay layer style, they're rendered on top of everything in the clipping group. In this case I've included pattern overlay layer style that's providing some subtle noise.

The end result is that you can extend the Main shape with solid fill layer without having to worry about the gradient ever moving. It's a great way to work if you need to guarantee that a gradient ends at a certain point for iOS resizableImageWithCapInsets or Android 9-patch images.

Image shown is Photoshop CS6, but CS5 and prior versions work the same.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.