Lesson 36 of 50 · Web pages

Borders, radius and shadows

A border is part of the box and takes space. An outline and a shadow do not. This lesson shows each with the same three-part form: width, style, colour.

Border

border takes width, style and colour in any order: border = 2, solid, #3366aa. The styles are solid, dashed, dotted, double and none. One side has its own property (border bottom, border start), and the parts have theirs (border width, border style, border color).

Radius and outline

radius takes one to four lengths for the corners, or one corner such as radius top start. outline is written like a border but is drawn outside the box and takes no space; outline offset moves it away.

dsl-borders.salam
page:
    title = "Borders"
    box:
        layout = row
        gap = 16
        padding = 16
        box: width = 100 height = 80 border = 2, solid, #3366aa end
        box: width = 100 height = 80 border = 2, dashed, #3366aa radius = 16 end
        box: width = 100 height = 80 border bottom = 4, solid, #dc2626 end
        box: width = 100 height = 80 radius = 40, 0, 40, 0 background = #bbf7d0 end
        box: width = 100 height = 80 outline = 3, solid, #f59e0b outline offset = 4 end
    end
end

Shadows

shadow takes x, y, blur, spread and colour, and the word inset for an inner shadow. Square brackets group one shadow when you list several.

dsl-shadow.salam
page:
    title = "Shadows"
    box:
        layout = row
        gap = 24
        padding = 24
        background = #f3f4f6
        box: width = 100 height = 80 background = white radius = 8 shadow = 0, 4, 8, #00000040 end
        box: width = 100 height = 80 background = white radius = 8 shadow = [0, 4, 8, #00000040], [0, 1, 2, red] end
        box: width = 100 height = 80 background = white radius = 8 shadow = inset, 0, 2, 6, #00000040 end
    end
end

Next: layout.