Poetry can be divided into three categories: desirable, permissible, and prohibited. It is desirable if it admonishes against indulgence in this world or attracts one to the Hereafter or encourages noble qualities; it is permissible (i.e. neutral) if it is free of any indecencies and lies; it is forbidden when it is tainted by lies or indecencies. (Ruh-al-Maani)
Finally, it is important to also mention that excessive involvement in poetry or any other art which will make one oblivious to the remembrance of Allah and causes doubts in the mind about beliefs of Islam or helps in promoting spiritual ills will fall under the same ruling as is given for contemptible poetry. In conclusion, poetry is permissible according to sharia when its contents are permissible and it does not cause one to neglect their obligations towards Allah. It is prohibited when it contains lies or obscenities and causes one to neglect their duties towards Allah.