---
title: HWDecoratedBox
description: Decorate a child with a background color, border and rounded corners.
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.page/abausg/home_widget/llms.txt
> Use this file to discover all available pages before exploring further.

# HWDecoratedBox

Wraps a child with an `HWBoxDecoration` — an optional [`HWColor`](/generator/styling/hw-color) background, an optional `HWBoxBorder` and an optional `HWBorderRadius`. For a plain solid fill, prefer [`HWColoredBox`](/generator/widgets/hw-colored-box).

```dart
HWDecoratedBox(
  decoration: HWBoxDecoration(
    color: HWColor.fixed(0xFF222222),
    borderRadius: HWBorderRadius.circular(12),
    border: HWBoxBorder(
      thickness: 1,
      color: HWColor.fixed(0xFFFFFFFF),
    ),
  ),
  child: HWText.fixed('Boxed'),
)
```

`HWBoxBorder` requires `thickness` and `color`. The border is drawn inside the box, like Flutter's default `BorderSide.strokeAlignInside`: SwiftUI strokes it with `strokeBorder`, and Glance, which has no stroke, gets an inside-border approximation.

`borderRadius` rounds the background and the border alike, with or without either of the two. Like Flutter's `DecoratedBox`, it does not clip the child.

The decoration covers all the room the box gets, like Flutter's `DecoratedBox`: an [`HWSizedBox`](/generator/widgets/hw-sized-box) around it or inside it fills the whole box with the color, rounded corners included, and inside an `HWColumn` / `HWRow` the decorated box takes the weight an expanded child asks for.

## Parameters

### HWDecoratedBox

| Name         | Type               | Default      | Description                              |
| ------------ | ------------------ | ------------ | ---------------------------------------- |
| `child`      | `HWWidget`         | **required** | Widget being decorated.                  |
| `decoration` | `HWBoxDecoration`  | **required** | Background color, border and corners.    |

### HWBoxDecoration

| Name           | Type              | Default | Description                                   |
| -------------- | ----------------- | ------- | --------------------------------------------- |
| `color`        | `HWColor?`        | `null`  | Background color.                             |
| `border`       | `HWBoxBorder?`    | `null`  | Border specification.                         |
| `borderRadius` | `HWBorderRadius?` | `null`  | Corner radius of the background and border.   |

### HWBorderRadius

| Constructor                              | Description                                                 |
| ---------------------------------------- | ----------------------------------------------------------- |
| `HWBorderRadius.circular(double radius)` | The same radius on every corner, in logical pixels.         |

### HWBoxBorder

| Name        | Type      | Default      | Description   |
| ----------- | --------- | ------------ | ------------- |
| `thickness` | `double`  | **required** | Border width. |
| `color`     | `HWColor` | **required** | Border color. |

## Platform mapping

- **iOS:** SwiftUI [`.background(_:)`](https://developer.apple.com/documentation/swiftui/view/background(_:ignoressafeareaedges:)) and [`.overlay(_:)`](https://developer.apple.com/documentation/swiftui/view/overlay(alignment:content:)) with `strokeBorder` for the border, both a `RoundedRectangle(cornerRadius:)` once a radius is set.
- **Android:** `background(...)` and `cornerRadius(...)` on the child's own composable, or a Glance [`Box`](https://developer.android.com/reference/kotlin/androidx/glance/layout/package-summary#Box(androidx.glance.GlanceModifier,androidx.glance.layout.Alignment,kotlin.Function1)) of its own with a nested-`Box` border approximation, whose fill is rounded by the radius less the border thickness.
