Skip to content

Node fields as components #16580

@tropical32

Description

@tropical32

What problem does this solve or what need does it fill?

In Bevy 0.15, Node's properties like background_color were converted into components, making them easy to override after node creation. However, properties like grid_auto_rows are not components, making it harder to override them after spawning. This inconsistency increases boilerplate when passing all style properties to helper functions, especially if only a few need to be modified.

What solution would you like?

Make all style properties (like grid_auto_rows, grid_row, grid_column) components, as background_color is now. This would allow properties to be overridden after node creation.

What alternative(s) have you considered?

An alternative is to pass all style properties explicitly, even if they aren’t overridden, which leads to unnecessary verbosity. Another approach is modifying node styles directly after creation, but this adds extra steps.

Additional information

A similar thing happens with components that store more than one field like TextFont. If you wish to override only the font size, you have to override the entire component, providing the font file again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-ControversialThere is active debate or serious implications around merging this PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions