If we know the magnitude and the angle, calculating the x-component is simple trigonometry.

From the figure, it is clear that the angle between OB and AB is 90 degrees. That is, OAB forms a right-angled triangle. From trigonometry, we know that $$\mathrm{cos} \, \theta = \frac{\mathrm{adjacent}}{\mathrm{hypotenuse}}$$ In this case, it becomes $$\mathrm{cos} \,60^{\circ} = \frac{\mathrm{OB}}{\mathrm{OA}}$$

Thus, the x-component, which is nothing but the length OB, is

$$\mathrm{OB} = \mathrm{OA} \times \mathrm{cos} \, 30^{\circ} = 10 \times \mathrm{cos} \, 30^{\circ}$$.