# TreeList Column Width

This article explains how to set TreeList column widths and how the component behaves, depending on its column width configuration.

## Basics

The TreeList renders separate HTML `<table>` elements for its header and data areas. This allows users to scroll the data area vertically, while the header area remains visible at all times. The TreeList tables apply `table-layout: fixed` and `width: 100%` CSS styles to ensure column alignment between the three areas.

You can set the TreeList column `Width` parameter in any CSS unit, such as `px`, `%`, `vw`, `em`, `rem`. Unit-less `Width` values are not supported. You can read more on how to set sizes in Telerik components in the [Dimensions](https://www.telerik.com/blazor-ui/documentation/common-features/dimensions) article.

## Column Width Behavior

The TreeList column width settings can vary and result in the following behaviors:

<style>
    table.multi-dimensional-table {
        border-collapse: collapse;
        border-radius: 0 0 0 0;
    }

    .multi-dimensional-table th {
        padding: 8px;
        background: var(--bg-table-th-color);
        color: var(--table-th-color);
        font-weight: 700;
        text-align: left;
        font-size: 18px;
        text-align: center;
    }
    .multi-dimensional-table,
    .multi-dimensional-table th,
    .multi-dimensional-table td {
        border: 1px solid rgba(127, 127, 127, .2);
    }

    table.multi-dimensional-table ul {
        margin: .5em 0;
    }

    table.multi-dimensional-table li {
        font-size: inherit;
        font-weight: inherit;
    }
</style>

<table class="multi-dimensional-table">
    <colgroup><col style="width: 112px" /><col style="width: 70px" /><col /><col /></colgroup>
    <tr>
        <th>&nbsp;</th>
        <th>&nbsp;</th>
        <th colspan="2">The Sum of All Set Column Widths Is:</th>
    </tr>
    <tr>
        <th>&nbsp;</th>
        <th>&nbsp;</th>
        <th>Greater Than the TreeList Width</th>
        <th>Less Than the TreeList Width</th>
    </tr>
    <tr>
        <th style="writing-mode: vertical-lr;" rowspan="3">How Many Columns Have Width:</th>
        <th>All</th>
        <td><ul><li>All columns respect their <code>Width</code> setting.</li><li>A horizontal scrollbar appears.</li></ul></td>
        <td><ul><li>All columns expand beyond their <code>Width</code> setting to fill the available space in the TreeList.</li><li>There is no horizontal scrollbar.</li></ul></td>
    </tr>
    <tr>
        <th>Some</th>
        <td><ul><li>All columns respect their <code>Width</code> setting, if exists.</li><li>All columns without a <code>Width</code> shrink and disappear.</li><li>A horizontal scrollbar appears.</li></ul></td>
        <td><ul><li>All columns respect their <code>Width</code> setting, if exists.</li><li>All columns without a <code>Width</code> shrink or expand, depending on the remaining space in the TreeList.</li><li>There is no horizontal scrollbar.</li></ul></td>
    </tr>
    <tr>
        <th>None</th>
        <td colspan="2"><ul style="margin: .5em auto; width: max-content;"><li>All columns have the same width, which depends on the TreeList width.</li><li>There is no horizontal scrollbar.</li></ul></td>
    </tr>
</table>

To allow the users to adjust or auto-fit the column widths to the content, enable [TreeList column resizing](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/resize). You can also [resize columns through the TreeList state](https://www.telerik.com/blazor-ui/documentation/components/treelist/state#methods) or [auto-fit columns programmatically](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/resize#autofit-columns).

> Single table rendering and automatic table layout are not supported.

## Recommendations

For predictable and user-friendly behavior, consider the following TreeList configuration:

* If the TreeList has a fixed width and you need horizontal scrolling, set widths to all columns. Use absolute units that do not depend on the browser viewport size.
* If the TreeList does not need horizontal scrolling and is not likely to shrink too much, then leave at least one column without a width. This ensures that all set column widths are respected and the width-less columns take up the remaining space.
* If the TreeList width is unpredictable and the width-less columns may shrink too much, then apply a `min-width` style to the TreeList tables, according to the example below.

> caption Apply a minimum width to the TreeList table in a responsive layout

<demo metaUrl="client/treelist/columns/width/example-1/" height="720"></demo>

## See Also

* [Column Resizing](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/resize)
