In the name of Allah, the most Beneficent, the most Merciful.
Saaiduna Abu Sa'id Khudri Radiallahu Anhu narrates, “The garlic and onions were mentioned before the Prophet of Allah Sallallahu Alahi Wasalam. He was told: The most severe of them is garlic. Would you make it unlawful? The Prophet of Allah Sallallahu Alahi Wasalam said: Eat it, and he who eats it should not come near this mosque until its odour goes away.”
Saaiduna Mughirah Bin Shubah Radiallahu Anhu narrates, “I ate garlic and came to the place where the Prophet of Allah Sallallahu Alahi Wasalam was praying; one rakat of prayer had been performed when I joined. When I entered the mosque, the Prophet of Allah Sallallahu Alahi Wasalam noticed the odour of garlic. When the Prophet of Allah Sallallahu Alahi Wasalam finished his prayer, he said: He who eats from this plant should not come near us until its odour has gone away…”
Khalid said: Abu Ziyad Khiyar ibn Salamah asked Aisha Radiallahu Anha about onions. She replied: The last food, which the Prophet of Allah Sallallahu Alahi Wasalam ate, was some, which contained onions. (Hadiths taken from Sunan Abi Dawud p.179-p.180 v.2)
From the aforementioned ahadith we can derive that eating onions is permissible. What is not permissible is to eat onions then without cleaning or rinsing the mouth to enter the masjid.
Only Allah Knows Best
Mohammed Tosir Miah
Darul Ifta Birmingham.