Vladimir Arkhangelskii
Vladimir Arkhangelskii

Reputation: 120

How can I add a border to my react-konva shape?

I have a React project with TypeScript. I'm using the react-konva package to draw some shapes. How can I add to my shape a border like at HTML (border: 1px solid black)?

My code:

       <Rect
          x={103}
          y={103}
          width={144}
          height={44}
          // here i need a border
          fill="#E2E6EA"
          draggable
          onDragStart={this.handleDragStart}
          onDragEnd={this.handleDragEnd}
        />

Upvotes: 2

Views: 5028

Answers (1)

user11910739
user11910739

Reputation:

You have to set the border using strokeWidth & stroke attributes.

<Rect
    x={103}
    y={103}
    width={144}
    height={44}
    // here i need a border
    fill="#E2E6EA"
    draggable
    onDragStart={this.handleDragStart}
    onDragEnd={this.handleDragEnd}
    strokeWidth={1} // border width
    stroke="red" // border color
/>

Upvotes: 8

Related Questions