Skip to content

feat: allow objects for style attribute #14832

Open
@adiguba

Description

@adiguba

Describe the problem

Since #14714, Svelte allow objects/arrays for class attribute.
I think there should be an equivalent for the style attribute, at least for objects (I don't see any usage for array).

Describe the proposed solution

I expect to have something like this :

<div style={{
	'font-size': size,
	border: "1px solid",
	color
}}>
   ...
</div>

This could be easily done by wrapping the object into a function, but I think this could be handheld internaly.

Example :

https://svelte.dev/playground/hello-world?version=5.16.0#H4sIAAAAAAAACq1S24rbMBD9lakI2IbUbkpZimMH-tS-9QPWC-vLuOtEkYQ0TrM1_vdKirOJqfetGIN0zszozMwZmCiPyFL2AzmX8Ftq3kCITUfYRGzN2o6jYenjwOhVuTgHWHzK-qZUbE7IyWFVaXAJr6UgFGTLsMzUulO0K0RB3VFJTTBAbcwZRmi1PEIQJ-4a702wdUHu50hQSy415LAyVBKGQcXL-hBE2ytvuj94R28e1NmzWXJ7UWQGOdYEVSea9FTyHvPBFx69oEwq6qTY-dpZMt3mTI-LxC-NKBYZjc0dbuV4CbtlMa6LuZbNJ3VerOs6XCQ-f3mP-Doj7qT4MYvsZQOGXrkbil1BODgiaO3yPjpdQeqHvHZoJXWDOoWCbdQZjORdUzDP-HEWYozGnT-mME0YEp9u777JLHnZXHaiNNrDdxSo7eqaiwRIr8v_L1qy5PKK-6whCc_EUtI9jut3jD2ZcO7qG3hn6cJW80Zue1G72Xo_hyYCL9r6vIXQQJ6D6Dl_QwvSSL0WHr1YncZbghMlW3B5OQSy2ttNBf8m__REbKXoDo199MoXFNuGCHUYPq5PTxHkOzjBh0nEXdSxVDbkcI15Xg2HMV0Np_H5LQog3stOhME2iGZCJxHGyx_ng30a_wKyD94cWwQAAA==

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions