Learn To Create A Switch Button

Learn To Create A Switch Button

Switch style buttons seem to be popping up all over the internet just lately so in this tutorial I’ll be showing you how quick and easy it is to create a switch style button.

In Designing

What We’ll Be Creating

Learn How To Create A Switch Button

Lets Get Started…

Create a new document 800×600 pixels with any color background. Set your foreground color to #303030 and background color to #161616, then select the “Gradient Tool” (G) with a radial gradient.

Learn How To Create A Switch Button

Drag the gradient from the middle of the canvas outwards then apply the noise filter by going to “Filter > Noise > Add Noise”.

Learn How To Create A Switch Button

Your background should look something like this.

Learn How To Create A Switch Button

Creating The Switch Outer Circle

Select the “Ellipse Tool” (U) then select shape layers as your path type from the options bar at the top.

Learn How To Create A Switch Button

Drag out an ellipse onto the middle of the canvas then rename the new layer “Outer Circle”.

Quick Tip:

Holding down the Shift key while dragging the ellipse will ensure the ellipse is a fully circle

Learn How To Create A Switch Button

Once your happy with the size of the button add the following layer styles using the following settings.

Learn How To Create A Switch Button

Learn How To Create A Switch Button

Learn How To Create A Switch Button

You should have something like this.

Learn How To Create A Switch Button

Creating The Switch Indent

Duplicate the “Outer Circle Layer” then rename the duplicated layer “Switch Indent”. Right click the duplicated layer then select “Clear Layer Styles” from the menu. We now need to resize the “Switch Indent Layer”, so select the “Free Transform Tool” (Ctrl + T) then drag one of the corner anchor points inwards about 10-15 pixels.

Quick Tip:

Holding down the shift key and Alt key while dragging the ellipse will resize the ellipse from the middle opposed to from the anchor point you are resizing with

Learn How To Create A Switch Button

Now add a gradient overlay to the “Switch Indent Layer” using the settings below.

Learn How To Create A Switch Button

Learn How To Create A Switch Button

Creating The Switch

Duplicate the “Switch Indent Layer” then clear the layer styles by right clicking the layer and selecting “Clear Layer Styles”, at this point should also rename our duplicated layer to “Switch”. We now need to resize the “Switch Layer” by about 1-3 pixels, select the “Free Transform Tool” (Ctrl + T) then resize the ellipse.

Quick Tip:

Holding down the shift key and Alt key while dragging the ellipse will resize the ellipse from the middle opposed to from the anchor point you are resizing with

Learn How To Create A Switch Button

Now add a gradient overlay using the settings below.

Learn How To Create A Switch Button

You should have something like this.

Learn How To Create A Switch Button

Duplicate the “Switch Layer” then rename the duplicated layer to “Switch Main”. Clear the layer styles from the “Switch Main Layer” by right clicking and selecting “Clear Layer Styles”. We now need to resize the new layer only this time making it alot smaller and moving it up slightly.

Learn How To Create A Switch Button

Now add the following layer styles to the “Switch Main Layer” using the settings below.

Learn How To Create A Switch Button

Learn How To Create A Switch Button

You should have something like this.

Learn How To Create A Switch Button

Adding Some Switch Detail

Duplicate the “Switch Main Layer” then clear the layer styles, rename the layer to “Switch Shadow” then drag the layer underneath the “Switch Main” layer. Blur the layer by selecting “Filter > Blur > Guassian Blur” using the settings below.

Learn How To Create A Switch Button

Learn How To Create A Switch Button

Using the “Arial Font” create two letters on separate layers, the letters being “I” and “O”. Place the two letters onto the button.

Learn How To Create A Switch Button

Using the “Text Tool” (T) add the words on and off at the top and bottom of the button.

Learn How To Create A Switch Button

Now add the following layer styles to the two text layers.

Learn How To Create A Switch Button

Learn How To Create A Switch Button

Finally you should have something like this.

Learn How To Create A Switch Button

Additional Steps – Turn The Button Into A Working CSS Sprite

If you would like to use this button as a real button on your website then you can follow the next few steps provided.

The first thing you need to do is duplicate the button and create an “On” and “Off” state.

Learn How To Create A Switch Button

Once you have your on and off states we need to turn the two states into a sprite and do this by making a selection around one of the buttons. Try and get as close to the button as you can.

Learn How To Create A Switch Button

Once the selection has been made hide all your layers apart from the button layers you have selected, now go to “Edit > Copy Merged” (Shift + Ctrl + C). Now that the button is copied to the clipboard go to “File > New” (Ctrl + N) the dimensions of the element copied to the clipboard should already be inputted into the dimension boxes. Paste the element onto the canvas with a transparent background.

Learn How To Create A Switch Button

We now need to adjust the canvas height to double the height of the pasted element, doing this will allow us to fit two buttons onto the canvas. To adjust the canvas go to “Image > Canvas Size”.

