# Max Width

## Introduction

The `Max Width` variable sets the maximum width in pixels. The value is applied after all other layout so it can be used to overwrite automatically-assigned width.

By default this value is `<NULL>` which means there is no `Max Width`.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-605643ba60c5a81c3712adaf867abde4117cef31%2F13_06%2038%2036.gif?alt=media" alt=""><figcaption><p>A ColoredRectangle with no <code>Max Width</code></p></figcaption></figure>

If `Max Width` is assigned (not `<NULL>`), then the effective width cannot be larger than the `Max Width` value. The following animation shows that width is limited to a `Max Width` of `100`.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-0b6784d890fa49979cdf4550d95756e542a758d3%2F13_06%2040%2031.gif?alt=media" alt=""><figcaption><p><code>Max Width</code> set to <code>100</code> limits the ColoredRectangle's width</p></figcaption></figure>

Notice that the `Width` variable can still be set to a value larger than `Max Width`, but it does not apply visually.

`Max Width` can also be used if `Width Units` is set to values other than `Absolute`. For example, `Max Width` can be used to limit the width of a ColoredRectangle when `Width Units` is `Relative to Parent`.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-6ead249986d37078c78f9ea08756a6c0539dafe6%2F13_06%2045%2003.gif?alt=media" alt=""><figcaption><p>ColoredRectangle's width limited by its <code>Max Width</code> of <code>100</code></p></figcaption></figure>

## Max Width and Relative to Children

Note that Max Width can prevent a container from growing according to its children. For more information, see the [Relative to Children Width Units page](https://docs.flatredball.com/gum/gum-tool/gum-elements/width-units#relative-to-children).
