Skip to content

Conversation

@ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Oct 27, 2025

Objective

Allows users to override TextColor and use a custom color for underline and strikethrough text decorations.

Solution

New components UnderlineColor and StrikethroughColor. Add them to a text entity with Underline or Strikethrough, respectively, to use a custom color for the lines.

This could just be an optional color field on Underline or Strikethrough, that would be fine. I spent a while going back and fourth about it. The main reasons why I went with a separate component:

  • The same color is almost always used for both text and its decorations. Overriding TextColor is going to be rare.
  • Once we have some sort of global or propagated text style support, underline and strikethrough colors probably won't be set per entity.

The single component approach has some advantages too. Discoverability, obviously. Also compare:

(
    Text::new("Hello"),
    Underline,
    UnderlineColor(RED.into())
)

with

(
    Text::new("Hello"),
    Underline::color(RED),
)

which seems clearly nicer. If it weren't for the planned non-entity-local text styling support, I'd lean more towards the single component approach.

Testing

Added a few color overrides to this example:

cargo run --example strikethrough

Showcase

strike-under-color

Copy link
Member

@mnmaita mnmaita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and using separate components for the colors sounds sensible to me.

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it M-Release-Note Work that should be called out in the blog due to impact X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Oct 29, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 29, 2025
Merged via the queue into bevyengine:main with commit 051a393 Oct 29, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Release-Note Work that should be called out in the blog due to impact S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants