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}
\usetikzlibrary{fadings}
\newcommand{\tikzrule}[3][]{\tikz{\fill[#1] (0,0) rectangle (#2,#3);}}
\begin{document}
{\centering
\tikzrule[cyan, path fading=east]{\textwidth}{1em}\\[.5em]
\textbf{Thermodynamics}\\[.5em]
\tikzrule[cyan, path fading=west]{\textwidth}{1em}
}
\noindent
\tikzrule{.9\textwidth}{3pt}\\
\rule{.9\textwidth}{3pt}
\end{document}

The command \tikzrule which behaves like the built in \rule except that it takes an optional argument which is passed as a 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.