Let $X$ be a topological space and $A$ be a subset of $X$. Is there any nice condition on $A$ equivalent to the property that if $C$ is a connected component of $X$, then either $A\cap C=\emptyset$ or for a continuous real valued function if $f(A\cap C)\in\{0, 1\}$, then $f$ must be constant?

For example, dense subspaces of $X$ have this property. Also, connected components of $X$ have this property.