Learn How To Create A Switch Button

Learn How To Create A Switch Button

Copy and paste the 2nd state of the button onto the new canvas in the same way as we did earlier.

Learn How To Create A Switch Button

Save the sprite as “Button.PNG” inside a new folder on your desktop.

The Button HTML/CSS

Setup a blank HTML file with your button.PNG file inside the directory. I’ve setup a my HTML file and it looks like this.

<body>

<div id="container">

<ul class="button">
<li><a href="http://www.photoshop-plus.co.uk" title="Launch Photoshop Plus">Launch Photoshop Plus</a></li>
</ul>

</div><!--container ends-->

</body>
body {
	background-color: #1a1a1a;
}

#container {
	margin: auto;
	height: 612px;
	width: 950px;
	background-image: url(images/background.gif);
	background-repeat: no-repeat;
}

I’ve basically just set my background as the HTML background and set the dimensions of the container which will hold my background and button. Inside the container I’ve created a simple list which we’ll use to show our button. The buttons CSS looks like this.

ul.button {
	margin-top: 250px;
	height: 114px;
	width: 72px;
	float: left;
	margin-left: 400px;
}

.button li {
	list-style-type: none;
	float: left;
}

.button li a {
	outline:none;
	display: block;
	text-indent: -9999px;
	background-image: url(images/button_sprite.png);
	background-repeat: no-repeat;
	background-position: left bottom;
	height: 114px;
	width: 72px;
	float: left;
}

.button li a:hover {
	background-image: url(images/button_sprite.png);
	background-repeat: no-repeat;
	background-position: left top;
}

Click Here to view the Demo.

Conclusion

Thanks for taking part in this tutorial, if you managed to finish this tutorial I’d love to see some of your results. Feel free to post them up on our Facebook Fan Page.

Learn How To Create A Switch Button

Download Source

License and Attribution:

This file is licensed under the Creative Commons license. Attribution is required and always appreciated. Thanks.

Download Freebie
  • Share
Auto Scroll To The Top
  1. April 14, 2011 at 4:18 PM

    Merci beaucoup pour ce tutoriel Photshop et les code HTML-CSS !
    Linda

  2. April 14, 2011 at 4:54 PM

    Hm, I don’t like the on/off text, because it looks somehow “cheap”, but the switch is really nice. :-)

  3. April 14, 2011 at 11:08 PM

    This is very poorly executed. The dimensions aren’t right on the button – the gradient that is supposed to make it appear to be lifted up goes in the wrong direction, and it actually just appears as if one circle is floating on top of another. In addition, in your demo, the css sprite has an error – its off vertically by about 2 pixels. It’s a great effort writing a tutorial like this, but it needs a little work.

  4. April 15, 2011 at 7:32 AM

    This looks gr8!
    What an idea to switch an option.
    Thanks!

  5. April 15, 2011 at 12:39 PM

    Super ce tuto ! Le button est très réaliste. Merci pour les codes (En attendant que j’arrive à perfectionner mes propres buttons :-))

  6. April 15, 2011 at 1:12 PM

    @Jenius:

    i dont think its poorly executed at all, after checking the demo i to have noticed that its off vertically but its easy fixed.

    thanks for all your comments.

  7. April 15, 2011 at 1:41 PM

    Good tutorials thanks for sharing
    i will try to do it by my own

    Joe

  8. psdude
    April 17, 2011 at 1:25 PM

    i agree with @Jenius it needs more detail and doesn’t look realistic

  9. April 18, 2011 at 6:39 AM

    Great tutorial and techniques well explained.
    Thanks for sharing…
    Bookmarked !!

  10. April 18, 2011 at 8:14 AM

    Unusual web button, thanks

  11. April 19, 2011 at 7:40 AM

    understood each step like anything, very nicely explained

  12. andrew
    April 25, 2011 at 12:59 PM

    Great, beautifuly done.
    But how should someone chose al those colors, for gradients, I mean how do you chose those colors to make it look more deep and more realistic or do you memorize all those hex codes?

  13. April 27, 2011 at 9:50 AM

    Nice result, very useful tut.

  14. May 9, 2011 at 7:44 AM

    Awesome end result This was a really interesting tutorial. Love the short step by step description, makes it a lot easier to understand. Very well done !

  15. S. Bala
    July 4, 2011 at 5:55 AM

    no words to explain my emotions…….. really excellent tutorials…. i like it too much.. thank you so much…….

  16. October 13, 2011 at 6:23 PM

    Nice tutorial also shared on my website

    :)

Give Us Your Feedback

Here on Photoshop Plus we use something called Gravatar, its a little image which will appear next to your name when you comment on a blog. Using a gravatar will help us recognise genuine comments from the spam comments.


Don't forget to leave a comment on this post, we appreciated your feedback good or bad.

There's currently 16 Comments On Learn To Create A Switch Button, why not add yours!