  We show that coupling of ultralight dark matter (UDM) to quarks and gluons
would lead to an oscillation of the nuclear charge radius for both the quantum
chromodynamics (QCD) axion and scalar dark matter. Consequently, the resulting
oscillation of electronic energy levels could be resolved with optical atomic
clocks, and their comparisons can be used to investigate UDM-nuclear couplings,
which were previously only accessible with other platforms. We demonstrate this
idea using the ${}^2S_{1/2} (F=0)\leftrightarrow {}^2F_{7/2} (F=3)$ electric
octupole and ${}^2S_{1/2} (F=0)\leftrightarrow \,{}^2D_{3/2} (F=2)$ electric
quadrupole transitions in ${}^{171}Yb^+$. Based on the derived sensitivity
coefficients for these two transitions and a long-term comparison of their
frequencies using a single trapped ${}^{171}Yb^+$ ion, we find bounds on the
scalar UDM-nuclear couplings and the QCD axion decay constant. These results
are at a similar level compared to the tightest spectroscopic limits, and
future investigations, also with other optical clocks, promise significant
improvements.
