How to have a node's width match another's height?

You can use fit library to compute node's height. But with fitting nodes, it's better to add its contents with the label option.

Following code defines a barstyle style with two arguments, the first one is the original node which is used to get its height while the second is the node contents.

\documentclass{article}
\usepackage{tikz}
\usepackage{varwidth}
\usetikzlibrary{positioning,shapes, fit}

\begin{document}
\begin{tikzpicture}[%
  node distance=2em,
  textbox/.style={rectangle split, rectangle split parts=2, 
                  rectangle split part fill={black!90,black!5},
                  rectangle split part align=base,
                  draw=gray,align=center},
  barstyle/.style 2 args={fill=black!90,
            minimum width=3em, 
            fit={(#1.south) (#1.north)}, inner ysep=0pt, label={[rotate=90, white]center:#2}
    }]

\node[textbox] (textnode) {%
  {\color{white} Input}
  \nodepart{two}
  \begin{varwidth}{.8\columnwidth}
    Some pretty\\
    drawn-out text\\
    much too long\\
    to fit on a single\\
    line.
  \end{varwidth}};

\node[barstyle={textnode}{A Bar!}, right=of textnode] (bar) {};

\node[textbox, below= of textnode] (textnode2) {%
  {\color{white} Input}
  \nodepart{two}
  \begin{varwidth}{.8\columnwidth}
    Some pretty 
    drawn-out text\\
    much too long 
    to fit on a single\\
    line.
  \end{varwidth}};

\node[barstyle={textnode2}{A Bar!}, right=of textnode2] (bar2) {};

\end{tikzpicture}
\end{document}

nodes whose heights match those of another node

2nd solution:

A completely different solution could be to use \tcbsetmacrotoheightofnode or \tcbsetmacrotowidthofnode macros from skins library in tcolorbox (see: 12.9 Extracting node dimensions) package:

\tcbsetmacrotoheightofnode{\myheight}{textnode2}

saves height of textnode2 node in macro \myheight which can be used in minimum height|width|size option from other nodes.

\documentclass{article}
\usepackage{tikz}
\usepackage{varwidth}
\usetikzlibrary{positioning,shapes}
\usepackage[skins]{tcolorbox}

\begin{document}
\begin{tikzpicture}[%
  node distance=2em,
  textbox/.style={rectangle split, rectangle split parts=2, 
                  rectangle split part fill={black!90,black!5},
                  rectangle split part align=base,
                  draw=gray,align=center},
  barstyle/.style={fill=black!90, text=white, align=center, inner ysep=6pt, rotate=90}
  ]

\node[textbox] (textnode) {%
  {\color{white} Input}
  \nodepart{two}
  \begin{varwidth}{.8\columnwidth}
    Some pretty\\
    drawn-out text\\
    much too long\\
    to fit on a single\\
    line.
  \end{varwidth}};

  \tcbsetmacrotoheightofnode{\myheight}{textnode}

    \node[barstyle, minimum width=\myheight, right= of textnode, anchor=north] (bar) {A Bar!};

\node[textbox, below= of textnode] (textnode2) {%
  {\color{white} Input}
  \nodepart{two}
  \begin{varwidth}{.8\columnwidth}
    Some pretty 
    drawn-out text\\
    much too long 
    to fit on a single\\
    line.
  \end{varwidth}};

  \tcbsetmacrotoheightofnode{\myheight}{textnode2}

    \node[barstyle, minimum width=\myheight, right=of textnode2, anchor=north] (bar2) {A Bar!};

\end{tikzpicture}
\end{document}

By looking at this previous question:

Extract x, y coordinate of an arbitrary point on curve in TikZ

\documentclass{article}
\usepackage{tikz}
\usepackage{varwidth}
\usetikzlibrary{positioning,shapes,calc}

\begin{document}
\newdimen\XCoord
\newdimen\YCoord
\makeatletter
\newcommand{\gettikzxy}[3]{%
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \edef#2{\the\pgf@x}%
  \edef#3{\the\pgf@y}%
}
\begin{tikzpicture}[%
  node distance=2em,
  textbox/.style={rectangle split, rectangle split parts=2, 
                  rectangle split part fill={black!90,black!5},
                  rectangle split part align=base,
                  draw=gray,align=center},
  barstyle/.style={fill=black!90,text=white,align=center,inner ysep=6pt,rotate=90}]

\node[textbox] (textnode) {%
  {\color{white} Input}
  \nodepart{two}
  \begin{varwidth}{.8\columnwidth}
    Some pretty\\
    drawn-out text\\
    much too long\\
    to fit on a single\\
    line.
  \end{varwidth}};
 \gettikzxy{(textnode.north)}{\ax}{\ay}
\gettikzxy{(textnode.south east)}{\bx}{\by}
\node[barstyle,minimum width=\ay-\by,anchor=south west] at($(\bx,\by)+(1cm,0.cm)$) % THIS should match height of text node automatically
  (bar) {A Bar!};
\end{tikzpicture}
\end{document} 

enter image description here


And, just for fun, a method using the let syntax from the calc library.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{varwidth}
\usetikzlibrary{positioning,shapes,calc}

\begin{document}
\begin{tikzpicture}[%
  node distance=2em,
  textbox/.style={rectangle split, rectangle split parts=2, 
                  rectangle split part fill={black!90,black!5},
                  rectangle split part align=base,
                  draw=gray,align=center},
  barstyle/.style={fill=black!90,text=white,align=center,inner ysep=6pt,rotate=90}]

\node[textbox] (textnode) {%
  {\color{white} Input}
  \nodepart{two}
  \begin{varwidth}{.8\columnwidth}
    Some pretty\\
    drawn-out text\\
    much too long\\
    to fit on a single\\
    line.
  \end{varwidth}};

\path let
\p1=(textnode.south), \p2=(textnode.north)
in
node[barstyle,right=of textnode.south east,minimum width=\y2-\y1] 
  (bar) {A Bar!};
\end{tikzpicture}
\end{document}

Tags:

Width

Tikz Pgf