Fork me on GitHub

Hey all, how can I add style to an element after its creation? I have some a place in my project that creates (h/div {:style "min-width: 40px; min-height:80px;background-color:#ebffca;"} "a"), and then in another place I want to enrich it, like (assoc elem :style "width:100%"). How can I do it?


the attribute value can be a cell that you can modify


do i need to wrap my element in a div? I prefer appending \ overriding the current style of the element without adding a new one. Something like that:

(def a (h/div {:style "..."}))
(update a :style #(str % "..."))


oh, i just realized that h/div is a regular HTML element, so you can mutate the style on it like any HTML thing.. like (set! (.-style elem) "width:100%")

🙌 2