Consider a spherical coordinate system. Let a point be represented by $(r, \theta, \phi)$, in that order. Now that the order of the coordinates is established, I can define unit vectors that form a right-handed coordinate system. Suppose the radial unit vector $\vec{e}_r$ points radially outward from the origin to the point, and the polar unit vector $\vec{e}_{\theta}$ points in the direction of increasing $\theta$. From the right hand rule, the azimuthal unit vector $\vec{e}_{\phi}$ points in the direction of increasing $\phi$. Below is a diagram with an arbitrary vector $\vec{r}=(r,\theta,\phi)=r \vec{e}_r$.
The Polar Unit Vector in Terms of Spherical Coordinates
Another axis called the $w$-axis is included, to help define $\vec{e}_{\theta}$ in terms of symbols. Since $\theta$ increases from 0 on the $+z$-axis to $\pi$ radians on the $-z$-axis, as $\theta$ increases $\vec{r}$ traces a curved path in the $z-w$ plane. Also, $\vec{r}$ undergoes a counterclockwise rotation from the $+z$-axis to the $+w$-axis, if the $+z$-axis is on the right.
The length of the radius does not affect the direction of the polar unit vector, so I set $r=1$.
$\vec{e}_{\theta} = -\sin\theta \vec{e}_z + \cos\theta \vec{e}_w$.
This equation can be obtained with trigonometry. This unit vector has a length of 1. The next step is to solve for $\vec{e}_w$. From vector addition,
$\vec{e}_w = r’ \cos\phi \vec{e}_x + r’ \sin\phi \vec{e}_y $.
To get the direction for $\vec{e}_w$, I disregard $r=1$ and set $r’=1$. Then
$\vec{e}_w = \cos\phi \vec{e}_x + \sin\phi \vec{e}_y $.
This unit vector also has a length of 1. Substituting the previous expression for $\vec{e}_w$ into the initial expression for $\vec{e}_{\theta}$,
$\vec{e}_{\theta} = -\sin\theta \vec{e}_z + \cos\theta (\cos\phi \vec{e}_x + \sin\phi \vec{e}_y)$.
Simplifying,
$ \boxed { \vec{e}_{\theta} = \cos\theta \cos\phi \vec{e}_x + \cos\theta \sin\phi \vec{e}_y -\sin\theta \vec{e}_z }$.
The Polar Unit Vector in Terms of Cartesian Coordinates
It is possible to convert
$ \vec{e}_{\theta} = -\sin\theta \vec{e}_z + \cos\theta \cos\phi \vec{e}_x + \cos\theta \sin\phi \vec{e}_y $.
into Cartesian coordinates. This is done by recognizing that
$\cos\theta = \frac{z}{\sqrt{x^2 + y^2 + z^2}}$
$\sin\theta = \frac{\sqrt{x^2 + y^2}}{\sqrt{x^2 + y^2 + z^2}}$
$\cos\phi = \frac{x}{\sqrt{x^2 + y^2}}$
$\sin\phi = \frac{y}{\sqrt{x^2 + y^2}}$.
Therefore,
$ \boxed{ \vec{e}_{\theta} = \frac{z}{\sqrt{x^2 + y^2 + z^2} }\frac{x}{\sqrt{x^2 + y^2}} \vec{e}_x + \frac{z}{\sqrt{x^2 + y^2 + z^2} } \frac{y}{\sqrt{x^2 + y^2 }} \vec{e}_y – \frac{\sqrt{x^2 + y^2}}{\sqrt{x^2 + y^2 + z^2}} \vec{e}_z } $.