⌂
›
Widgets
›
Container
Container
A single-child layout surface for spacing, sizing, alignment, and decoration.
Example
container(
padding: 16,
margin: 12,
border_radius: 12,
bgcolor: "#111827",
content: text(value: "Card content")
)
Common properties
contentpaddingmarginwidthheightexpandbgcolorborderborder_radiusalignmenton_click
Usage
Use container when a control needs its own box, spacing, or click surface:
container(
expand: true,
alignment: "center",
content: text(value: "Centered")
)
Notes
containertakes one nested child throughcontent:alignment: "center"is normalized by Ruflet for convenience
Complete API
Helpers
center(**props, &block)container(**props, &block)
Accepted properties
adaptive— Adapts to the platform (Material/Cupertino) when true.align— Alignment of the control within its parent.alignment— Alignment of the content within the control.animate— Sets the animate property.animate_align— Animates alignment changes.animate_margin— Animates margin changes.animate_offset— Animates offset changes.animate_opacity— Animates opacity changes.animate_position— Animates position changes.animate_rotation— Animates rotation changes.animate_scale— Animates scale changes.animate_size— Animates size changes.aspect_ratio— Width-to-height ratio to maintain.badge— Badge drawn on the corner of the control.bgcolor— Background color.blend_mode— Sets the blend mode property.blur— Sets the blur property.border— Border definition.border_radius— Corner radius.bottom— Bottom offset when positioned inside a stack.clip_behavior— How content overflowing the bounds is clipped.col— Responsive column span (1-12) per breakpoint.color_filter— Sets the color filter property.content— The single child control rendered inside this control.dark_theme— Sets the dark theme property.data— Arbitrary value you can attach to the control and read back in handlers.disabled— Disables interaction when true.expand— Fills the available space along the parent's main axis when true.expand_loose— Like expand, but only grows up to the child's natural size.foreground_decoration— Sets the foreground decoration property.gradient— Sets the gradient property.height— Fixed height in logical pixels.ignore_interactions— Sets the ignore interactions property.image— Sets the image property.ink— Sets the ink property.ink_color— Ink color.key— Stable identity used to preserve state across rebuilds.left— Left offset when positioned inside a stack.margin— Outer spacing around the control.offset— Translation offset applied to the control.opacity— Opacity from 0.0 (transparent) to 1.0 (opaque).padding— Inner spacing between the border and the content.right— Right offset when positioned inside a stack.rotate— Rotation applied to the control.rtl— Renders right-to-left when true.scale— Scale transform applied to the control.shadow— Sets the shadow property.shape— Shape/border of the control.size_change_interval— Throttle interval for on_size_change, in ms.theme— Sets the theme property.theme_mode— Sets the theme mode property.tooltip— Text shown on hover/long-press.top— Top offset when positioned inside a stack.url— URL the control loads or links to.visible— Hides the control when false.width— Fixed width in logical pixels.
Events
on_animation_end— Fired when an animation completes.on_click— Fired when the control is clicked/tapped.on_hover— Fired when the pointer enters/leaves the control.on_long_press— Fired on a long press.on_size_change— Fired when the control's size changes.on_tap_down— Fired when a pointer presses down.
Wire reference
- Family:
materials - Widget type:
container