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
Currently
textDecoration: "underline"draws the underline using the same color asfill. There's no way to set a different underline color, width, or style.Use cases:
Proposed API (mirrors CSS
text-decorationsub-properties):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