---
title: Tables
---

# Tables

<div class="documentation__toc"></div>

## Introduction

The `table` plugin function allows you to initialize, configure, and display a table builder inline within a view.

### Displaying Tables

The easiest way to display a table is to use the `table` function and specify the `namespace` and `stream` slug.

The `render` method will trigger display but it is optional as `__toString` will result in the same thing.

```twig
{{ table('books', 'reviews').render()|raw }}
```

You may want to take more control and set the table to a variable and use it.

```twig
{% set table = table('books', 'reviews') %}

{{ table.render|raw }}
```

### Binding Table Builders

The `table` function makes use of a generic table `builder` class by default. Often times, however, you want to build and use a specific table builder. The easiest way to use said builder in the `table` function is to `bind` it to the service container.

You can define a table builder `binding` within a service provider.

[Service Providers](../the-basics/service-providers){.link}
[Table Builders](../ui/tables){.link}

```php
protected $bindings = [
    'employment_applicants_table' => \Anomaly\ExampleModule\Applications\Table\PublicApplicantsTableBuilder::class
];
```

After binding the table builder you can use it by specifying the bound `key`.

```twig
{{ table('employment_application').render()|raw }}
```


## Table Components

You can work with table `components` similarly as to how you would work with a table `builder`.

[Table Builders](../ui/tables){.link}

[Table Components](../ui/tables/components){.link}


## Configuring Tables

You can configure tables inline to an extent. Which is sometimes easier than writing a dedicated table builder.

Generally you can interact with the table `criteria` the same as you would with a table `builder` instance.

[Table Builders](../ui/tables){.link}

[Table Configuration](../ui/tables/configuration){.link}

### Setting Options

You can set options by using the `setOption` method.

[Table Options](../ui/tables/configuration/options){.link}

```twig
{{ table('employment_application')
    .setOption('redirect', url_previous())
    .render()|raw }}
```
