You cannot decide whether a small piece of what you call "UI" is good without considering its place within the larger context that you call "UX". A dialog box that is very pretty, fits well with the overall aesthetics of the application and the platform/OS, and properly does what it says it does—would still be an example of bad UI if it's one of those dialog boxes that shouldn't exist in the first place and is a product of the developers/designers fundamentally misunderstanding the workflow or goals of their users.
This distinction you're trying to make is really not productive. Its too vague and subjective about where to draw the line, and I'm pretty sure most people who are adamant that a line must be drawn are people who will subsequently neglect things on one side of the line as "somebody else's problem".