This is a possible implementation:
\tikzset{mynode/.style={
bottom color=white,top color=black!20,
append after command={
[very thick,shorten >=0.2bp, shorten <=0.2bp]
(\tikzlastnode.north west)edge(\tikzlastnode.north east)
}
}
}
The complete example:
\documentclass{standalone}
\usepackage{tikz}
\tikzset{mynode/.style={
bottom color=white,top color=black!20,
append after command={
[very thick,shorten >=0.2bp, shorten <=0.2bp]
(\tikzlastnode.north west)edge(\tikzlastnode.north east)
}
}
}
\begin{document}
\begin{tikzpicture}
\node[mynode] at (0,0){texta};
\end{tikzpicture}
\end{document}
The result:

Some explanation
Inside a tikzset
you can define the style of your node, thus you can select the colors bottom color=white,top color=black!20,
. It is also possible to automatically draw the thick line on the upper border just appending the path when the node has been drawn: that's the purpose of:
append after command={
[very thick,shorten >=0.2bp, shorten <=0.2bp]
(\tikzlastnode.north west)edge(\tikzlastnode.north east)
}
Notice that, in order to correctly set the line with, it has been reduced a bit by means of shorten >=0.2bp, shorten <=0.2bp
.
After percusse's comment I investigated a bit on it and actually I found a way to solve the problem.
Assume indeed to substitute \node[mynode] at (0,0){texta};
with \draw[red,dotted] node[mynode]at (0,0){texta};
. You'll get:

But the following MWE demonstrates that this could be avoided (part of the credit should go to percusse's comment):
\documentclass[border=1bp]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}
\tikzset{
my safe node/.style={
bottom color=white,top color=black!20,text=black,% <= that's for the text
line width=0pt, %<= now it's absolutely needed to not have problems while scaling the picture
append after command={% <= for the line
\pgfextra{%
\begin{pgfinterruptpath}
\begin{pgfonlayer}{foreground}
\draw[very thick,shorten >=0.05bp, shorten <=0.05bp] % <= this actually is to remove a residual tiny exceeding border
(\tikzlastnode.north west)--(\tikzlastnode.north east);
\end{pgfonlayer}
\end{pgfinterruptpath}
}
}
}
}
\begin{document}
\scalebox{6}{
\begin{tikzpicture}
\draw[draw=red,dashed,ultra thick] (0,0) -- (1,1) node[my safe node]{texta} -- (2,2)
node[my safe node] {textb} --(3,3);
\end{tikzpicture}
}
\end{document}
The result is:
