makebox with minimum width

\documentclass{article}
\newlength{\mylen}
\newcommand{\myflexbox}[2][3em]{%
  \settowidth{\mylen}{#2}%
  \ifdim\mylen < #1
    \makebox[#1][l]{#2}%
  \else
    #2%
  \fi
}
\begin{document}
  \myflexbox{good} padding

  \myflexbox{notbad} padding

  \myflexbox{it overlaps!} padding

  it overlaps! padding

\end{document}

enter image description here


1st Try

Try the tabbing environment and next time please provide a complete example (including documentclass etc.)

The first line defines the tab position.

\documentclass{article}

\begin{document}

 \begin{tabbing}
    longestlongest \= long  \kill % kill -> do not print this line
    good \> padding \\
    notbad \> padding \\
    it overlaps \> padding \\
 \end{tabbing}

\end{document}

enter image description here


2nd Try

Now I use a tikz picture but I don't know how to left align (align=left) it without using text with. Maybe an expert can help us out.

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

\parindent0mm

\section*{With Frame}   

\tikz[baseline=(O.base)]{\node(O) [baseline,draw,minimum width=15mm,inner sep = 0,align=left] {good};} padding\\
\tikz[baseline=(O.base)]{\node(O) [baseline,draw,minimum width=15mm,inner sep = 0,align=left] {notbad};} padding\\
\tikz[baseline=(O.base)]{\node(O) [baseline,draw,minimum width=15mm,inner sep = 0] {it does not overlap};} padding\\

\section*{No Frame (\texttt{draw} removed)} 

\tikz[baseline=(O.base)]{\node(O) [baseline,minimum width=15mm,inner sep = 0,align=left] {good};} padding\\
\tikz[baseline=(O.base)]{\node(O) [baseline,minimum width=15mm,inner sep = 0,align=left] {notbad};} padding\\
\tikz[baseline=(O.base)]{\node(O) [baseline,minimum width=15mm,inner sep = 0] {it does not overlap};} padding\\

\end{document}

I used this question for help.

enter image description here