Figma Support Forum

Dashed strokes

Hi,

I want to have dashed strokes around rectangles but I can’t find a way. I apparently cannot change stroke type from SOLID to DASH:

const outline = figma.createRectangle();
    outline.x = xmin - 3 - radius;
    outline.y = ymin - 3;
    outline.resize(xmax - xmin + 6 + radius, ymax - ymin + 6);
    outline.cornerRadius = 5;
    const fills_outline = clone(outline.fills);
    fills_outline[0].opacity = 0;
    outline.fills = fills_outline;
    const stroke_outline: SolidPaint = {
        type: "SOLID",
        color: red
    }
    outline.strokes = [stroke_outline];
    outline.strokeWeight = 2;
    outline.strokeAlign = "CENTER";

Thanks,
Antoine

“DASH” does not exist. I think you want to set the dashPattern of the rectangle instead. Note this is a readonly array, so you’ll need to follow the instructions for editing properties. Hope that helps!