I would like to draw a node around a one-line text, with only the left part filled. The size of that 'left part' would be specified by some fraction. In effect, this would be a progress bar with text inside.

\documentclass{article} \usepackage{tikz} \begin{document}

 \draw (0, 0) node[draw, fill = green!10, fill fraction = .7] {Some


Of course my fictitious option 'fill fraction', which should say that only the leftmost 70% should be filled, gets ignored.

1 Answer 1


It is so cruel that TikZ ignored you, I had to do something about it. ;-)

 \begin{tikzpicture}[fill fraction/.style n args={2}{path picture={
 \fill[#1] (path picture bounding box.south west) rectangle
 ($(path picture bounding box.north west)!#2!(path picture bounding box.north

 \draw (0, 0) node[draw, fill fraction={green!10}{0.7}] {Some
 \draw (4, 0) node[circle,draw, fill fraction={green!10}{0.7}] {Some
 other text};

enter image description here

  • Very efficient thank you ! Can you help us understand how it works ?
    – joseldsm
    Mar 7, 2019 at 7:43
  • @joseldsm I just add a path picture. This is something that is drawn on the background and clipped against the node boundary path.
    – user121799
    Mar 7, 2019 at 14:40
  • Nice and simple! In my case, I wanted to fill the white portion of the circle with another color (say red). You can fill the entire circle first by adding \draw node[circle, draw, fill={red}] before the \draw command that uses fill fraction Jul 25, 2020 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.