Skip to content

Inline Styles #213

@bnikkhah

Description

@bnikkhah

Is it possible to have inline styles in AlpineJS? I've tried something on CodePen, but nothing was working. Consider the following code:

<div class="box" :style="{ backgroundColor: 'red' }"></div>

Assuming .box has width: 100px;, height: 100px, and a background-color: 'blue', the code above should make the box the color of red, but it does not.

I've tried the same code in VueJS and it did work with inline styles. Here is the same code in VueJS:

<div id="app">
  <div class="box" :style="{ backgroundColor: 'red' }"></div>
</div>

Is there an extra step to consider when working with inline styles in AlpineJS? I didn't see anything mentioned about inline styles in the GitHub documentation.

Thanks for the help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions