[Tex/LaTex] Shaded triangle arrow with text

tikz-arrowstikz-pgf

I have been trying to recreate a similar version of the arrow shown in the image below.

enter image description here

And this is what I manage to get so far:

enter image description here

I am a complete beginner when it comes to TikZ and after multiple failed attempts, I had to resort to drawing a shaded rectangle and then using right=of rectangle to append a triangle. However, obviously, the approach is awful. There's also a gap between the "arrowhead" and the line. Initially, I tried using using triangle 90,triangle 45 and so forth, but I the height of the arrowhead seemed to be dependent on the length of the line (which I did not like), and also I could not figure out how to add text within the line. Here's what I have:

MWE

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes}

\begin{document}
\begin{tikzpicture}[font=\large]
  \tikzset{
    node distance=0cm,
    buffer/.style={
      shape border rotate=270,
      regular polygon,
      regular polygon sides=3,
      minimum height=2cm,
      fill=blue!50,
    }
  }

  \node (therectangle) at (0,0) [shade,shading=axis,left color=white,right color=blue!50,minimum width=2.5cm,minimum height=1cm,] {Codes for};

  \node [buffer,right=of therectangle] {};
\end{tikzpicture}%

\end{document}

What I want is an arrow like shown in the picture, giving me the ability to:

  • Add text within.
  • Make it shaded.
  • Be able to use below=of <whatever> etc.
  • Retain the ability to use shorten <= <whatever> etc.
  • (Optional) Start the shading from the arrowhead.

Could someone help with this?

Best Answer

As it's a node, you can't use shorten, but the single arrow shape does most of what you want I think.

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes}

\begin{document}
\begin{tikzpicture}[font=\large]
  \node (therectangle) at (0,0) [single arrow,
                                 text width=3cm,
                                 align=center,
                                 shade,shading=axis,
                                 left color=white,right color=blue!50,
                                 minimum width=2.5cm,minimum height=1cm,] {Codes for};

\end{tikzpicture}%

\end{document}

Concerning your original code, setting the outer sep to zero for both nodes removes the gap, i.e.

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes}

\begin{document}
\begin{tikzpicture}[font=\large]
  \tikzset{
    node distance=0cm,
    buffer/.style={
      shape border rotate=270,
      regular polygon,
      regular polygon sides=3,
      minimum height=2cm,
      fill=blue!50,
    }
  }

  \node (therectangle) at (0,0) [shade,shading=axis,left color=white,right color=blue!50,minimum width=2.5cm,minimum height=1cm,outer sep=0pt] {Codes for};

  \node [buffer,outer sep=0pt,right=of therectangle] {};
\end{tikzpicture}%

\end{document}