# Is there a way to draw 3D-style “buttons”?

I was wondering if there is a latex package to get pseudo-3D style "buttons" as are often seen on the web, or if not is there an easy way to draw them?

An example of what I mean:

-
You mean those 80x15px things? Maybe you could explain what use you have in mind? –  Carsten Thiel Dec 22 '10 at 12:52
What do you mean by WYSIWYM an by “web buttons” in this context? Like Carsten, I have problems understanding the question. –  Konrad Rudolph Dec 22 '10 at 14:01
I'd like to get something like that by using latex code and not a program like Inkscape... I can get similar buttons with the tikz picture but not with this shiny color effects.. –  Arianna Angeletti Dec 22 '10 at 16:38
Do you just want the shape, or do you want the interactivity as well? (That is, does a clicked-on button need to do anything?) –  Antal S-Z Dec 22 '10 at 18:11
shape, color shining and shadowing effects –  Arianna Angeletti Dec 22 '10 at 18:30
show 2 more comments

## 2 Answers

This is an example of a simple button created with tikz:

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[
button/.style={
rectangle,
minimum size=6mm,
very thick,
rounded corners,
draw=red!50!black!74,
top color=red!50!black!70,
bottom color=white,
}]
\node[button] (button) {A Button!};
\begin{scope}[opacity=.6, transparency group]
\draw[white,fill=white,rounded corners={2pt}] ($(button.north west) + (3pt,-3pt)$) rectangle ($(button.north east) + (-3pt,-8pt)$);
\draw[white,fill=white,rounded corners={.5pt}] ($(button.north west) + (3pt,-5pt)$) rectangle ($(button.north east) + (-3pt,-8pt)$);
\end{scope}
\draw[white,fill=white,opacity=.8,rounded corners={1pt}] ($(button.south west) + (5pt,2pt)$) rectangle ($(button.south east) + (-5pt,4pt)$);
\end{tikzpicture}
\end{document}


I then used pdfcrop to crop the file, and gimp to convert the pdf to png:

Basically you do the same you would do in Inkscape, except that you don't have very good support for things like fading etc, so it will be somewhat limited.

-
Thanks!This is exactly what I meant ;-) (I'll do some research on pdfcrop because I've never heard of it). Thanks again! –  Arianna Angeletti Dec 23 '10 at 12:00
@Arianna. This answer seems to solve your issue: please consider accepting it by choosing the 'tick' underneath the voting arrows. –  Joseph Wright Feb 2 '11 at 20:37
add comment

Here's a little playground for this inspirational question and answers (plain-tex format; adjust for latex etc.):

\input tikz
\usetikzlibrary{shapes.geometric,shapes.symbols,shadows}
\tikzpicture[
button/.style={text=white,draw=#1!50!black,
preaction={drop shadow={shadow scale=1.05,shadow xshift=0pt,shadow yshift=-1pt}},
top color=#1!10,bottom color=#1!50!black,inner xsep=2ex,inner ysep=1.6ex,
},
plastic/.style={button=#1,shape=rectangle,rounded corners=1.6ex},
oval/.style={button=#1,shape=rectangle,rounded corners=2.5ex,ball color=#1},
any size/.style={button=#1,shape=ellipse,inner xsep=1ex, inner ysep=1ex},
slick/.style={button=#1,shape=tape,tape bend height=1ex,inner sep=1ex},
candy wrap/.style={button=#1,shape=rectangle,rounded corners=5ex},
smooth/.style={button=#1,shape=rectangle,rounded corners=2ex,
top color=#1!50!black,shading angle=45,bottom color=#1!10}
]
\draw (0,0)
\foreach \color in {red,green,blue} {
\foreach \shape in {plastic,oval,any size,slick,candy wrap,smooth} {
node[\shape=\color] {\shape} ++(2.5,0)
}
++(-15,1)
};
\endtikzpicture
\bye


-
add comment