# Drawing neat UML class diagrams with tikz

I want to draw (UML) class diagrams with tikz (and I'm aware there is a special tikz package for that). I want to imitate the style that yuml.me uses, since personally I find it very appealing and at the same time still serious. Here is an example what I would like to achieve:

Note in particular that there is a slight shadow/glow outside and inside the border and the subtle color gradient used for the fill color.

Here is a zoomed view to make clear what I mean:

I tried to take the color values from an yuml diagram and transfer them to tikz, but the closest I got is the following:

\tikzstyle{class}=[
rectangle,
draw=black,
text centered,
anchor=north,
text=black,
text width=3cm,

\begin{tikzpicture}[node distance=2cm]
\node (Item) [class, rectangle split, rectangle split parts=2]
{
\textbf{Car}
\nodepart{second}foobar\newline baz
};
\end{tikzpicture}


which is still pretty ugly and not anywhere near the style I want to achieve.

Any help from the tikz-experts would be appriciated!

Just replace your older bottom color definition with bottom color=black!20. Change that number to increase or decrease the saturation.

• Well the bottom color I used is the one from the original png - but for whatever reason, tikz produces r:85g:85b:85 with my definition (which clearly is not 222). Why? Also, do you have any idea how to reproduce the soft borders? – Leo Oct 25 '13 at 13:49
• Not sure, but you can set what red, blue and green look like. Add this in your preamble: \definecolor{red}{RGB}{200,5,5}. Red is the "command name", so whenever you write red, it will use the RGB commands you gave. For this reason, I'd use customized names, like "myred" and so on. :) What do you mean by soft borders? Sorry can't get that. :P – Alenanno Oct 25 '13 at 13:55
• If you open the target png with an image editor and zoom in, you will see that the border is not just a 1px black line (which tikz produces at the moment) but there is an inner and an outer border as well, that's what I mean with soft borders. – Leo Oct 25 '13 at 14:13
• @Mef I'm looking into it. :) – Alenanno Oct 25 '13 at 15:21
• @Mef The “soft border” looks like anti-aliasing. The same can be observed with the text “User”. The shadow can be achieved with TikZ, looks like a drop shadow. However I would advise against any fancy coloring as it looks neither good nor professional (in my opinion). The zigzaged lines from the examples look even worse. – Qrrbrbirlbel Oct 25 '13 at 19:47

Just as Alenanno's suggestion,use define color marco will resolve the color issue.

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\definecolor{bottomcol}{RGB}{222,222,222}

\begin{document}
\tikzstyle{class}=[
rectangle,
draw=black,
text centered,
anchor=north,
text=black,
text width=3cm,