The pronunciation of "耽美" (dan mei) is たんび（tan bi） in Japanese. Its original meaning is "beautiful, romantic". For example, "耽美主义" (dan mei zhu yi) is romanticism.
Later, the word was used in BL (boy's love) comics by the Japanese ACGN circle. It was extended to refer to all the "handsome men" and love between men. Finally, it was developed to become one of the alternative names of gay works.