[Tex/LaTex] TikZ Mindmap: How to make nodes autosize to fit the text

mindmapstikz-pgf

How can I have the size of a mindmap node be calculated automatically by TikZ such that the text inside fits nicely inside? With inner sep=... I am able to have the height fit in such a way, but not the width. Btw.: I am using rectangles as nodes, not the standard circles.

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{mindmap}

\tikzset{
    every node/.append style={concept, rectangle, minimum size=0cm, inner sep=2mm}
}

\begin{document}

\begin{tikzpicture}[mindmap,text=white]
\node {O} child { node {A} };
\end{tikzpicture}

\end{document}

Best Answer

I think you can simply add

text width=

to the style for every node. The mindmap style applies styles for each level of the tree which set the width of the text. You could override these separately per level, but if you want to do this generally, just adding it for all nodes seems to make more sense.

This produces

shrink-to-fit nodes

Code:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{mindmap}
\tikzset{
    every node/.append style={concept, text width=, rectangle, minimum size=0cm, inner sep=2mm},
}
\begin{document}
\begin{tikzpicture}[mindmap,text=white]
  \node {Orangutans} child { node {Aardvarks} child { node {Bees} } };
\end{tikzpicture}
\end{document}