Border
Border
#
A border comprised of four sides: top
, right
, bottom
, left
.
Each side of the border is an instance of
BorderSide
.
Example
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)