2

I have something like this:

<Stage>
  <Layer>
    <Rect />
      <Text
        ref={this.text}
        draggable 
        align="center"
      />
  </Layer>
</Stage>

The text is aligned in the center, but I need to align it vertically. How can I do this?

I know with plain canvas you can do textBaseline="center", but what's the equivalent for Konva?

Colin Ricardo
  • 16,488
  • 11
  • 47
  • 80

1 Answers1

2

From Konva v2.3.0 you can use verticalAlign property:

<Text
  x={20}
  y={20}
  width={150}
  height={50}
  text="vertical align"
  verticalAlign="middle"
/>

https://codesandbox.io/s/4xorl71m77

lavrton
  • 18,973
  • 4
  • 30
  • 63