Let $X$ be a topological space and $A$ be a subset of $X$ is there any equivalent condition on $A$ for the fact 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