Black Friday: 50% off all products for the first 50 customers. Only 10 left. Use code
40/50 claimed
See pricing →
November 17, 2026

Quasar QTable Columns: Format, Align and Sort

Quasar QTable columns explained option by option: field, format, align, sortable, sort and rawSort, plus a free generator that builds them from your JSON.
Quasar
QTable
Data Tables
TypeScript

Quasar QTable columns are where most table bugs start: a date that sorts as text, a price that searches as 12900 instead of $129.00, a name column stuck to the right edge. Every one of those is a single option on the column object. This post goes through each option the Quasar 2.35.2 API has, with the rule behind it, and introduces a free tool that writes the first draft of the array for you: the QTable Columns Generator.

If you haven't built a QTable yet, start with the Quasar QTable tutorial, which covers filtering, pagination and a status cell. Here we stay on the columns prop.

The QTable Columns Generator

Typing column objects by hand gets old after the third table. The QTable Columns Generator starts from your data instead:

  1. Paste a JSON array of rows, for example a response from your API. An object that wraps the array, like { "data": [...] }, works too.
  2. The tool reads each key and its values in every row and writes one column per key: name, label, field, align chosen from the value type, sortable, and a format function for numbers, money and dates. Nested objects get their own columns with a field function, such as row => row.customer.name.
  3. Fix any guess that's wrong: rename a label, switch a column's type (a number to money, or money stored in cents), turn sorting off, or leave a column out. A live QTable underneath shows how each column sorts.
  4. Copy the columns array, typed as QTableColumn<Row>[] with an inferred Row interface, or a complete QTable component that uses it, in TypeScript or JavaScript.

It runs in your browser. Nothing is sent anywhere and you don't need an account. The generated field always keeps the raw value: numbers stay numbers and ISO dates stay ISO strings, which sort in date order when they share one format. The readable text goes in format. Treat the output as a first draft: the sections below explain what each generated option does, so you know which ones to change.

Every QTable column option at a glance

OptionTypeWhat it does
namestring, requiredThe column's id. sortBy, visible-columns and the body-cell-[name] slots refer to it.
labelstring, requiredHeader text.
fieldstring or (row) => anyWhere the value comes from.
format(val, row) => stringHow the value is displayed.
align'left', 'center', 'right'Defaults to 'right'.
sortablebooleanMakes the header clickable.
sort / rawSort(a, b, rowA, rowB) => numberCustom comparison.
sortOrder'ad' or 'da'Direction of the first click.
requiredbooleanAlways shown, even with visible-columns.
classes / stylestring or (row) => stringClasses and styles on body cells.
headerClasses / headerStylestringClasses and styles on the header cell.
autoWidthbooleanShrinks the column to its content (v2.31+).

The rest of the post takes them in the order you'll need them.

field: a key or a function

field tells QTable where the cell value lives. A string reads that key from the row. A function receives the row and returns anything, which is how you reach nested data or compute a value:

import type { QTableColumn } from 'quasar'

interface Invoice {
  id: string
  customer: { name: string; country: string }
  amountCents: number
  issuedAt: string
  paidAt: string | null
  overdueDays: number
}

const columns: QTableColumn<Invoice>[] = [
  { name: 'id', label: 'Invoice', field: 'id', align: 'left', sortable: true },
  { name: 'customer', label: 'Customer', field: row => row.customer.name, align: 'left', sortable: true },
]

The value field returns is the one QTable sorts by, so it should be the raw value (a number, a Date), not a display string. A column with no field at all is allowed. Its value is empty and QTable skips it when sorting and filtering, which is what you want for an actions column drawn entirely by a slot.

QTableColumn<Invoice> is worth the import: with a row type, a string field must be a real key of Invoice, and the function form gets a typed row.

QTable format: display only

format receives the value from field and the whole row, and returns what the cell shows:

const money = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' })
const day = new Intl.DateTimeFormat('en-US', { dateStyle: 'medium' })

const columns: QTableColumn<Invoice>[] = [
  {
    name: 'amount',
    label: 'Amount',
    field: 'amountCents',
    sortable: true,
    format: (cents: number) => money.format(cents / 100),
  },
  {
    name: 'issuedAt',
    label: 'Issued',
    field: row => new Date(row.issuedAt),
    sortable: true,
    format: (date: Date) => day.format(date),
  },
]

