Skip to content

BoxShadow

Configuration for a box's shadow.

属性 ​

名称类型默认值说明
spread_radiusNumber0.0The amount the box should be inflated prior to applying the blur.
blur_radiusNumber0.0The standard deviation of the Gaussian to convolve with the shadow's shape.
colorColorValueColors.BLACKColor used to draw the shadow.
offsetOffsetValueOffset(()The displacement of the shadow from the casting element. Positive x/y offsets will shift the shadow to the right and down, while negative offsets shift the shadow to the left and up. The offsets are relative to the position of the element that is casting it.
blur_styleBlurStyleBlurStyle.NORMALThe blur style to apply to this shadow.

方法 ​

名称类型默认值说明
copy'BoxShadow'—返回此对象的副本,可覆盖指定属性。

示例 ​

Example 1 ​

python
import flet as ft


def main(page: ft.Page):
    page.add(
        ft.SafeArea(
            content=ft.Column(
                controls=[
                    ft.Container(
                        bgcolor=ft.Colors.YELLOW,
                        width=100,
                        height=100,
                        border_radius=50,
                        shadow=[
                            ft.BoxShadow(
                                spread_radius=1,
                                blur_radius=15,
                                color=ft.Colors.WHITE,
                                offset=ft.Offset(-5, -5),
                            ),
                            ft.BoxShadow(
                                spread_radius=1,
                                blur_radius=15,
                                color=ft.Colors.GREY_600,
                                offset=ft.Offset(5, 5),
                            ),
                        ],
                    ),
                    ft.Container(
                        # bgcolor=ft.Colors.WHITE,
                        border_radius=10,
                        width=100,
                        height=100,
                        shadow=ft.BoxShadow(
                            spread_radius=1,
                            blur_radius=15,
                            color=ft.Colors.BLUE_GREY_300,
                            offset=ft.Offset(0, 0),
                            blur_style=ft.BlurStyle.OUTER,
                        ),
                    ),
                ]
            )
        )
    )


if __name__ == "__main__":
    ft.run(main)

关注我,学习大模型、大数据、Python等热门技术。