[Tex/LaTex] Boxed text explaining a part of equation in beamer

beamerequations

\documentclass[10pt]{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\usepackage[english]{babel}
\usepackage{booktabs}
\usefonttheme[onlymath]{serif}
\setbeamercolor{background canvas}{bg=white}
\setbeamertemplate{footline}[frame number]
\usetheme{Singapore}
\usepackage{xcolor}


\begin{document}

\begin{frame}{Standard Model}
Standard Model(SM) is gauge theory based on the gauge group-
\begin{equation}
G_{SM}=  SU(3)_C\times SU(2)_L\times U(1)_Y
\end{equation}
Complete SM lagrangian can be written as-

\[\mathcal{L}_{SM}=\textcolor{blue}{i\overline{\psi}\gamma^{\mu}\mathcal{D}_{\mu}\psi}\pause\textcolor{red}{ -\frac{1}{4}G^{\mu\nu A}G_{\mu\nu}^{A}-\frac{1}{4}W^{\mu\nu I}W_{\mu\nu}^{I}-\frac{1}{4}B^{\mu\nu}B_{\mu\nu}}\]
                              \[\pause\textcolor{magenta}{+h_{ij}^{u}\overline{Q}_{i}U_{j} \widetilde{H}+h_{ij}^{d}\overline{Q}_{i} D_{j}H+h_{ij}^{e}\overline{L}_{i}E_{j}H+h.c.}\]
                              \pause

\begin{equation}
\textcolor{violet}{+(\mathcal{D}_{\mu}H)^{\dag}\mathcal{D}_{\mu}H-\mu^{2}H^{\dag}H+\lambda(H^{\dag}H)^{2}}
\end{equation}
\end{frame}
\end{document}  

This code is giving following four slides-
enter image description here
enter image description here
enter image description here
enter image description here

I want boxed description of each term to be included in these slides but previous description should fade away when I jump to next term or next slide.
How can I achieve that?

Best Answer

If you want to add text to just one slide, try \only<>{}

\documentclass{beamer}

\begin{document}

    \begin{frame}
        Complete SM lagrangian can be written as-
        \[\mathcal{L}_{SM}=\textcolor{blue}{i\overline{\psi}\gamma^{\mu}\mathcal{D}_{\mu}\psi}\only<1>{~\fbox{explain something}}\pause
        \textcolor{red}{ -\frac{1}{4}G^{\mu\nu A}G_{\mu\nu}^{A}-\frac{1}{4}W^{\mu\nu I}W_{\mu\nu}^{I}-\frac{1}{4}B^{\mu\nu}B_{\mu\nu}}\]
        \[\pause\textcolor{magenta}{+h_{ij}^{u}\overline{Q}_{i}U_{j} \widetilde{H}+h_{ij}^{d}\overline{Q}_{i} D_{j}H+h_{ij}^{e}\overline{L}_{i}E_{j}H+h.c.}\]
        \pause
        \begin{equation}
        \textcolor{violet}{+(\mathcal{D}_{\mu}H)^{\dag}\mathcal{D}_{\mu}H-\mu^{2}H^{\dag}H+\lambda(H^{\dag}H)^{2}}
        \end{equation}
    \end{frame} 

\end{document}

enter image description here

With a bit of help from https://tex.stackexchange.com/a/205623/36296 you could also explain the terms like this

\documentclass{beamer}

\usepackage{mathtools}

\newcommand<>{\uncoverubrace}[2]{%
    \onslide#3 \underbrace{ \onslide<1->%
        #1%
        \onslide#3 }_{#2} \onslide<1->%
}
\newcommand<>{\uncoverobrace}[2]{%
    \onslide#3 \overbrace{ \onslide<1->%
        #1%
        \onslide#3 }^{#2} \onslide<1->%
}


\begin{document}

    \begin{frame}
        Complete SM lagrangian can be written as-
        \[\mathcal{L}_{SM}=\uncoverubrace<1>{\textcolor{blue}{i\overline{\psi}\gamma^{\mu}\mathcal{D}_{\mu}\psi}}{\only<1>{\fbox{matter}}}\pause
        \textcolor{red}{ -\frac{1}{4}G^{\mu\nu A}G_{\mu\nu}^{A}-\frac{1}{4}W^{\mu\nu I}W_{\mu\nu}^{I}-\frac{1}{4}B^{\mu\nu}B_{\mu\nu}}\]
        \[\pause\textcolor{magenta}{+h_{ij}^{u}\overline{Q}_{i}U_{j} \widetilde{H}+h_{ij}^{d}\overline{Q}_{i} D_{j}H+h_{ij}^{e}\overline{L}_{i}E_{j}H+h.c.}\]
        \pause
        \begin{equation}
        \textcolor{violet}{+(\mathcal{D}_{\mu}H)^{\dag}\mathcal{D}_{\mu}H-\mu^{2}H^{\dag}H+\lambda(H^{\dag}H)^{2}}
        \end{equation}
    \end{frame} 

\end{document}

enter image description here