You could just use the style from the pgfmanual. Details can be found here. Note that you may have to modify the path in
\input{/usr/local/texlive/2019/texmf-dist/doc/generic/pgf/macros/pgfmanual-en-macros.tex}
on your machine.
\documentclass{ltxdoc} % the pgf manual styles are based on ltxdoc
\usepackage{tikz}
% necessary for the manual styles:
\usepackage{calc}
\input{/usr/local/texlive/2019/texmf-dist/doc/generic/pgf/macros/pgfmanual-en-macros.tex}
\RequirePackage{pgfmanual}
\begin{document}
\begin{codeexample}[]
\begin{tikzpicture}
\draw[thick, blue] (1,0) -- (0,0) -- (0,1) -- cycle;
\end{tikzpicture}
\end{codeexample}
\end{document}

Or you could, similarly to CarLaTeX, use a tcolorbox. The author of the package provides us with a style that looks like the pgfmanual.
\documentclass{article}
\usepackage[most]{tcolorbox}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\lstdefinestyle{example}{style=tcblatex,
classoffset=0,
texcsstyle=*\color{blue},%
deletetexcs={begin,end},
moretexcs={,%
pgfdeclarehorizontalshading,pgfuseshading,node,
useasboundingbox,draw}%
classoffset=1,
keywordstyle=\color{blue},%
morekeywords={tikzpicture,shade,fill,draw,path,node,child,line,width,rectangle},
classoffset=0}
\tcbset{%
fillbackground/.style={before lower pre={%
\tikzset{every picture/.style={execute at end picture={\begin{pgfonlayer}{background}
\fill[yellow!25!white]
([xshift=-1mm,yshift=-1mm]current bounding box.south west) rectangle
([xshift=1mm,yshift=1mm]current bounding box.north east);
\end{pgfonlayer}}}}}},
explicitpicture/.style={before lower=\begin{center},after lower=\end{center},fillbackground}}
\newtcblisting{sidebyside}[2][]{%
enhanced,frame hidden,
top=0pt,bottom=0pt,left=0pt,right=0pt,arc=0pt,boxrule=0pt,
colback=blue!25!white,
listing style=example,
sidebyside,text and listing,text outside listing,sidebyside gap=2mm,
lefthand width=#2,tikz lower,fillbackground,
#1}
\begin{document}
\begin{sidebyside}[explicitpicture]{4.2cm}
\begin{tikzpicture}
\draw[thick, blue] (1,0) -- (0,0) -- (0,1) -- cycle;
\end{tikzpicture}
\end{sidebyside}
\end{document}