Learn R Programming

calcite (version 1.0.0)

calcite_table: Create a Calcite Table Component

Description

Creates a table component from a data.frame with automatic row and cell generation. The table provides pagination, numbering, and various styling options.

Usage

calcite_table(
  data,
  ...,
  id = NULL,
  caption,
  header = NULL,
  alignment = "start",
  bordered = NULL,
  numbered = NULL,
  page_size = NULL,
  scale = NULL,
  striped = NULL,
  numbering_system = NULL
)

Value

An object of class calcite_component

Arguments

data

A data.frame to display in the table (required)

...

Additional attributes passed to the component

id

Component ID (required for Shiny reactivity)

caption

Accessible title for the table (required)

header

Custom header row created with calcite_table_header(). If NULL, column names from data are used

alignment

Alignment for all cells: "start", "center", or "end" (default: "start")

bordered

When TRUE, displays borders (default: FALSE)

numbered

When TRUE, displays row numbers (default: FALSE)

page_size

Page size for pagination. When > 0, renders pagination controls (default: 0)

scale

Size of the component: "s" (small), "m" (medium), or "l" (large) (default: "m")

striped

When TRUE, displays striped styling (default: FALSE)

numbering_system

Unicode numeral system: "arab", "arabext", or "latn"

Details

Shiny Integration

The table emits events for page changes and selection changes (when selection is enabled).

Available properties in input$id:

  • $pageSize - Current page size

  • $scale - Component scale

  • $bordered - Whether borders are displayed

  • $numbered - Whether row numbers are displayed

  • $striped - Whether striped styling is applied

  • Other component properties

Events:

  • calciteTablePageChange - Fires when the page changes

References

Official Documentation

Examples

Run this code
# Basic table from data frame
calcite_table(
  data = mtcars[1:5, 1:4],
  id = "my_table",
  caption = "Motor Trend Car Data",
  bordered = TRUE,
  striped = TRUE
)

# Table with pagination
calcite_table(
  data = iris,
  id = "iris_table",
  caption = "Iris Dataset",
  page_size = 10,
  numbered = TRUE
)

# Table with custom headers
calcite_table(
  data = mtcars[1:5, 1:3],
  caption = "Cars",
  header = list(
    calcite_table_header(heading = "Miles/Gallon", description = "Fuel efficiency"),
    calcite_table_header(heading = "Cylinders", description = "Number of cylinders"),
    calcite_table_header(heading = "Displacement", description = "Engine size")
  )
)

Run the code above in your browser using DataLab