# Custom shadow - border effect with TikZ

I would like to draw a box like this:

I'm especially interested in both

1. how to draw a shadow that comes out from the sides only (not also top or bottom) and
2. how to draw two shadows, the bigger left-right shadow and the smaller outline border one.

I've tried many approaches but it seems I'm completely off track here since I can't even draw the left-right bigger shadow, so I would appreciate if someone could explain me where to start here.

Clarifications. I think the picture is compose by 4 parts:

1) the background (uninteresting here)

2) the white rectangle

3) the rectangle borders-edges (what I previously referred as the smaller shadow) with a ridge like effect

4) the left and right shadows

I'm trying to draw parts 3 and 4.

-
The smaller outline border shadow? Where? (Do you mean the slightly darker edges on the rectangle?) I can only see the one at the left and right. –  Qrrbrbirlbel Oct 27 '13 at 16:07
@Qrrbrbirlbel I added a small clarification, BTW it's like you said, I was referring to the edges. –  knut Oct 27 '13 at 16:42

An idea that needs xscale around and yscale around. Better results can probably achieved with a custom fading that works similar to circle with fuzzy edge XX percent (see circular shadow and circular glow) but for rectangles.

## Code

\documentclass[tikz,border={3pt 0pt 3pt 0pt}]{standalone}
\makeatletter
\tikzset{
xscale around/.code=%
yscale around/.code=%
preaction={#1,
transform canvas={
xscale around=%
yscale around=%
shift=%
}}},
bottom color=gray!10, middle color=gray!50, every shadow, #1}}}
\makeatletter
\begin{document}
\begin{tikzpicture}[start chain=ch0 going below, node distance=.2cm,
nodes={draw, fill=white, my shadow, on chain=ch0}]
\node                     {Effect 8};
\node[minimum height=+2cm]{Effect 9};
\node[minimum width =+2cm]{Effect 10};
\end{tikzpicture}
\end{document}


## Output

-
this works "in principle", but the result is very far from the original picture. I was looking to fully reproduce it. –  knut Oct 29 '13 at 12:51

Some ideas, lots of hardcoded magic numbers (found by trial and error):

\documentclass{article}
\usepackage{tikz}

% #1: Optional aditional tikz options
% #2: Name of the node to "decorate"
\begin{pgfonlayer}{background}
\path[
rounded corners=1pt,
($(#2.north west)+( 0.3pt,0)$) --
($(#2.south west)+( 0.3pt,0)$) --
($(#2.south east)+(-0.3pt,0)$) --
($(#2.north east)+(-0.3pt,0)$) --
cycle;
\path[rounded corners,
($(#2.north west)+(-1pt,-2pt)$) --
($(#2.south west)+(-1pt, 2pt)$) --
($(#2.south east)+( 1pt, 2pt)$) --
($(#2.north east)+( 1pt,-2pt)$) --
cycle;
\end{pgfonlayer}
}

\begin{document}
\begin{tikzpicture}
\begin{pgfonlayer}{background}
\fill[black!20] (-3,-1) rectangle (3,1);
\end{pgfonlayer}
\node[fill=white, rectangle, minimum width=3cm, minimum height=1cm]
(example) {Test};
\end{tikzpicture}
\end{document}


Result:

-

Still far away from expected results but here it is another approximation with tcolorbox

\documentclass[border=5mm]{standalone}
\usepackage[most]{tcolorbox}

\begin{document}

\tcbset{width=.5\linewidth, height=3cm, valign=center, center upper, sharp corners, enhanced, frame hidden, fontupper=\sffamily\Huge,colback=white,
fuzzy halo=.1pt with black!35,
overlay unbroken={
sin +(1mm,-1.5mm) cos +(1mm,-1.5mm)--
([xshift=2mm,yshift=6mm]frame.south east)
sin +(-1mm,-1.5mm)  cos +(-1mm,-1.5mm);
\shade[right color=black!30, left color=white] ([yshift=-3mm]frame.north west)
sin +(-1mm,-1.5mm) cos +(-1mm,-1.5mm)--
([xshift=-2mm,yshift=6mm]frame.south west)
sin +(1mm,-1.5mm)  cos +(1mm,-1.5mm);
}}

\begin{tcolorbox}
Effect 8
\end{tcolorbox}

\end{document}


-