• Meet OMA at Smart City Expo World Congress • Barcelona • 3–5 November 2026 • Hall 3, Street F, Stand 90 •
• Live LwM2M demos • Water 2.0 panel • Smart City SIG sessions •

💧 OMA Utilities WG • Water 2.0 has launched • Utility Membership •

🏙️ OMA Conformance Tool • Apply for Early Access •


Dynamic Table

Usage

Basic

The simplest usage of ShDynamicTable can be shown in the following example:

Dymanic Table example

Email
Showing 0 to 0 out of 0 items

Copyright © 2024

::ShDynamicTable
---
dataUrl: "https://dummyjson.com/users"
dataField: "users"
columns:
  - name: "firstName"
    title: "First Name"
    filter: false
    query: true
    sortable: true
    type: text
  - name: "lastName"
    title: "Last Name"
    filter: false
    query: true
    sortable: true
    type: text
  - name: "username"
    title: "username"
    filter: false
    query: true
    sortable: true
    type: text
  - name: "email"
    title: "Email"
    filter: false
    query: true
    sortable: false
    type: email
  - name: "gender"
    title: "Gender"
    filter: true
    sortable: true
    order: true
    type: text
  - name: "birthDate"
    title: "Birth Date"
    filter: false
    query: true
    sortable: true
    type: date
  - name: "age"
    title: "Age"
    filter: true
    query: true
    sortable: true
    type: number
ui:
  footer: "text-sm"
header: Dymanic Table example
footer: "*Copyright © 2024*"
---
::

The important parts are the dataUrl, and columns. The prior one define the URL from witch the data will be fetched. On the other hand, columns represent a list of elements where each table column is described.

Each column is described using the following properties:

  • name - the property name
  • title - the label that will be show in the column header
  • filter - true | false value indication that if the field in question should be used for quick filters
  • query - true | false value indicating if this filed should be used in query search
  • sortable - true | false value indication if this field should be used for ordering the data
  • type - one of the following [text, number, date, list, url] values defining the type of the field value. A list column holds comma-separated values, and each value gets its own quick filter
  • pill - true | false value indicating that the value should be shown as a pill, meant for short status words
  • wrap - true | false value letting the cell wrap over up to two lines instead of being cut to one (the full value is always available as a tooltip)

Numeric columns (other than identifiers whose name ends in id) are right-aligned automatically.

Data field

Beside the above the dataField parameter can be used if the data fetched holds the table items under a specific property. This is typical in REST API results. You can review the one used in above example where the items that we would like to show in the table is stored in users field.

Props

PropTypeDefaultDescription
dataUrlrequiredString''URL from which the table fetches its data dynamically.
dataFieldString() => undefinedSpecifies the key or field within the fetched data to be displayed.
columnsrequireditemsElement[]() => ([])Column definitions: `name` (key in the data) plus optional `title`, `filter`, `order`, `hide`, `type`, `pill`, `wrap` and more. See the Columns section of the guideline.
uiRecord<string, any>–Overrides the default classes of the UI config below. Values are merged with the defaults using tailwind-merge.
headerString''Content for the table header, typically displayed above the column titles.
footerString''Content for the footer section, often used for totals or additional information.
perPagenumberDEFAULT_PER_PAGEDefines the number of rows shown per page when the table loads, and preselects that value in the "Show" dropdown. Acceptable values: 10, 25, 50, 100, or `-1` to show all rows on a single page.
transformRawDataany() => nullOptional. Name of a built-in transform applied to the fetched data before it is rendered. Accepts `filterDDFObjects`, `filterCommonObjects`, or `filterOmaEnablers`.
autofocusSearchBooleanfalseWhen `true`, the page scrolls to the table once its data has loaded and puts the cursor in the search box, so a visitor can start typing straight away. Intended for pages whose main purpose is looking something up in the table. The scroll is skipped when the URL carries an anchor, and the focus is skipped below the `lg` breakpoint so the on-screen keyboard does not cover the table on touch devices.
classany() => undefinedAdditional classes applied to the root element of the component.

Columns

Each item of the columns prop describes one column of the table:

FieldTypeDefaultDescription
namerequiredString–Key of the field in the data that this column displays.
titleString–Header text of the column. Defaults to `name`.
filterBoolean–Adds a filter panel with the distinct values of the column.
sortableBoolean–Adds a sort button to the column header.
hideBoolean–Hides the column, while still allowing it to be searched.
formatColumValueString–Reformats the value before display. `DY` shows only the year of a date.
typeString–How the value is rendered: `url` (link), `list` (several values) or `subs` (a field of the value).
typeDataArray–Extra fields used by `type`. For `url`, the field that holds the link address.
pillBoolean–Render the value as a pill - meant for short status vocabularies.
wrapBoolean–Let the cell wrap over several lines instead of truncating to one.

Slots

This component has no slots.

UI config

Default classes of every styled element. Override any key through the ui prop.

KeyDefault classesDescription
wrapperw-full bg-neutral-50 dark:bg-inherit border-2 border-neutral-200 dark:border-neutral-500 rounded-2xl p-5Customizes the overall container's styling, such as padding, margin, and background.
headerrounded-xl border-2 border-neutral-300 dark:border-neutral-600 bg-neutral-100 dark:bg-neutral-800 px-6 py-4 mb-6 text-center text-lg md:text-xl font-bold uppercase tracking-[0.18em] text-black dark:text-white not-proseStyles for the table's header, including background, text alignment, and font.
basew-fullApplies default styles to the main table structure, including borders and layout.
footerfont-semibold text-center text-black dark:text-white border-t border-neutral-200 dark:border-neutral-700 pt-3 mt-5Customizes the footer section, often used for summaries or additional actions.
searchw-full pb-4Defines styling for the search input or controls, enhancing usability and design.
toolbarflex flex-wrap items-center gap-2Row that holds the search, filters and result count.