> ## Documentation Index
> Fetch the complete documentation index at: https://quill.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Table

> The Tabular view of a Quill Report

```tsx App.tsx theme={null}
import { QuillProvider, Table } from "@quillsql/react";

const MyTable = () => (
  <QuillProvider tenants={[{ tenantField: "customer_id", tenantIds: [2] }]} publicKey={process.env.QUILL_PUBLIC_KEY}>
    <Table reportId="6644088e6e2470000cbdb109" />
  </QuillProvider>
);
```

A simple component that displays the given data as a table.

<Info>Make sure `QuillProvider` is a parent of the `Table` component.</Info>

## Examples

<Tabs>
  <Tab title="Ant Design">
    [![Edit \[Ant Design\] Quill React Components](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/p/devbox/ant-design-quill-react-components-9qcs8k?embed=1)

    ```tsx theme={null}
    import { Table, useQuill } from "@quillsql/react";
    import { AntTable } from "./ui/ant/Table";

    export function AntDesignTable() {
      const report = useQuill("6644088e6e2470000cbdb109");
      if (!report || !report.data) return null;
      return <AntTable rows={report.data.rows} columns={report.data.columns} />;
    }
    ```
  </Tab>

  <Tab title="Material Design">
    [![Edit \[Material Design\] Quill React Components](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/p/devbox/material-design-quill-react-components-d862dk?embed=1)

    ```tsx theme={null}
    import { Table, useQuill } from "@quillsql/react";
    import { MaterialTable } from "./ui/ant/Table";

    export function MaterialDesignTable() {
      const report = useQuill("6644088e6e2470000cbdb109");
      if (!report || !report.data) return null;
      return (
        <div style={{ padding: 12 }}>
          <MaterialTable rows={report.data.rows} columns={report.data.columns} />
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

### Automatically fetch data by id

If you know the id of the table you would like to display, you can pass in the reportId to the Table component and it will load and display the data for that table.

```jsx theme={null}
import { QuillProvider, Table } from "@quillsql/react";

function App() {
  return (
    <QuillProvider tenants={[{ tenantField: "customer_id", tenantIds: [2] }]} publicKey={process.env.QUILL_PUBLIC_KEY}>
      <Table reportId="664283fb4db8ad000bfe54d7" />
    </QuillProvider>
  );
}
```

### Pass data directly into the table

Alternatively, if you have the actual data you would like to display (eg. you fetched the data using our `useQuill` hook) you can also pass in that data directly to the Table component and it will display that data without doing any async fetching.

<CodeGroup>
  ```jsx Using raw data theme={null}
  import { QuillProvider, Table } from "@quillsql/react";

  function App() {
    return (
      <QuillProvider tenants={[{ tenantField: "customer_id", tenantIds: [2] }]} publicKey={process.env.QUILL_PUBLIC_KEY}>
        <Table
          rows={[
            { x: 1, y: 1, z: 0 },
            { x: 2, y: 2, z: 0 },
            { x: 3, y: 3, z: 0 },
            { x: 4, y: 4, z: 0 },
            { x: 5, y: 5, z: 0 },
            { x: 6, y: 6, z: 0 },
          ]}
          columns={[
            { label: "My X-Axis", field: "x" },
            { label: "My Y-Axis", field: "y" },
          ]}
        />
      </QuillProvider>
    );
  }
  ```

  ```jsx Using useQuill theme={null}
  import { QuillProvider, Table } from "@quillsql/react";
  import { MY_TABLE_ID } from "./constants";

  function App() {
    const report = useQuill(MY_TABLE_ID);
    return (
      <QuillProvider tenants={[{ tenantField: "customer_id", tenantIds: [2] }]} publicKey={process.env.QUILL_PUBLIC_KEY}>
        <Table rows={report.rows} columns={report.columns} />
      </QuillProvider>
    );
  }
  ```
</CodeGroup>

## Props

<ParamField path="reportId" type="string">
  The table's id. The most usage is through a detail page built to navigate from
  the dashboard - using the onClick callback to get the report id, and
  navigating to a route (say, reports/:id) where the url param is passed in as
  the reportId. For a standalone table, you can find the reportId in the Quill
  BI Platform and pass it in directly.

  When a `reportId` is passed, the table will first fetch the data necessary
  to render this table, and then it will render the rows and columns that it
  receives from the server.

  <Info>A `reportId` must be passed if `rows` and `columns` are not present.</Info>
</ParamField>

<ParamField path="rows" type="{ [key: string]: any }[]">
  The rows of the table to show, if any.

  When `rows` and `columns` are passed, the table will not refetch the given
  report and will instead simply render the rows and columns it was given.

  <Info>Both `rows` and `columns` must be passed if `reportId` is not present.</Info>
</ParamField>

<ParamField path="columns" type="{ label: string; field: string; }[]">
  The columns of the table to show, if any.

  When `rows` and `columns` are passed, the table will not refetch the given
  report and will instead simply render the rows and columns it was given.

  <Info>Both `rows` and `columns` must be passed if `reportId` is not present.</Info>
</ParamField>

<ParamField path="csvFilename" type="string">
  The placeholder filename to use when downloading this table as a csv file.
</ParamField>

<ParamField path="hideDownloadCSVButton" type="boolean">
  Whether to hide the download csv button.
</ParamField>

<ParamField path="isLoading" type="boolean">
  Whether this table component is loading.
</ParamField>

<ParamField path="downloadCSV" type="() => void">
  A callback that is fired when the user clicks download csv.
</ParamField>

<ParamField path="LoadingComponent" type="() => JSX.Element">
  A loading component to show when the table is loading.
</ParamField>

<ParamField path="className" type="string">
  Styles the top-level container of the Table.

  This can be useful for TailwindCSS-style classname strings.
</ParamField>

<ParamField path="containerStyle" type="React.CSSProperties">
  The CSS styles that wrap the table.
</ParamField>
