\documentclass[12pt]{article}
\usepackage{xhfill}
\begin{document}

blah \xhrulefill{cyan}{1cm} blub

blahblah \xhrectanglefill{0.5cm}{1pt} blubber

\end{document}