Three rules decide how format behaves:

  • Sorting ignores it. The amount column sorts by amountCents, a number, so $1,200.00 correctly lands after $950.00.
  • The default filter uses it. The built-in search matches the formatted text of the visible columns, so a user typing Nov 3 finds the invoice issued on that day.
  • It should return a string. QTableColumn types format as returning string. For anything richer, a badge or a link, use a body-cell-[name] slot.

Create the Intl formatters once, outside the column array. format runs for every visible cell on every render.

The date column shows the trick for date sorting: the field function turns the ISO string into a Date, and QTable's default sort compares two Date objects as dates. The format function turns it back into readable text.

align: why your text sits on the right

Every column is right-aligned unless you say otherwise. QTable puts the text-right class on the header and body cells, and a left or center value switches it. The convention is simple:

  • numbers, money and durations: right (the default), so digits line up;
  • text, names and ids: left;
  • short status values, icons and checkboxes: center.

If you leave out columns entirely, QTable builds them from the first row: one column per key, the key in upper case as the label, right for numbers and left for everything else, all sortable. That's fine for a quick look at data. For a real screen you want proper labels, formats and sort rules, which is the gap the QTable Columns Generator fills.

Sorting a QTable column: sortable, sort, rawSort and sortOrder

sortable: true is enough for most columns. The default comparison looks at the two raw values: numbers as numbers, Date objects as dates, booleans as booleans, and anything else as lowercase text. The tutorial shows a sort function for a status column with its own order.

Two details are easy to miss.

Empty values. Before sort is called, rows whose value is null or undefined are put aside: they come first when sorting ascending and last when sorting descending. When "Unpaid" should sort after every paid date, handle it yourself with rawSort, which receives empty values too:

{
  name: 'paidAt',
  label: 'Paid',
  field: 'paidAt',
  sortable: true,
  rawSort: (a: string | null, b: string | null) => {
    if (a === b) return 0
    if (a === null) return 1
    if (b === null) return -1
    return a < b ? -1 : 1
  },
  format: (val: string | null) => (val === null ? 'Unpaid' : day.format(new Date(val))),
}

QTable multiplies the result by -1 for a descending sort, so unpaid invoices move to the top when the user flips the column.

The first click. A click on a sortable header sorts ascending, the next one descending, the third removes the sort. For dates and amounts, users usually want "newest" or "largest" first. sortOrder: 'da' on the column makes the first click sort descending. The table-wide column-sort-order="da" prop does the same for every column, and the column option wins over the prop.

classes, style and autoWidth

classes and style style the body cells. Both take a string, or a function that receives the row, so a cell can react to its data:

{
  name: 'overdue',
  label: 'Overdue',
  field: 'overdueDays',
  sortable: true,
  format: (days: number) => (days > 0 ? `${days} days` : '—'),
  classes: row => (row.overdueDays > 30 ? 'text-negative text-weight-medium' : ''),
  headerClasses: 'text-no-wrap',
}

headerClasses and headerStyle apply to the header cell only, and they're plain strings. Use them for widths (headerStyle: 'width: 160px') and to stop a long label from wrapping.

autoWidth: true shrinks a column to the narrowest width its header and cells need. It suits icon columns, checkboxes and row actions, and it needs Quasar 2.31 or later.

required and visible-columns

When you let users pick columns with the visible-columns prop, any column not in that list is hidden, except columns with required: true. Mark the column that identifies the row (the invoice number, the customer name) as required, so a user can't hide every way of telling rows apart.

Common questions about Quasar QTable columns

Why does my QTable column sort numbers as text? The field returns strings like "129". Return a number from field (row => Number(row.total)), or add a sort function.

Can a column show two fields? Yes. Use a field function for the sort value and a format that reads the row, or a body-cell-[name] slot for markup.

Why is my format function not used in my slot? It is: props.value in a body-cell slot is the formatted value. Use props.row for the raw data.

Do I need TypeScript for the generator's output? No. Switch the generator to JavaScript and it drops the QTableColumn import, the Row interface and the parameter types.

Next step

Open the QTable Columns Generator, paste a sample of your API response, and copy the columns. Then go through the draft with the rules above: the right field for sorting, a format for display, align for each type, and sortOrder: 'da' where newest-first makes sense.