# How to Disable Label Rendering in Outfancy Tables: 2 Proven Methods

> Learn two effective methods to disable label rendering in Outfancy tables. Control label visibility globally or per-render for cleaner table outputs.

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

---

**You can disable label rendering in outfancy tables either globally by calling `set_show_labels(False)` on the Table instance, or per-render by passing `label_list=False` to the `render()` method.**

Outfancy provides a lightweight Python library for rendering formatted tables in terminal environments. When you need to display raw data without column headers, disabling label rendering gives you cleaner output for automated processing or minimalist displays.

## Understanding the Label Rendering Pipeline

Outfancy’s table rendering pipeline constructs output through three distinct phases implemented in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py):

1. **Data preparation** – Columns are reordered, widths are calculated, and the table body (`pre_table`) is generated.
2. **Label handling** – The `check_label_list` function creates or validates the list of column headers.
3. **Final composition** – The `post_render` method concatenates the optional label line with the table body.

The **visibility of the label line** depends on two control points: the `self.show_labels` instance attribute (default `True` at line 177) and the `label_list` parameter passed to `render()`. The final guard at line 273 in `post_render` only includes the header when `label_list is not False` **and** `self.show_labels` is `True`.

## Global Disabling Using set_show_labels()

For consistent header suppression across multiple render calls, toggle the `show_labels` attribute using the public API setter.

The `Table.set_show_labels()` method (defined at line 187 in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py)) modifies the instance flag that governs whether `post_render` includes the label line:

```python
from outfancy import Table

tbl = Table()
tbl.set_show_labels(False)  # Disable headers for this instance

print(tbl.render(dataset))  # No header line appears

```

This approach affects every subsequent call to `render()` until you explicitly re-enable labels.

## Per-Render Disabling Using the label_list Parameter

When you need occasional header suppression without changing the Table’s global state, pass `label_list=False` directly to the `render()` method:

```python
from outfancy import Table

tbl = Table()

# Suppress header only for this specific render call

print(tbl.render(dataset, label_list=False))

```

This parameter overrides the `self.show_labels` flag for a single execution, making it ideal for conditional formatting logic.

## Practical Code Examples

The following examples demonstrate both approaches using the included example dataset.

### Example 1: Global Disable

```python
from outfancy import Table, example_dataset

t = Table()
t.set_show_labels(False)  # Turn off headers permanently for this instance

print(t.render(example_dataset.dataset))

```

### Example 2: Disable for a Single Render

```python
from outfancy import Table, example_dataset

t = Table()

# Instance retains default show_labels=True, but this call skips the header

print(t.render(example_dataset.dataset, label_list=False))

```

### Example 3: Re-enabling Labels After Disabling

```python
from outfancy import Table, example_dataset

t = Table()
t.set_show_labels(False)
print("Without labels:")
print(t.render(example_dataset.dataset))

t.set_show_labels(True)  # Re-enable headers

print("\nWith labels:")
print(t.render(example_dataset.dataset))

```

## Summary

- **Global control**: Use `Table.set_show_labels(False)` to disable labels for all future renders on that instance.
- **Per-call control**: Pass `label_list=False` to `render()` to suppress headers for a single output.
- **Default behavior**: The `show_labels` attribute defaults to `True` in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py) line 177.
- **Implementation**: The `post_render` method at line 273 contains the logic gate that checks both flags before including the header line.

## Frequently Asked Questions

### What is the default behavior for labels in outfancy tables?

By default, outfancy displays column labels. The `show_labels` attribute initializes to `True` in the `Table` class constructor located at [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py) line 177, causing `post_render` to include the header line unless explicitly disabled.

### Can I toggle label visibility multiple times on the same Table instance?

Yes. The `set_show_labels()` method is a runtime setter that you can call repeatedly. Each call updates the instance attribute immediately, affecting only the subsequent `render()` invocations without requiring you to recreate the Table object.

### Where is the label rendering logic implemented in the source code?

The core logic resides in [`outfancy/table.py`](https://github.com/carlosplanchon/outfancy/blob/main/outfancy/table.py). The `check_label_list` function handles header validation, while the final rendering decision occurs in `post_render` at line 273, which checks both `self.show_labels` and the `label_list` parameter before concatenating the header.

### Does disabling labels affect table width calculations?

No. Width calculations occur during the data preparation phase before label handling. Whether you disable labels globally or per-render, column widths are determined by the dataset content, ensuring consistent alignment between labeled and unlabeled outputs.