WContainer
A utility-first container widget that wraps Flutter's Container, styled directly with Wind className utilities.
WContainer(
className: 'bg-gray-200 p-4 rounded-lg dark:bg-gray-800',
child: WText('This is a container', className: 'text-lg text-gray-700 dark:text-gray-200'),
);
Basic Usage
A bordered, rounded card-like box: A fixed-size, centered tile:WContainer is the Wind equivalent of an HTML child; it does not lay out multiple children. For multi-child flex layouts reach for WFlex or WFlexContainer.
WContainer(
className: 'bg-blue-500 p-4 rounded-lg shadow-md dark:bg-blue-700',
child: WText('This is a container', className: 'text-white text-lg'),
);
Constructor
WContainer({
Key? key,
dynamic className = '',
AlignmentGeometry? alignment,
EdgeInsetsGeometry? padding,
Color? color,
Decoration? decoration,
Decoration? foregroundDecoration,
double? width,
double? height,
BoxConstraints? constraints,
EdgeInsetsGeometry? margin,
Matrix4? transform,
AlignmentGeometry? transformAlignment,
Widget? child,
Clip clipBehavior = Clip.none,
});
Props
Prop
Type
Default
Description
classNamedynamic''Wind utility class string applied to the container.
childWidget?nullThe single widget wrapped by the container.
alignmentAlignmentGeometry?nullAligns the child within the container; overrides any
alignment-* utility.
paddingEdgeInsetsGeometry?nullInner padding; overrides any
p-* utility.
colorColor?nullBackground color; overrides any
bg-* utility.
decorationDecoration?nullFull box decoration; when set, overrides the utility-driven background, border, and shadow.
foregroundDecorationDecoration?nullDecoration painted in front of the child.
widthdouble?nullFixed width; overrides any
w-* utility.
heightdouble?nullFixed height; overrides any
h-* utility.
constraintsBoxConstraints?nullBox constraints; overrides utility-driven min/max sizing.
marginEdgeInsetsGeometry?nullOuter margin; overrides any
m-* utility.
transformMatrix4?nullTransformation matrix applied before painting.
transformAlignmentAlignmentGeometry?nullOrigin of the
transform relative to the container's size.
clipBehaviorClipClip.noneHow content is clipped to the container bounds.
Supported Utility Classes
Class Type
Example
Documentation
Responsive Design
sm:p-4, xs:mt-2Responsive Design
Flex-x
flex-1, flex-3Flex-x
Flex Fit Classes
flex-grow, flex-autoFlex Fit Classes
Alignment
alignment-top-leftAlignment
Padding
p-4, p-[11]Padding
Margin
m-8, m-[4]Margin
Width
w-10, w-[30]Width
Height
h-10, h-[30]Height
Max-Width & Min-Width
max-w-10, min-w-10Max-Width & Min-Width
Max-Height & Min-Height
max-h-10, min-h-10Max-Height & Min-Height
Background Color
bg-red-500, bg-greenBackground Color
Border Width
border-4, border-[6]Border Width
Border Color
border-red-500, border-[#1abc9c]Border Color
Border Radius
rounded-lg, rounded-fullBorder Radius
Shadow
shadow-sm, shadow-lgShadow
Display Classes
hide, show, sm:hideDisplay
Styling Examples
WContainer(
className: 'bg-white border-2 border-gray-200 rounded-lg p-4 dark:bg-gray-900 dark:border-gray-700',
child: WText('Bordered box', className: 'text-gray-800 dark:text-gray-100'),
);
WContainer(
className: 'w-[120] h-[120] bg-blue-500 alignment-center rounded-lg',
child: WText('Centered', className: 'text-white'),
);
Related Documentation