--- package: "@svenskaspel/ui" version: "4.4.0" document_type: "component-documentation" source: "@svenskaspel/ui/docs/table.md" canonical_url: "/components/table" usage_source: "src/app/(docs)/components/table/page.mdx" --- # Table Table displays structured data in rows and columns for easy scanning and comparison.  *** ## Usage Use a table to display structured information in rows and columns, making it easy for users to scan, compare, and understand data such as transactions or game history. ### When to use Table Choose a table when users need to organize and compare multiple attributes across items, or when showing datasets that benefit from clear alignment, like lists of players, bets, or transactions. *** ## Formatting ### Anatomy A table is composed of the following elements  1. Table header – Defines column labels and provides structure for the data. 2. Table row –Each row groups related data points that belong to the same record, transaction, or entity. 3. Table Total – Summarizes data across the table, e.g. totals. (optional). 4. Table cell – The smallest unit, containing a piece of data within a row and column. 5. Table Footer – supportive text. (optional) ### Size Our tables are available in for row sizes: xsmall (32 px) small (48 px), medium (76 px), and large (96 px). All sizes share consistent 16 px horizontal padding.  Note: xsmall supports only single-line text — never use it for multi-line content. ### Min and max width Table cells follow defined width limits to ensure readability and consistency. Each column has a minimum width of 120 px and a maximum width of 400 px to prevent individual columns from dominating the layout. The last column may expand to fill any remaining space. ### Cell types Our Simple table support different cell types to match the content they display. #### Text  Use for simple labels or single pieces of information. #### Text + description  Use when additional context is needed under the main text. #### Numeric  Use for values like amounts or percentages, always right-aligned for readability. *** ## Modify ### Variants Tables can be configured in different variations depending on the data and context. #### Default  Balanced spacing for general use, offering a clear overview and comfortable readability. #### Striped  A striped table alternates row backgrounds to make large datasets easier to scan. ### Sizes We offer four table sizes to match content density and usage context. Each size is optimized for clarity, consistency, and accessibility across different scenarios. #### Xsmall  For dense data and one-line text only. #### Small  Compact, ideal for mobile and tight layouts. #### Medium  Default size for most use cases. #### Large  Spacious, best for content-rich or touch-friendly interfaces. *** ## Behaviour ### Scrolling The table header remains sticky on vertical scroll to keep column labels visible. If the content exceeds the viewport width, the table can be scrolled horizontally. Tables have a maximum height of 90% of the viewport, after which the body becomes scrollable. Note: Vertical scrolling should only be used on desktop. On mobile, avoid nested vertical scrolls as they create poor usability. Instead, let the table grow naturally and use horizontal scrolling or pagination when needed.  *** ## Screen sizes ### xs –small Tables can be scrolled horizontally if the content exceeds the viewport width. The header remains sticky on vertical scroll to keep column labels visible. (<480px).  ### Medium–Large Tables scale to available width and maintain alignment. The header is sticky on vertical scroll, and horizontal scrolling is enabled when needed. (≥481px – 1439px).  ### XL Tables display more columns within the grid while preserving readability. The header remains sticky, and long datasets may be scrolled. (<1440px).  *** ## Best practice ### Avoid long copy Use concise text and descriptions to keep tables easy to scan. Long copy reduces readability.  > **Do:** Use short, clear text with a concise supporting description when extra context is needed.  > **Don't:** Don’t repeat the same information in both text and description, or overload the cell with unnecessary details. ### Alignment Numbers should always be right-aligned to make comparisons easy across rows.  > **Do:** Keep numeric data right-aligned > > Numbers should always be right-aligned to make comparisons easy across rows.  > **Don't:** Don’t center or left-align numeric data, as it makes scanning and comparing harder. ### Use spacing for readability Tables should have enough padding and row height to feel open and easy to scan. Avoid squeezing rows and columns too tightly, as it makes the table harder to read and reduces clarity.  > **Do:** Keep sufficient gaps between columns and rows to support quick scanning.  > **Don't:** Don’t cram information too tightly — it makes the table harder to read and less accessible. --- # Readme / API # `Table` The `Table` component is used to display structured data in rows and columns for easy scanning and comparison. It includes built-in support for variants, sizes, cell types, and scrolling behavior, providing a flexible and accessible way to display tabular data with consistent styling and layout controls. ## Importing ```typescript import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSectionHeader, } from '@svenskaspel/ui/react/table'; ``` ## Sub-components The `Table` component consists of several sub-components: - `Table`: The main container component that wraps the entire table structure. - `TableHeader`: Contains the table header rows with column labels. - `TableBody`: Contains the main data rows of the table. - `TableFooter`: Contains footer rows, typically for totals or summaries. - `TableRow`: Represents a single row in the table. - `TableHead`: Represents a header cell (th) with column labels. - `TableCell`: Represents a data cell (td) containing table content. - `TableCaption`: Provides a caption or description for the table. - `TableSectionHeader`: Renders a section-heading row with a `th scope="rowgroup"`; place it directly inside TableBody. `colSpan` defaults to 1000 so the browser spans all actual columns. ## Props ### For the main `Table` component: - **`size`**: `('xs' | 'sm' | 'md' | 'lg')` (Optional) - Description: Controls the row height and spacing of the table. - `'xs'`: 6px vertical cell padding. - `'sm'`: 10px vertical cell padding. - `'md'`: 14px vertical cell padding (default). - `'lg'`: 20px vertical cell padding. - Row height is determined by content plus padding; these are not fixed row heights. - **`isStriped`**: `boolean` (Optional) - Description: When `true`, applies alternating row backgrounds to make large datasets easier to scan. Defaults to `false`. - **`isStickyHeader`**: `boolean` (Optional, default `false`) - Description: Makes TableHeader sticky and stacks TableSectionHeader below it. The consumer supplies the scrolling container. - **`className`**: `string` (Optional) - Description: Additional CSS classes to apply to the table element. ### For the `TableHead` sub-component: - **`type`**: `('text' | 'text-description' | 'numeric')` (Optional) - Description: Determines the alignment of the header cell. - `'text'`: Left-aligned text (default). - `'text-description'`: Left-aligned text with support for descriptions. - `'numeric'`: Right-aligned for numeric data. - **`className`**: `string` (Optional) - Description: Additional CSS classes to apply to the header cell. ### For the `TableCell` sub-component: - **`type`**: `('text' | 'text-description' | 'numeric')` (Optional) - Description: Determines the cell content type and styling. - `'text'`: Standard text cell (default). - `'text-description'`: Text with an optional description below (two-line layout). - `'numeric'`: Right-aligned numeric data with tabular figures. - **`isScrollable`**: `boolean` (Optional, default `false`) - Description: Wraps cell content in a horizontal scroller with edge fades and hidden scrollbars, capped at 400px. - **`description`**: `string` (Optional) - Description: Secondary text displayed below the main content when `type="text-description"`. Rendered in a muted color. - **`className`**: `string` (Optional) - Description: Additional CSS classes to apply to the cell. ### For other sub-components: Each sub-component (`TableHeader`, `TableBody`, `TableFooter`, `TableRow`, `TableCaption`) accepts: - **`className`**: `string` (Optional) - Description: Additional CSS classes to apply to the component. ## Usage ### Basic Table Here is a basic example of how to use the `Table` component: ```typescript import * as React from 'react'; import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableSectionHeader, } from '@svenskaspel/ui/react/table'; const BasicTable = () => { return (
| `, ` | `).
- Captions provide context for screen readers via ` |
|---|