Skip to content

Border

Border #

A border comprised of four sides: top, right, bottom, left.

Each side of the border is an instance of BorderSide.

Example
container_1.border = ft.Border.all(10, ft.Colors.PINK_600)
container_1.border = ft.Border.only(bottom=ft.BorderSide(1, "black"))

bottom #

bottom: BorderSide = field(default_factory=lambda: none())

Bottom side of the border.

left #

left: BorderSide = field(default_factory=lambda: none())

Left side of the border.

right #

right: BorderSide = field(default_factory=lambda: none())

Right side of the border.

top #

top: BorderSide = field(default_factory=lambda: none())

Top side of the border.

all #

all(
    width: Number | None = None,
    color: ColorValue | None = None,
    side: BorderSide | None = None,
) -> Border

Creates a border whose sides are all the same.

If side is not None, it gets used and both width and color are ignored.

copy_with #

copy_with(
    *,
    left: BorderSide | None = None,
    top: BorderSide | None = None,
    right: BorderSide | None = None,
    bottom: BorderSide | None = None,
) -> Border

Returns a copy of this Border instance with the given fields replaced with the new values.

only #

only(
    *,
    left: BorderSide | None = None,
    top: BorderSide | None = None,
    right: BorderSide | None = None,
    bottom: BorderSide | None = None,
) -> Border

Creates a Border from the given values.

symmetric #

symmetric(
    *,
    vertical: BorderSide | None = None,
    horizontal: BorderSide | None = None,
) -> Border

Creates a border with symmetrical vertical and horizontal sides.

The vertical argument applies to the left and right sides, and the horizontal argument applies to the top and bottom sides.

Examples#

Example 1#

import flet as ft


def main(page: ft.Page):
    page.title = "Containers with different borders"

    page.add(
        ft.Row(
            controls=[
                ft.Container(
                    bgcolor=ft.Colors.AMBER,
                    padding=15,
                    border=ft.Border.all(10, ft.Colors.PINK_600),
                    border_radius=ft.border_radius.all(30),
                    width=150,
                    height=150,
                ),
                ft.Container(
                    bgcolor=ft.Colors.DEEP_PURPLE,
                    padding=15,
                    border=ft.Border.all(3, ft.Colors.LIGHT_GREEN_ACCENT),
                    border_radius=ft.border_radius.only(top_left=10, bottom_right=10),
                    width=150,
                    height=150,
                ),
                ft.Container(
                    bgcolor=ft.Colors.BLUE_GREY_900,
                    padding=15,
                    border=ft.Border.symmetric(
                        vertical=ft.BorderSide(8, ft.Colors.YELLOW_800)
                    ),
                    width=150,
                    height=150,
                ),
            ]
        )
    )


ft.run(main)