Constant freya_elements::elements::rect::corner_radius

source ·
pub const corner_radius: (&'static str, Option<&'static str>, bool);
Expand description

Round the corners of an element by a specified radius.

The corner_radius attribute follows this syntax: corner_radius: <all> | <tl-tr> <bl-br> | <tl> <tr> <br> <bl>

  • Single value: Applied to all corners
  • Two values: First for top-left & top-right, second for bottom-left & bottom-right
  • Four values: Top-left, top-right, bottom-right, bottom-left (clockwise from top-left)

This creates rounded corners on rectangular elements like rects or buttons.

§Example

fn app() -> Element {
    rsx!(
        rect {
            corner_radius: "10" // All corners
        }
    )
}
fn app() -> Element {
    rsx!(
        rect {
            corner_radius: "10 5" // 10 for top corners, 5 for bottom corners
        }
    )
}
fn app() -> Element {
    rsx!(
        rect {
            corner_radius: "10 20 30 40" // Different radius for each corner
        }
    )
}