Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:36:69

And We did not give Prophet Muhammad, knowledge of poetry, nor is it befitting for him. It is not but a message and a clear Qur'an  

And We did not teach him, that is, the Prophet, poetry — this was ˹revealed˺ to refute their saying, ‘This Qur’ān that he has brought is but poetry!’ — nor is it, poetry, seemly, ˹nor is it˺ facilitated, for him. It — that which he has brought — is just Remembrance, an admonition, and a Qur’ān that clarifies, that manifests ˹God’s˺ rulings and other matters;
القرآن:٣٦:٦٩

وَمَا عَلَّمْنَاهُ الشِّعْرَ وَمَا يَنْبَغِي لَهُ ۚ إِنْ هُوَ إِلَّا ذِكْرٌ وَقُرْآنٌ مُبِينٌ  

{وما علمناه} أي النبي {الشعر} رد لقولهم إن ما أتى به من القرآن شعر {وما ينبغي} يسهل {له} الشعر {إن هو} ليس الذي أتى به {إلا ذكر} عظة {وقرآن مبين} مظهر للأحكام وغيرها.