← Back to Components
Table
Styled data-frame tables with captions, column formatting, alignment, and truncation notes.
Interactive Playground
R Code
API Reference
block_table()
Renders a data frame or tibble as a shadcn-style table through the shinyblocks runtime, with R-side formatting and a reactive server-side update path.
| Argument | Type | Default | Description |
|---|---|---|---|
| data | data.frame | required | Data frame or tibble to render. |
| columns | named list | NULL | Optional table_column() specs keyed by data column name. |
| caption | character | NULL | Caption rendered below the table. |
| max_rows | integer | NULL | Optional row limit. Truncated tables render a footer note. |
| na | character | "" | String used to render missing values. Per-column overrides win. |
| digits | integer | NULL | Decimal places for default numeric formatting. NULL keeps R's format(). |
| rownames | logical | FALSE | Render row.names(data) as a leading column. |
| row_format | function | NULL | function(row, i) returning list(intent=, emphasis=, class=, style=) applied to that row's <tr>. |
| striped | logical | FALSE | Zebra-stripe body rows. |
| hover | logical | TRUE | Highlight rows on hover (shadcn base behavior). |
| bordered | logical | FALSE | Draw cell borders. |
| selection | character | "none" | DT-style row selection mode: none, single, or multiple. Enables clickable rows reporting input$id_rows_selected, _row_last_clicked, and _cell_clicked. |
| selected | integer | NULL | 1-based row indices to select on load (requires selection != none). |
| id | character | NULL | Input id. Required to update the table from the server or to use row selection. |
| class | character | NULL | Additional classes applied to the runtime table container. |
| style | character | named list | NULL | Inline styles applied to the runtime mount and table container. |
update_block_table()
Re-renders an id-bound block_table() from the server with a freshly formatted payload (the same pipeline as the initial render).
| Argument | Type | Default | Description |
|---|---|---|---|
| session | ShinySession | current domain | Shiny session. |
| id | character | required | Input id passed to block_table(id = ). |
| data | data.frame | NULL | Replacement data frame. Re-renders with the formatting arguments below. |
| columns, caption, max_rows, na, digits, rownames, row_format, striped, hover, bordered | matching block_table() | block_table() defaults | Formatting arguments applied when data is supplied. |
| loading | logical | NULL | TRUE shows skeleton rows; FALSE clears the loading state without changing data. |
| selection | character | NULL | Optional new row-selection mode (none, single, multiple). NULL leaves it unchanged. |
| selected | integer | NULL | 1-based row indices to select; integer(0) clears. NULL leaves it unchanged. |
table_column()
Defines per-column display options for block_table().
| Argument | Type | Default | Description |
|---|---|---|---|
| label | character | NULL | Header label. Defaults to the column name. |
| align | 'left' | 'center' | 'right' | 'left' | Text alignment for header and cells. |
| format | function | NULL | Function applied to the full R column vector before rendering. When set, digits is ignored for this column. |
| width | character | NULL | Optional CSS width for the column. |
| digits | integer | NULL | Per-column decimal places, overriding the table-level digits. |
| na | character | NULL | Per-column missing-value string, overriding the table-level na. |
| intent | intent enum | NULL | Token-backed styling intent for every cell in the column: muted, primary, secondary, destructive, success, warning, or accent. Theme-safe. |
| emphasis | 'text' | 'soft' | 'solid' | 'text' | How an intent renders: colored text, tinted background, or filled chip. |
| class, style | character | named list | NULL | Escape hatch: class / inline style on each <td>. You own theme-correctness. |
| header_intent, header_emphasis, header_class, header_style | intent enum | character | NULL / 'text' | Same styling controls applied to the column's <th> header cell. |
| cell_intent, cell_emphasis, cell_class, cell_style | function | NULL | function(value) callbacks over the column vector returning one entry per row; per-cell results win over the column-level styling. |