# How to draw a horizontal rule with a colour gradient?

Look at the two blue coloured rules with a colour gradient. This is what I'm looking for. Thank You.

You can control the distance between the gradients and text changing the values 1em for example. Also, the height for rectangle could be changed 1.5em.

\documentclass{article}
\usepackage{lipsum}%dummy text only
\usepackage{tikz}
\begin{tikzpicture}
\node at (.5\linewidth,0) {\bfseries #1};
\end{tikzpicture}%
}

\begin{document}
\lipsum[1]
\lipsum[2]
\end{document}


Adapting Sigur's answer to just give a command for the rule itself without the rest of the header, you might try

\documentclass{article}
\usepackage{tikz}
\newcommand{\tikzrule}[3][]{\tikz{\fill[#1] (0,0) rectangle (#2,#3);}}

\begin{document}
{\centering

The command \tikzrule behaves like the built in \rule except that it takes an optional argument which is passed as a tikz style. It is, however, a bit less robust than \rule in terms of what sorts of expressions can be used as its dimensions (e.g., \dimexpr doesn't work in \tikzrule).
Note that \tikzrule itself still works without the fadings tikzlibrary, although of course you need the library in order to produce the fading.