# Conditional css binding

**URL:** <https://forum.builder.io/t/conditional-css-binding/1812>\
**Category:** Technical Questions\
**Tags:** visual-editor\
**Created:** [February 28, 2022, 4:58pm UTC](https://forum.builder.io/t/conditional-css-binding/1812 "2022-02-28T16:58:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![radikris](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@radikris](https://forum.builder.io/u/radikris)\
**Post date:** [February 28, 2022, 4:58pm UTC](https://forum.builder.io/t/conditional-css-binding/1812/1 "2022-02-28T16:58:55Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/8/89f4894f9bf3e5a635274c5c684854275620575c.jpeg)

Hi!

I would like to add dynamic conditional css:

Like if the state.data.image!=null then the box under it should be align center, but if state.data.image==null then it should align left. how can I achieve this?

Link: [Builder.io: Drag and drop page builder and CMS](https://builder.io/content/947209e5cd08415aa9a15028000f1a16)

---

<div class="post-metadata">

**Author:** ![TimG](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/timg/32/714_2.png) [@TimG](https://forum.builder.io/u/TimG)\
**Post date:** [February 28, 2022, 5:36pm UTC](https://forum.builder.io/t/conditional-css-binding/1812/2 "2022-02-28T17:36:36Z")

</div>

@radikris Great question, yes this is definitely possible. Select the item you want to style, and then in the data tab you would add an element binding to the style object for that element.

 ![Screen Shot 2022-02-28 at 9.35.18 AM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/8/8982febb1520b4c10711893ad7300164824350d1.png)

So in the example above, you would add a new binding for Get `style.justifyContent` and then in the from input you would put your logic:

![Screen Shot 2022-02-28 at 9.35.56 AM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/4/421b73bd19ba5ec3f925e37ab4ab97f8e526e0e4.png)

Try it out and let me know if that works!

---

<div class="post-metadata">

**Author:** ![radikris](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@radikris](https://forum.builder.io/u/radikris)\
**Post date:** [February 28, 2022, 6:22pm UTC](https://forum.builder.io/t/conditional-css-binding/1812/3 "2022-02-28T18:22:44Z")

</div>

yes, that was it, thanks, although I am sorry that this binding is not scoped to the specific device size. So if I want to center it only in mobile view it is not possible with this approach?

UPDATE found the answer, I can check it through state.deviceSize and use conditional css!
