This is a common question. In most cases, vitamin D toxicity does not come from sun exposure. Mayo Clinic explains that the body controls how much vitamin D it makes from sunlight, so toxicity is not likely from sunlight or from foods naturally containing vitamin D.
The NHS also says you cannot overdose on vitamin D through exposure to sunlight. However, it still recommends protecting your skin during long periods in the sun to reduce the risk of skin damage and skin cancer.
So the message is balanced: sunlight can