v0.6.22

Style Binding

Last updated


This page covers binding data straight to inline styles with :[CSS property].

Syntax


  1. <div id="app">
  2. <button :width="width" :background-color="color">Save</button>
  3. </div>
  4. <script>
  5. const app = new QUI({ id: "app", data: { width: "120px", color: "#3498db" } });
  6. </script>
Live preview · @pardnchiu/quickui@0.6.22

Result:
  1. <button style="width: 120px; background-color: #3498db;">Save</button>

RuleDescription
NameA kebab-case CSS property name whose camelCase form exists on element.style
ValueThe data value or the attribute value itself, including units, for example "120px"
PrefixOnly :; q-width does not reach style and sets the width attribute instead
:animationValues fade-in and expand are not written to style; they are treated as Render Effects

Legacy Names


The forms below still work but are planned for removal in 1.0.0; see Deprecations.
LegacyUse instead
:bg-* such as :bg-color, :bg-image:background-color, :background-image
camelCase such as :borderRadius, :backgroundColor:border-radius, :background-color
中文