Skip to content

Feature: textDecorationColor property for Text nodes #2037

@rcoenen

Description

@rcoenen

Currently textDecoration: "underline" draws the underline using the same color as fill. There's no way to set a different underline color, width, or style.

Use cases:

  • Selection/hover highlights: blue underline while text retains its original color
  • Spell/grammar check: red wavy underline on misspelled words
  • Strikethrough pricing: colored line-through on old prices
  • Rich text editors: full decoration control matching CSS capabilities

Proposed API (mirrors CSS text-decoration sub-properties):

const text = new Konva.Text({
  text: 'Hello world',
  fill: '#ffffff',
  textDecoration: 'underline',
  textDecorationColor: '#18A0FB',   // decoration color independent of fill
  textDecorationWidth: 2,           // override default thickness (fontSize / 15)
  textDecorationStyle: 'wavy',      // solid | dashed | dotted | double | wavy
});

When not set, all three fall back to existing behavior (no breaking changes).

Workaround: Render two stacked Text nodes — one behind with the desired underline color as fill + textDecoration: "underline", and the original on top. Works but doubles draw calls.

PR: #2038

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