[Tex/LaTex] Grid inside node with tikz

tikz-pgf

This snippet…

\documentclass{article}
\usepackage{tikz}
\newcommand{\mygrid}{\tikz{\draw[step=2.5mm] (0,0)  grid (1,1);}}

\begin{document}
    \begin{tikzpicture}
    \node[rectangle, draw]
    {
        \mygrid
    };
    \end{tikzpicture}
\end{document}

generates this picture:

rectangle with a grid

What I should do to make the grid occupy the whole square (starting at the left bottom angle and terminating at the top right angle)? Should I use pic instead of nesting two pictures?

Best Answer

try

\documentclass{article}
\usepackage{tikz}
\newcommand{\mygrid}{\tikz{\draw[step=2.5mm] (0,0)  grid (1,1);}}

\begin{document}
    \begin{tikzpicture}
    \node[rectangle, draw, inner sep=0]
    {
        \mygrid
    };
    \end{tikzpicture}
\end{document}