# How `show_width_threshold` Controls Column Visibility in Outfancy Terminal Tables

> Learn how show_width_threshold in Outfancy controls terminal table column visibility. Discover how it hides columns below a set width to optimize display on narrow screens.

- Repository: [Carlos A. Planchón/outfancy](https://github.com/carlosplanchon/outfancy)
- Tags: deep-dive
- Published: 2026-02-26

---

**`show_width_threshold` defines the minimum column width a column must retain to stay visible; when the terminal is too narrow, columns that fall below this limit are progressively hidden starting with the lowest-priority ones.**

Outfancy is a Python library for rendering elegant tables in the terminal. The `show_width_threshold` setting acts as a visibility guard that determines which columns survive when horizontal space is constrained, ensuring readable output even on small screens.

## What Is `show_width_threshold`?

`show_width_threshold` is a **column-width guard** that specifies the minimum number of characters a column must occupy to remain in the rendered output. According to the Outfancy source code in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py), the renderer evaluates every column against this threshold during the width-calculation phase.

### Default Value and Configuration

The default threshold is **5 characters**, initialized in the `Table` class constructor at line 59:

```python
self.show_width_threshold = 5

```

You can modify this value at runtime using the `set_show_width_threshold` method (lines 180-186). The library also includes validation logic (lines 1197-1205) to handle cases where the threshold value might be missing or invalid.

## How Column Removal Works in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py)

When Outfancy renders a table, it follows a specific algorithm in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py) to decide which columns to display based on available terminal width.

### Identifying Narrow Columns

During width assignment, the code records two distinct groups of columns:

1. **Columns whose maximum content width is already smaller than the threshold** — These are tracked in the `maxima_less_than_show_width_threshold` list (lines 1256-1258).
2. **Columns that receive an assigned width below the threshold** — After initial calculations, the code checks `if width[column] < self.show_width_threshold` (lines 1301-1306).

### The Removal Loop

If a column falls into the second group and is **not** already in the first group, the rendering loop sets `not_finished = True`. This triggers a `while not_finished` block (lines 1309-1324) that repeatedly recomputes widths and removes the lowest-priority column from the layout until every remaining column meets the threshold or no columns remain.

This ensures that when space is limited, the narrowest columns disappear first, prioritizing columns with higher importance.

## Changing the Threshold at Runtime

Adjust the threshold dynamically to control column density in your output. A lower threshold keeps more columns visible, while a higher threshold hides narrow columns sooner:

```python
from outfancy import Table

t = Table()

# Allow narrower columns (3 characters minimum)

t.set_show_width_threshold(3)

# Or require wider columns (10 characters minimum) to stay visible

t.set_show_width_threshold(10)

print(t.render(my_data))

```

## Summary

- **`show_width_threshold`** sets the minimum width in characters that a column must maintain to remain visible.
- The default value is **5 characters**, defined in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py) at line 59.
- Columns are removed in a priority-based order when their assigned width falls below the threshold, as implemented in the removal loop (lines 1309-1324).
- Use **`set_show_width_threshold()`** to adjust the limit at runtime based on your terminal size or readability requirements.

## Frequently Asked Questions

### What happens if a column's content is naturally smaller than `show_width_threshold`?

If a column's maximum content width is already less than the threshold, it is added to the `maxima_less_than_show_width_threshold` group (lines 1256-1258). These columns are exempt from the removal logic, meaning they remain visible even if their assigned width is below the threshold.

### How does Outfancy decide which columns to hide first?

The library removes columns based on **priority**, starting with the lowest-priority columns. This happens inside the `while not_finished` loop in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py) (lines 1309-1324), which continues dropping columns until all remaining ones meet the `show_width_threshold` or no columns are left.

### Can I disable column hiding entirely?

While there is no explicit "disable" flag, you can effectively prevent column removal by setting `show_width_threshold` to `1` or `0` using `set_show_width_threshold(1)`. This ensures that even single-character columns remain visible, though the table may become unreadable on narrow terminals.

### Where is the threshold validation handled?

Input validation and fallback logic for the threshold value occur at lines 1197-1205 in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py). This ensures that invalid or missing threshold values do not crash the rendering process.