In optional fasts, kissing, hugging, etc. are permitted so long as one does not engage in sexual intercourse. In obligatory fasts, one is allowed to do these only if one can control oneself. Therefore, no one who is fasting should do such things if there is a genuine risk of overstepping the boundaries. If there is no such fear, then light touching, or kissing, etc, when not accompanied by sexual desire, is permissible.
Sheikh Ahmad Kutty, a senior lecturer and Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states: Hugging your spouse in itself does not invalidate the fast; we read in the sources that the Prophet (peace and blessings be upon him) used to kiss his wife while fasting. We also read that once a person asked the Prophet (peace and blessings be upon him) “Am I allowed to kiss my wife while fasting?” He replied, “Yes.” Hugging is comparable to kissing.

Having said this, however, I must caution married couples to abstain from such acts if you find yourself unable to control your desire, for as Muslims we must keep away from all such acts that may inadvertently lead to invalidating our fasts. This is why we read in another hadith that the Prophet told another person not to kiss his spouse. In explaining the discrepancy between the two reports, Ibn `Abbas said, “The man he permitted was an older person, while the man he prohibited was a young man.” Therefore, if you have any doubt or fear of being unable to control yourself, then you should simply abstain from such actions altogether in order to save your fast. This is why the Prophet’s wife `A’ishah (may Allah be pleased with her) asked a person, ‘Who among you is capable of restraining himself as the Prophet (peace and blessings be upon him) had been?’