Documentation
Custom Theme
Simple Table offers two complementary ways to customize your table's appearance: CSS-based theming for colors and visual styling, and the customTheme prop for layout dimensions that affect virtualization calculations.
Two Types of Customization
- CSS Theming - Use CSS variables to customize colors, fonts, and visual styles. Perfect for matching your design system.
- customTheme Prop - Configure layout dimensions (heights, widths, spacing) that affect virtualization calculations. These cannot be styled through CSS alone.
customTheme Prop: Layout Dimensions
The customTheme prop allows you to configure layout dimensions that are critical for the table's virtualization engine. These values determine how the table calculates scroll positions, visible rows, and layout measurements.
Why These Can't Be CSS-Only
Simple Table uses virtualization to efficiently render large datasets by only rendering visible rows. To calculate which rows are visible and where to position them, the table needs to know exact pixel dimensions before rendering. CSS values can't be read synchronously during render, so these dimensions must be provided as props.
customTheme Properties
| Property | Required | Description | Example |
|---|---|---|---|
Property | Required | Description | Example |
rowHeightnumber | Optional | Height of table rows in pixels. This value is used for virtualization calculations and cannot be styled through CSS. If not specified, uses the default value of 40px. | |
headerHeightnumber | Optional | Height of the table header in pixels. This value is used for virtualization calculations and cannot be styled through CSS. If not specified, uses the default value of 40px. | |
footerHeightnumber | Optional | Height of the table footer in pixels. This value is used for virtualization calculations and cannot be styled through CSS. If not specified, uses the default value of 50px. | |
rowSeparatorWidthnumber | Optional | Width of separators between rows in pixels. This value affects virtualization calculations and cannot be styled through CSS. If not specified, uses the default value of 1px. | |
borderWidthnumber | Optional | General border width in pixels (e.g., table borders, header borders). This value affects layout calculations and cannot be styled through CSS. If not specified, uses the default value of 1px. | |
pinnedBorderWidthnumber | Optional | Width of borders for pinned columns in pixels. This value affects layout calculations for pinned columns and cannot be styled through CSS. If not specified, uses the default value of 2px. | |
nestedGridBorderWidthnumber | Optional | Border width for nested grid tables (top + bottom) in pixels. This value affects nested table layout calculations and cannot be styled through CSS. If not specified, uses the default value of 2px. | |
nestedGridPaddingTopnumber | Optional | Top padding for nested grids in pixels. This value affects nested table layout calculations and cannot be styled through CSS. If not specified, uses the default value of 8px. | |
nestedGridPaddingBottomnumber | Optional | Bottom padding for nested grids in pixels. This value affects nested table layout calculations and cannot be styled through CSS. If not specified, uses the default value of 8px. | |
nestedGridPaddingLeftnumber | Optional | Left padding for nested grids in pixels. This value affects nested table layout calculations and cannot be styled through CSS. If not specified, uses the default value of 16px. | |
nestedGridPaddingRightnumber | Optional | Right padding for nested grids in pixels. This value affects nested table layout calculations and cannot be styled through CSS. If not specified, uses the default value of 16px. | |
nestedGridMaxHeightnumber | Optional | Maximum height for nested grids in pixels. This value controls how tall nested tables can grow before scrolling. If not specified, nested grids will grow to fit their content. | |
selectionColumnWidthnumber | Optional | Width of the row selection checkbox column in pixels. This value affects layout calculations and cannot be styled through CSS. If not specified, uses the default value of 40px. |
Common Use Cases
- Compact tables - Reduce
rowHeightto 32px for dense data displays - Spacious layouts - Increase
rowHeightto 56px or more for better readability - Nested tables - Configure
nestedGridMaxHeightto control how tall nested grids can grow - Custom borders - Adjust border widths to match your design system
For a complete reference of all customTheme properties, see the API Reference.
CSS Theming: Colors and Visual Styling
Beyond the built-in themes, Simple Table allows you to create completely custom themes using CSS variables. By defining your own theme with custom colors, spacing, and typography, you can perfectly match your application's design system.
1import {SimpleTable} from "@simple-table/react";import type { Theme } from "@simple-table/react";2import { customThemeConfig } from "./custom-theme.demo-data";3import "@simple-table/react/styles.css";4import "./custom-theme.css";56const CustomThemeDemo = ({7 height = "400px",8 theme,9}: {10 height?: string | number;11 theme?: Theme;12}) => {13 return (14 <SimpleTable15 columns={customThemeConfig.headers}16 rows={customThemeConfig.rows}17 theme={theme ?? "custom"}18 customTheme={customThemeConfig.tableProps.customTheme}19 columnResizing20 selectableCells21 height={height}22 />23 );24};2526export default CustomThemeDemo;272829// custom-theme.css30.theme-custom {31 --st-border-radius: 8px;32 --st-cell-padding: 12px;3334 --st-spacing-small: 6px;35 --st-spacing-medium: 10px;3637 --st-scrollbar-bg-color: #f5f5f4;38 --st-scrollbar-thumb-color: #8b5cf6;3940 --st-border-color: #e7e5e4;41 --st-odd-row-background-color: #fffbeb;42 --st-even-row-background-color: #fef3c7;43 --st-odd-column-background-color: #fffbeb;44 --st-even-column-background-color: var(--st-white);45 --st-hover-row-background-color: #fde68a;46 --st-selected-row-background-color: #f5f3ff;47 --st-header-background-color: #7c3aed;48 --st-header-label-color: var(--st-white);49 --st-header-icon-color: var(--st-white);50 --st-dragging-background-color: #f5f3ff;51 --st-selected-cell-background-color: #f5f3ff;52 --st-selected-first-cell-background-color: #ede9fe;53 --st-footer-background-color: #f5f5f4;54 --st-cell-color: #44403c;55 --st-cell-odd-row-color: #44403c;56 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),57 0 2px 4px -1px rgba(124, 58, 237, 0.06);58 --st-selected-cell-color: #5b21b6;59 --st-selected-first-cell-color: #5b21b6;60 --st-resize-handle-color: #a78bfa;61 --st-resize-handle-selected-color: var(--st-white);62 --st-separator-border-color: #e7e5e4;63 --st-last-group-row-separator-border-color: #d6d3d1;6465 --st-selected-border-color: #8b5cf6;66 --st-editable-cell-focus-border-color: #8b5cf6;6768 --st-checkbox-checked-background-color: #8b5cf6;69 --st-checkbox-checked-border-color: #7c3aed;70 --st-column-editor-background-color: var(--st-white);71 --st-column-editor-popout-background-color: var(--st-white);72 --st-button-hover-background-color: #f5f3ff;73 --st-button-active-background-color: #7c3aed;74 --st-cell-flash-color: #ddd6fe;75 --st-copy-flash-color: #8b5cf6;76 --st-warning-flash-color: var(--st-red-300);7778 --st-header-selected-background-color: #6d28d9;79 --st-header-selected-label-color: var(--st-white);80 --st-header-selected-icon-color: var(--st-white);8182 --st-header-highlight-indicator-color: #d6d3d1;83 --st-selection-highlight-indicator-color: #d6d3d1;8485 --st-next-prev-btn-color: #57534e;86 --st-next-prev-btn-disabled-color: #a8a29e;8788 --st-page-btn-color: #57534e;89 --st-page-btn-hover-background-color: #fef3c7;9091 --st-column-editor-text-color: #78716c;9293 --st-checkbox-border-color: #d6d3d1;9495 --st-dropdown-group-label-color: #78716c;9697 --st-datepicker-weekday-color: #78716c;98 --st-datepicker-other-month-color: #a8a29e;99100 --st-filter-button-disabled-background-color: #d6d3d1;101 --st-filter-button-disabled-text-color: #78716c;102103 --st-sub-header-background-color: #8b5cf6;104 --st-sub-cell-background-color: #fef8dc;105 --st-sub-cell-hover-background-color: #fef3c7;106 --st-dragging-sub-header-background-color: #c4b5fd;107 --st-selected-sub-cell-background-color: #ede9fe;108 --st-selected-sub-cell-color: #4c1d95;109110 --st-chart-color: #8b5cf6;111 --st-chart-fill-color: #c4b5fd;112113 --st-drag-separator-color: #8b5cf6;114}115116.theme-custom .st-header-label {117 font-weight: 600 !important;118 letter-spacing: 0.025em !important;119}120
1<script setup lang="ts">2import {SimpleTable} from "@simple-table/vue";import type { Theme } from "@simple-table/vue";3import { customThemeConfig } from "./custom-theme.demo-data";4import "@simple-table/vue/styles.css";5import "./custom-theme.css";67const props = withDefaults(defineProps<{ height?: string | number; theme?: Theme }>(), {8 height: "400px",9});10</script>1112<template>13 <SimpleTable14 :columns="customThemeConfig.headers"15 :rows="customThemeConfig.rows"16 :theme="props.theme ?? 'custom'"17 :custom-theme="customThemeConfig.tableProps.customTheme"18 :column-resizing="true"19 :selectable-cells="true"20 :height="props.height"21 />22</template>232425// custom-theme.css26.theme-custom {27 --st-border-radius: 8px;28 --st-cell-padding: 12px;2930 --st-spacing-small: 6px;31 --st-spacing-medium: 10px;3233 --st-scrollbar-bg-color: #f5f5f4;34 --st-scrollbar-thumb-color: #8b5cf6;3536 --st-border-color: #e7e5e4;37 --st-odd-row-background-color: #fffbeb;38 --st-even-row-background-color: #fef3c7;39 --st-odd-column-background-color: #fffbeb;40 --st-even-column-background-color: var(--st-white);41 --st-hover-row-background-color: #fde68a;42 --st-selected-row-background-color: #f5f3ff;43 --st-header-background-color: #7c3aed;44 --st-header-label-color: var(--st-white);45 --st-header-icon-color: var(--st-white);46 --st-dragging-background-color: #f5f3ff;47 --st-selected-cell-background-color: #f5f3ff;48 --st-selected-first-cell-background-color: #ede9fe;49 --st-footer-background-color: #f5f5f4;50 --st-cell-color: #44403c;51 --st-cell-odd-row-color: #44403c;52 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),53 0 2px 4px -1px rgba(124, 58, 237, 0.06);54 --st-selected-cell-color: #5b21b6;55 --st-selected-first-cell-color: #5b21b6;56 --st-resize-handle-color: #a78bfa;57 --st-resize-handle-selected-color: var(--st-white);58 --st-separator-border-color: #e7e5e4;59 --st-last-group-row-separator-border-color: #d6d3d1;6061 --st-selected-border-color: #8b5cf6;62 --st-editable-cell-focus-border-color: #8b5cf6;6364 --st-checkbox-checked-background-color: #8b5cf6;65 --st-checkbox-checked-border-color: #7c3aed;66 --st-column-editor-background-color: var(--st-white);67 --st-column-editor-popout-background-color: var(--st-white);68 --st-button-hover-background-color: #f5f3ff;69 --st-button-active-background-color: #7c3aed;70 --st-cell-flash-color: #ddd6fe;71 --st-copy-flash-color: #8b5cf6;72 --st-warning-flash-color: var(--st-red-300);7374 --st-header-selected-background-color: #6d28d9;75 --st-header-selected-label-color: var(--st-white);76 --st-header-selected-icon-color: var(--st-white);7778 --st-header-highlight-indicator-color: #d6d3d1;79 --st-selection-highlight-indicator-color: #d6d3d1;8081 --st-next-prev-btn-color: #57534e;82 --st-next-prev-btn-disabled-color: #a8a29e;8384 --st-page-btn-color: #57534e;85 --st-page-btn-hover-background-color: #fef3c7;8687 --st-column-editor-text-color: #78716c;8889 --st-checkbox-border-color: #d6d3d1;9091 --st-dropdown-group-label-color: #78716c;9293 --st-datepicker-weekday-color: #78716c;94 --st-datepicker-other-month-color: #a8a29e;9596 --st-filter-button-disabled-background-color: #d6d3d1;97 --st-filter-button-disabled-text-color: #78716c;9899 --st-sub-header-background-color: #8b5cf6;100 --st-sub-cell-background-color: #fef8dc;101 --st-sub-cell-hover-background-color: #fef3c7;102 --st-dragging-sub-header-background-color: #c4b5fd;103 --st-selected-sub-cell-background-color: #ede9fe;104 --st-selected-sub-cell-color: #4c1d95;105106 --st-chart-color: #8b5cf6;107 --st-chart-fill-color: #c4b5fd;108109 --st-drag-separator-color: #8b5cf6;110}111112.theme-custom .st-header-label {113 font-weight: 600 !important;114 letter-spacing: 0.025em !important;115}116
1import { Component, Input } from "@angular/core";2import {SimpleTableComponent} from "@simple-table/angular";import type { AngularColumnDef, Row, Theme } from "@simple-table/angular";3import { customThemeConfig } from "./custom-theme.demo-data";4import "@simple-table/angular/styles.css";5import "./custom-theme.css";67@Component({8 selector: "custom-theme-demo",9 standalone: true,10 imports: [SimpleTableComponent],11 template: `12 <simple-table13 [rows]="rows"14 [columns]="headers"15 [height]="height"16 [theme]="resolvedTheme"17 [customTheme]="customThemeOverrides"18 [columnResizing]="true"19 [selectableCells]="true"20 ></simple-table>21 `,22})23export class CustomThemeDemoComponent {24 @Input() height: string | number = "400px";25 @Input() theme?: Theme;2627 readonly rows: Row[] = customThemeConfig.rows;28 readonly headers: AngularColumnDef[] = customThemeConfig.headers;29 readonly customThemeOverrides = customThemeConfig.tableProps.customTheme;3031 get resolvedTheme(): Theme {32 return this.theme ?? "custom";33 }34}353637// custom-theme.css38.theme-custom {39 --st-border-radius: 8px;40 --st-cell-padding: 12px;4142 --st-spacing-small: 6px;43 --st-spacing-medium: 10px;4445 --st-scrollbar-bg-color: #f5f5f4;46 --st-scrollbar-thumb-color: #8b5cf6;4748 --st-border-color: #e7e5e4;49 --st-odd-row-background-color: #fffbeb;50 --st-even-row-background-color: #fef3c7;51 --st-odd-column-background-color: #fffbeb;52 --st-even-column-background-color: var(--st-white);53 --st-hover-row-background-color: #fde68a;54 --st-selected-row-background-color: #f5f3ff;55 --st-header-background-color: #7c3aed;56 --st-header-label-color: var(--st-white);57 --st-header-icon-color: var(--st-white);58 --st-dragging-background-color: #f5f3ff;59 --st-selected-cell-background-color: #f5f3ff;60 --st-selected-first-cell-background-color: #ede9fe;61 --st-footer-background-color: #f5f5f4;62 --st-cell-color: #44403c;63 --st-cell-odd-row-color: #44403c;64 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),65 0 2px 4px -1px rgba(124, 58, 237, 0.06);66 --st-selected-cell-color: #5b21b6;67 --st-selected-first-cell-color: #5b21b6;68 --st-resize-handle-color: #a78bfa;69 --st-resize-handle-selected-color: var(--st-white);70 --st-separator-border-color: #e7e5e4;71 --st-last-group-row-separator-border-color: #d6d3d1;7273 --st-selected-border-color: #8b5cf6;74 --st-editable-cell-focus-border-color: #8b5cf6;7576 --st-checkbox-checked-background-color: #8b5cf6;77 --st-checkbox-checked-border-color: #7c3aed;78 --st-column-editor-background-color: var(--st-white);79 --st-column-editor-popout-background-color: var(--st-white);80 --st-button-hover-background-color: #f5f3ff;81 --st-button-active-background-color: #7c3aed;82 --st-cell-flash-color: #ddd6fe;83 --st-copy-flash-color: #8b5cf6;84 --st-warning-flash-color: var(--st-red-300);8586 --st-header-selected-background-color: #6d28d9;87 --st-header-selected-label-color: var(--st-white);88 --st-header-selected-icon-color: var(--st-white);8990 --st-header-highlight-indicator-color: #d6d3d1;91 --st-selection-highlight-indicator-color: #d6d3d1;9293 --st-next-prev-btn-color: #57534e;94 --st-next-prev-btn-disabled-color: #a8a29e;9596 --st-page-btn-color: #57534e;97 --st-page-btn-hover-background-color: #fef3c7;9899 --st-column-editor-text-color: #78716c;100101 --st-checkbox-border-color: #d6d3d1;102103 --st-dropdown-group-label-color: #78716c;104105 --st-datepicker-weekday-color: #78716c;106 --st-datepicker-other-month-color: #a8a29e;107108 --st-filter-button-disabled-background-color: #d6d3d1;109 --st-filter-button-disabled-text-color: #78716c;110111 --st-sub-header-background-color: #8b5cf6;112 --st-sub-cell-background-color: #fef8dc;113 --st-sub-cell-hover-background-color: #fef3c7;114 --st-dragging-sub-header-background-color: #c4b5fd;115 --st-selected-sub-cell-background-color: #ede9fe;116 --st-selected-sub-cell-color: #4c1d95;117118 --st-chart-color: #8b5cf6;119 --st-chart-fill-color: #c4b5fd;120121 --st-drag-separator-color: #8b5cf6;122}123124.theme-custom .st-header-label {125 font-weight: 600 !important;126 letter-spacing: 0.025em !important;127}128129130// custom-theme.demo-data.ts131// Self-contained demo table setup for this example.132import type { AngularColumnDef, Row } from "@simple-table/angular";133134135export const customThemeData: Row[] = [136 { id: 1, name: "Alice Johnson", phone: "2125551234", email: "alice@corp.com", city: "New York", status: "active" },137 { id: 2, name: "Bob Martinez", phone: "3105559876", email: "bob@corp.com", city: "Los Angeles", status: "active" },138 { id: 3, name: "Clara Chen", phone: "4155553210", email: "clara@corp.com", city: "San Francisco", status: "inactive" },139 { id: 4, name: "David Kim", phone: "3125557654", email: "david@corp.com", city: "Chicago", status: "active" },140 { id: 5, name: "Elena Rossi", phone: "6175554321", email: "elena@corp.com", city: "Boston", status: "active" },141 { id: 6, name: "Frank Müller", phone: "2065558765", email: "frank@corp.com", city: "Seattle", status: "inactive" },142 { id: 7, name: "Grace Park", phone: "5125552468", email: "grace@corp.com", city: "Austin", status: "active" },143 { id: 8, name: "Henry Patel", phone: "3035551357", email: "henry@corp.com", city: "Denver", status: "active" },144];145146function formatPhone(raw: string): string {147 if (raw.length === 10) {148 return `(${raw.slice(0, 3)}) ${raw.slice(3, 6)}-${raw.slice(6)}`;149 }150 return raw;151}152153export const customThemeHeaders: AngularColumnDef[] = [154 { accessor: "id", label: "ID", width: 60, type: "number" },155 { accessor: "name", label: "Name", width: 170, type: "string", sortable: true },156 {157 accessor: "phone",158 label: "Phone",159 width: 150,160 type: "string",161 valueFormatter: ({ value }) => formatPhone(value as string),162 },163 { accessor: "email", label: "Email", width: 180, type: "string" },164 { accessor: "city", label: "City", width: 140, type: "string", sortable: true },165 { accessor: "status", label: "Status", width: 100, type: "string" },166];167168export const customThemeConfig = {169 headers: customThemeHeaders,170 rows: customThemeData,171 tableProps: {172 theme: "custom" as const,173 customTheme: {174 rowHeight: 40,175 headerHeight: 44,176 },177 },178} as const;179
1<script lang="ts">2 import {SimpleTable} from "@simple-table/svelte"; import type { Theme } from "@simple-table/svelte";3 import { customThemeConfig } from "./custom-theme.demo-data";4 import "@simple-table/svelte/styles.css";5 import "./custom-theme.css";67 let { height = "400px", theme }: { height?: string | number; theme?: Theme } = $props();8</script>910<SimpleTable11 columns={customThemeConfig.headers}12 rows={customThemeConfig.rows}13 theme={theme ?? "custom"}14 customTheme={customThemeConfig.tableProps.customTheme}15 columnResizing={true}16 selectableCells={true}17 {height}18/>192021// custom-theme.css22.theme-custom {23 --st-border-radius: 8px;24 --st-cell-padding: 12px;2526 --st-spacing-small: 6px;27 --st-spacing-medium: 10px;2829 --st-scrollbar-bg-color: #f5f5f4;30 --st-scrollbar-thumb-color: #8b5cf6;3132 --st-border-color: #e7e5e4;33 --st-odd-row-background-color: #fffbeb;34 --st-even-row-background-color: #fef3c7;35 --st-odd-column-background-color: #fffbeb;36 --st-even-column-background-color: var(--st-white);37 --st-hover-row-background-color: #fde68a;38 --st-selected-row-background-color: #f5f3ff;39 --st-header-background-color: #7c3aed;40 --st-header-label-color: var(--st-white);41 --st-header-icon-color: var(--st-white);42 --st-dragging-background-color: #f5f3ff;43 --st-selected-cell-background-color: #f5f3ff;44 --st-selected-first-cell-background-color: #ede9fe;45 --st-footer-background-color: #f5f5f4;46 --st-cell-color: #44403c;47 --st-cell-odd-row-color: #44403c;48 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),49 0 2px 4px -1px rgba(124, 58, 237, 0.06);50 --st-selected-cell-color: #5b21b6;51 --st-selected-first-cell-color: #5b21b6;52 --st-resize-handle-color: #a78bfa;53 --st-resize-handle-selected-color: var(--st-white);54 --st-separator-border-color: #e7e5e4;55 --st-last-group-row-separator-border-color: #d6d3d1;5657 --st-selected-border-color: #8b5cf6;58 --st-editable-cell-focus-border-color: #8b5cf6;5960 --st-checkbox-checked-background-color: #8b5cf6;61 --st-checkbox-checked-border-color: #7c3aed;62 --st-column-editor-background-color: var(--st-white);63 --st-column-editor-popout-background-color: var(--st-white);64 --st-button-hover-background-color: #f5f3ff;65 --st-button-active-background-color: #7c3aed;66 --st-cell-flash-color: #ddd6fe;67 --st-copy-flash-color: #8b5cf6;68 --st-warning-flash-color: var(--st-red-300);6970 --st-header-selected-background-color: #6d28d9;71 --st-header-selected-label-color: var(--st-white);72 --st-header-selected-icon-color: var(--st-white);7374 --st-header-highlight-indicator-color: #d6d3d1;75 --st-selection-highlight-indicator-color: #d6d3d1;7677 --st-next-prev-btn-color: #57534e;78 --st-next-prev-btn-disabled-color: #a8a29e;7980 --st-page-btn-color: #57534e;81 --st-page-btn-hover-background-color: #fef3c7;8283 --st-column-editor-text-color: #78716c;8485 --st-checkbox-border-color: #d6d3d1;8687 --st-dropdown-group-label-color: #78716c;8889 --st-datepicker-weekday-color: #78716c;90 --st-datepicker-other-month-color: #a8a29e;9192 --st-filter-button-disabled-background-color: #d6d3d1;93 --st-filter-button-disabled-text-color: #78716c;9495 --st-sub-header-background-color: #8b5cf6;96 --st-sub-cell-background-color: #fef8dc;97 --st-sub-cell-hover-background-color: #fef3c7;98 --st-dragging-sub-header-background-color: #c4b5fd;99 --st-selected-sub-cell-background-color: #ede9fe;100 --st-selected-sub-cell-color: #4c1d95;101102 --st-chart-color: #8b5cf6;103 --st-chart-fill-color: #c4b5fd;104105 --st-drag-separator-color: #8b5cf6;106}107108.theme-custom .st-header-label {109 font-weight: 600 !important;110 letter-spacing: 0.025em !important;111}112
1import {SimpleTable} from "@simple-table/solid";import type { Theme } from "@simple-table/solid";2import { customThemeConfig } from "./custom-theme.demo-data";3import "@simple-table/solid/styles.css";4import "./custom-theme.css";56export default function CustomThemeDemo(props: { height?: string | number; theme?: Theme }) {7 return (8 <SimpleTable9 columns={customThemeConfig.headers}10 rows={customThemeConfig.rows}11 height={props.height ?? "400px"}12 theme={props.theme ?? "custom"}13 customTheme={customThemeConfig.tableProps.customTheme}14 columnResizing15 selectableCells16 />17 );18}192021// custom-theme.css22.theme-custom {23 --st-border-radius: 8px;24 --st-cell-padding: 12px;2526 --st-spacing-small: 6px;27 --st-spacing-medium: 10px;2829 --st-scrollbar-bg-color: #f5f5f4;30 --st-scrollbar-thumb-color: #8b5cf6;3132 --st-border-color: #e7e5e4;33 --st-odd-row-background-color: #fffbeb;34 --st-even-row-background-color: #fef3c7;35 --st-odd-column-background-color: #fffbeb;36 --st-even-column-background-color: var(--st-white);37 --st-hover-row-background-color: #fde68a;38 --st-selected-row-background-color: #f5f3ff;39 --st-header-background-color: #7c3aed;40 --st-header-label-color: var(--st-white);41 --st-header-icon-color: var(--st-white);42 --st-dragging-background-color: #f5f3ff;43 --st-selected-cell-background-color: #f5f3ff;44 --st-selected-first-cell-background-color: #ede9fe;45 --st-footer-background-color: #f5f5f4;46 --st-cell-color: #44403c;47 --st-cell-odd-row-color: #44403c;48 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),49 0 2px 4px -1px rgba(124, 58, 237, 0.06);50 --st-selected-cell-color: #5b21b6;51 --st-selected-first-cell-color: #5b21b6;52 --st-resize-handle-color: #a78bfa;53 --st-resize-handle-selected-color: var(--st-white);54 --st-separator-border-color: #e7e5e4;55 --st-last-group-row-separator-border-color: #d6d3d1;5657 --st-selected-border-color: #8b5cf6;58 --st-editable-cell-focus-border-color: #8b5cf6;5960 --st-checkbox-checked-background-color: #8b5cf6;61 --st-checkbox-checked-border-color: #7c3aed;62 --st-column-editor-background-color: var(--st-white);63 --st-column-editor-popout-background-color: var(--st-white);64 --st-button-hover-background-color: #f5f3ff;65 --st-button-active-background-color: #7c3aed;66 --st-cell-flash-color: #ddd6fe;67 --st-copy-flash-color: #8b5cf6;68 --st-warning-flash-color: var(--st-red-300);6970 --st-header-selected-background-color: #6d28d9;71 --st-header-selected-label-color: var(--st-white);72 --st-header-selected-icon-color: var(--st-white);7374 --st-header-highlight-indicator-color: #d6d3d1;75 --st-selection-highlight-indicator-color: #d6d3d1;7677 --st-next-prev-btn-color: #57534e;78 --st-next-prev-btn-disabled-color: #a8a29e;7980 --st-page-btn-color: #57534e;81 --st-page-btn-hover-background-color: #fef3c7;8283 --st-column-editor-text-color: #78716c;8485 --st-checkbox-border-color: #d6d3d1;8687 --st-dropdown-group-label-color: #78716c;8889 --st-datepicker-weekday-color: #78716c;90 --st-datepicker-other-month-color: #a8a29e;9192 --st-filter-button-disabled-background-color: #d6d3d1;93 --st-filter-button-disabled-text-color: #78716c;9495 --st-sub-header-background-color: #8b5cf6;96 --st-sub-cell-background-color: #fef8dc;97 --st-sub-cell-hover-background-color: #fef3c7;98 --st-dragging-sub-header-background-color: #c4b5fd;99 --st-selected-sub-cell-background-color: #ede9fe;100 --st-selected-sub-cell-color: #4c1d95;101102 --st-chart-color: #8b5cf6;103 --st-chart-fill-color: #c4b5fd;104105 --st-drag-separator-color: #8b5cf6;106}107108.theme-custom .st-header-label {109 font-weight: 600 !important;110 letter-spacing: 0.025em !important;111}112
1import { SimpleTableVanilla } from "simple-table-core";2import type { Theme } from "simple-table-core";3import { customThemeConfig } from "./custom-theme.demo-data";4import "simple-table-core/styles.css";5import "./custom-theme.css";67export function renderCustomThemeDemo(8 container: HTMLElement,9 options?: { height?: string | number; theme?: Theme }10): SimpleTableVanilla {11 const table = new SimpleTableVanilla(container, {12 columns: [...customThemeConfig.headers],13 rows: customThemeConfig.rows,14 height: options?.height ?? "400px",15 theme: options?.theme ?? "custom",16 customTheme: customThemeConfig.tableProps.customTheme,17 columnResizing: true,18 selectableCells: true,19 });20 return table;21}222324// custom-theme.css25.theme-custom {26 --st-border-radius: 8px;27 --st-cell-padding: 12px;2829 --st-spacing-small: 6px;30 --st-spacing-medium: 10px;3132 --st-scrollbar-bg-color: #f5f5f4;33 --st-scrollbar-thumb-color: #8b5cf6;3435 --st-border-color: #e7e5e4;36 --st-odd-row-background-color: #fffbeb;37 --st-even-row-background-color: #fef3c7;38 --st-odd-column-background-color: #fffbeb;39 --st-even-column-background-color: var(--st-white);40 --st-hover-row-background-color: #fde68a;41 --st-selected-row-background-color: #f5f3ff;42 --st-header-background-color: #7c3aed;43 --st-header-label-color: var(--st-white);44 --st-header-icon-color: var(--st-white);45 --st-dragging-background-color: #f5f3ff;46 --st-selected-cell-background-color: #f5f3ff;47 --st-selected-first-cell-background-color: #ede9fe;48 --st-footer-background-color: #f5f5f4;49 --st-cell-color: #44403c;50 --st-cell-odd-row-color: #44403c;51 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),52 0 2px 4px -1px rgba(124, 58, 237, 0.06);53 --st-selected-cell-color: #5b21b6;54 --st-selected-first-cell-color: #5b21b6;55 --st-resize-handle-color: #a78bfa;56 --st-resize-handle-selected-color: var(--st-white);57 --st-separator-border-color: #e7e5e4;58 --st-last-group-row-separator-border-color: #d6d3d1;5960 --st-selected-border-color: #8b5cf6;61 --st-editable-cell-focus-border-color: #8b5cf6;6263 --st-checkbox-checked-background-color: #8b5cf6;64 --st-checkbox-checked-border-color: #7c3aed;65 --st-column-editor-background-color: var(--st-white);66 --st-column-editor-popout-background-color: var(--st-white);67 --st-button-hover-background-color: #f5f3ff;68 --st-button-active-background-color: #7c3aed;69 --st-cell-flash-color: #ddd6fe;70 --st-copy-flash-color: #8b5cf6;71 --st-warning-flash-color: var(--st-red-300);7273 --st-header-selected-background-color: #6d28d9;74 --st-header-selected-label-color: var(--st-white);75 --st-header-selected-icon-color: var(--st-white);7677 --st-header-highlight-indicator-color: #d6d3d1;78 --st-selection-highlight-indicator-color: #d6d3d1;7980 --st-next-prev-btn-color: #57534e;81 --st-next-prev-btn-disabled-color: #a8a29e;8283 --st-page-btn-color: #57534e;84 --st-page-btn-hover-background-color: #fef3c7;8586 --st-column-editor-text-color: #78716c;8788 --st-checkbox-border-color: #d6d3d1;8990 --st-dropdown-group-label-color: #78716c;9192 --st-datepicker-weekday-color: #78716c;93 --st-datepicker-other-month-color: #a8a29e;9495 --st-filter-button-disabled-background-color: #d6d3d1;96 --st-filter-button-disabled-text-color: #78716c;9798 --st-sub-header-background-color: #8b5cf6;99 --st-sub-cell-background-color: #fef8dc;100 --st-sub-cell-hover-background-color: #fef3c7;101 --st-dragging-sub-header-background-color: #c4b5fd;102 --st-selected-sub-cell-background-color: #ede9fe;103 --st-selected-sub-cell-color: #4c1d95;104105 --st-chart-color: #8b5cf6;106 --st-chart-fill-color: #c4b5fd;107108 --st-drag-separator-color: #8b5cf6;109}110111.theme-custom .st-header-label {112 font-weight: 600 !important;113 letter-spacing: 0.025em !important;114}115116117// custom-theme.demo-data.ts118// Self-contained demo table setup for this example.119import type { ColumnDef, Row } from "simple-table-core";120121122export const customThemeData: Row[] = [123 { id: 1, name: "Alice Johnson", phone: "2125551234", email: "alice@corp.com", city: "New York", status: "active" },124 { id: 2, name: "Bob Martinez", phone: "3105559876", email: "bob@corp.com", city: "Los Angeles", status: "active" },125 { id: 3, name: "Clara Chen", phone: "4155553210", email: "clara@corp.com", city: "San Francisco", status: "inactive" },126 { id: 4, name: "David Kim", phone: "3125557654", email: "david@corp.com", city: "Chicago", status: "active" },127 { id: 5, name: "Elena Rossi", phone: "6175554321", email: "elena@corp.com", city: "Boston", status: "active" },128 { id: 6, name: "Frank Müller", phone: "2065558765", email: "frank@corp.com", city: "Seattle", status: "inactive" },129 { id: 7, name: "Grace Park", phone: "5125552468", email: "grace@corp.com", city: "Austin", status: "active" },130 { id: 8, name: "Henry Patel", phone: "3035551357", email: "henry@corp.com", city: "Denver", status: "active" },131];132133function formatPhone(raw: string): string {134 if (raw.length === 10) {135 return `(${raw.slice(0, 3)}) ${raw.slice(3, 6)}-${raw.slice(6)}`;136 }137 return raw;138}139140export const customThemeHeaders: ColumnDef[] = [141 { accessor: "id", label: "ID", width: 60, type: "number" },142 { accessor: "name", label: "Name", width: 170, type: "string", sortable: true },143 {144 accessor: "phone",145 label: "Phone",146 width: 150,147 type: "string",148 valueFormatter: ({ value }) => formatPhone(value as string),149 },150 { accessor: "email", label: "Email", width: 180, type: "string" },151 { accessor: "city", label: "City", width: 140, type: "string", sortable: true },152 { accessor: "status", label: "Status", width: 100, type: "string" },153];154155export const customThemeConfig = {156 headers: customThemeHeaders,157 rows: customThemeData,158 tableProps: {159 theme: "custom" as const,160 customTheme: {161 rowHeight: 40,162 headerHeight: 44,163 },164 },165} as const;166
Creating a Custom CSS Theme
To create a custom CSS theme for Simple Table, follow these steps:
- Create a CSS file with your theme variables using the
.theme-customclass - Import the CSS file into your application
- Apply the theme by passing
theme="custom"to the SimpleTable component
CSS Theme Configuration
| Property | Required | Description | Example |
|---|---|---|---|
Property | Required | Description | Example |
theme | Optional | Set to "custom" to apply your custom CSS theme. Requires a corresponding CSS file with .theme-custom class and CSS variables. |
Theme Variable Tips
- Use the
.theme-customclass to define your custom theme - Define CSS variables with the
--st-prefix - Customize colors, spacing, fonts, and transitions
- Use direct hex values or color variables for consistent styling
- Test your theme with different features like column resizing and cell selection
CSS Variables Example
Here are the CSS variables used to create the custom theme in the demo above:
1import {SimpleTable} from "@simple-table/react";import type { Theme } from "@simple-table/react";2import { customThemeConfig } from "./custom-theme.demo-data";3import "@simple-table/react/styles.css";4import "./custom-theme.css";56const CustomThemeDemo = ({7 height = "400px",8 theme,9}: {10 height?: string | number;11 theme?: Theme;12}) => {13 return (14 <SimpleTable15 columns={customThemeConfig.headers}16 rows={customThemeConfig.rows}17 theme={theme ?? "custom"}18 customTheme={customThemeConfig.tableProps.customTheme}19 columnResizing20 selectableCells21 height={height}22 />23 );24};2526export default CustomThemeDemo;272829// custom-theme.css30.theme-custom {31 --st-border-radius: 8px;32 --st-cell-padding: 12px;3334 --st-spacing-small: 6px;35 --st-spacing-medium: 10px;3637 --st-scrollbar-bg-color: #f5f5f4;38 --st-scrollbar-thumb-color: #8b5cf6;3940 --st-border-color: #e7e5e4;41 --st-odd-row-background-color: #fffbeb;42 --st-even-row-background-color: #fef3c7;43 --st-odd-column-background-color: #fffbeb;44 --st-even-column-background-color: var(--st-white);45 --st-hover-row-background-color: #fde68a;46 --st-selected-row-background-color: #f5f3ff;47 --st-header-background-color: #7c3aed;48 --st-header-label-color: var(--st-white);49 --st-header-icon-color: var(--st-white);50 --st-dragging-background-color: #f5f3ff;51 --st-selected-cell-background-color: #f5f3ff;52 --st-selected-first-cell-background-color: #ede9fe;53 --st-footer-background-color: #f5f5f4;54 --st-cell-color: #44403c;55 --st-cell-odd-row-color: #44403c;56 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),57 0 2px 4px -1px rgba(124, 58, 237, 0.06);58 --st-selected-cell-color: #5b21b6;59 --st-selected-first-cell-color: #5b21b6;60 --st-resize-handle-color: #a78bfa;61 --st-resize-handle-selected-color: var(--st-white);62 --st-separator-border-color: #e7e5e4;63 --st-last-group-row-separator-border-color: #d6d3d1;6465 --st-selected-border-color: #8b5cf6;66 --st-editable-cell-focus-border-color: #8b5cf6;6768 --st-checkbox-checked-background-color: #8b5cf6;69 --st-checkbox-checked-border-color: #7c3aed;70 --st-column-editor-background-color: var(--st-white);71 --st-column-editor-popout-background-color: var(--st-white);72 --st-button-hover-background-color: #f5f3ff;73 --st-button-active-background-color: #7c3aed;74 --st-cell-flash-color: #ddd6fe;75 --st-copy-flash-color: #8b5cf6;76 --st-warning-flash-color: var(--st-red-300);7778 --st-header-selected-background-color: #6d28d9;79 --st-header-selected-label-color: var(--st-white);80 --st-header-selected-icon-color: var(--st-white);8182 --st-header-highlight-indicator-color: #d6d3d1;83 --st-selection-highlight-indicator-color: #d6d3d1;8485 --st-next-prev-btn-color: #57534e;86 --st-next-prev-btn-disabled-color: #a8a29e;8788 --st-page-btn-color: #57534e;89 --st-page-btn-hover-background-color: #fef3c7;9091 --st-column-editor-text-color: #78716c;9293 --st-checkbox-border-color: #d6d3d1;9495 --st-dropdown-group-label-color: #78716c;9697 --st-datepicker-weekday-color: #78716c;98 --st-datepicker-other-month-color: #a8a29e;99100 --st-filter-button-disabled-background-color: #d6d3d1;101 --st-filter-button-disabled-text-color: #78716c;102103 --st-sub-header-background-color: #8b5cf6;104 --st-sub-cell-background-color: #fef8dc;105 --st-sub-cell-hover-background-color: #fef3c7;106 --st-dragging-sub-header-background-color: #c4b5fd;107 --st-selected-sub-cell-background-color: #ede9fe;108 --st-selected-sub-cell-color: #4c1d95;109110 --st-chart-color: #8b5cf6;111 --st-chart-fill-color: #c4b5fd;112113 --st-drag-separator-color: #8b5cf6;114}115116.theme-custom .st-header-label {117 font-weight: 600 !important;118 letter-spacing: 0.025em !important;119}120
1<script setup lang="ts">2import {SimpleTable} from "@simple-table/vue";import type { Theme } from "@simple-table/vue";3import { customThemeConfig } from "./custom-theme.demo-data";4import "@simple-table/vue/styles.css";5import "./custom-theme.css";67const props = withDefaults(defineProps<{ height?: string | number; theme?: Theme }>(), {8 height: "400px",9});10</script>1112<template>13 <SimpleTable14 :columns="customThemeConfig.headers"15 :rows="customThemeConfig.rows"16 :theme="props.theme ?? 'custom'"17 :custom-theme="customThemeConfig.tableProps.customTheme"18 :column-resizing="true"19 :selectable-cells="true"20 :height="props.height"21 />22</template>232425// custom-theme.css26.theme-custom {27 --st-border-radius: 8px;28 --st-cell-padding: 12px;2930 --st-spacing-small: 6px;31 --st-spacing-medium: 10px;3233 --st-scrollbar-bg-color: #f5f5f4;34 --st-scrollbar-thumb-color: #8b5cf6;3536 --st-border-color: #e7e5e4;37 --st-odd-row-background-color: #fffbeb;38 --st-even-row-background-color: #fef3c7;39 --st-odd-column-background-color: #fffbeb;40 --st-even-column-background-color: var(--st-white);41 --st-hover-row-background-color: #fde68a;42 --st-selected-row-background-color: #f5f3ff;43 --st-header-background-color: #7c3aed;44 --st-header-label-color: var(--st-white);45 --st-header-icon-color: var(--st-white);46 --st-dragging-background-color: #f5f3ff;47 --st-selected-cell-background-color: #f5f3ff;48 --st-selected-first-cell-background-color: #ede9fe;49 --st-footer-background-color: #f5f5f4;50 --st-cell-color: #44403c;51 --st-cell-odd-row-color: #44403c;52 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),53 0 2px 4px -1px rgba(124, 58, 237, 0.06);54 --st-selected-cell-color: #5b21b6;55 --st-selected-first-cell-color: #5b21b6;56 --st-resize-handle-color: #a78bfa;57 --st-resize-handle-selected-color: var(--st-white);58 --st-separator-border-color: #e7e5e4;59 --st-last-group-row-separator-border-color: #d6d3d1;6061 --st-selected-border-color: #8b5cf6;62 --st-editable-cell-focus-border-color: #8b5cf6;6364 --st-checkbox-checked-background-color: #8b5cf6;65 --st-checkbox-checked-border-color: #7c3aed;66 --st-column-editor-background-color: var(--st-white);67 --st-column-editor-popout-background-color: var(--st-white);68 --st-button-hover-background-color: #f5f3ff;69 --st-button-active-background-color: #7c3aed;70 --st-cell-flash-color: #ddd6fe;71 --st-copy-flash-color: #8b5cf6;72 --st-warning-flash-color: var(--st-red-300);7374 --st-header-selected-background-color: #6d28d9;75 --st-header-selected-label-color: var(--st-white);76 --st-header-selected-icon-color: var(--st-white);7778 --st-header-highlight-indicator-color: #d6d3d1;79 --st-selection-highlight-indicator-color: #d6d3d1;8081 --st-next-prev-btn-color: #57534e;82 --st-next-prev-btn-disabled-color: #a8a29e;8384 --st-page-btn-color: #57534e;85 --st-page-btn-hover-background-color: #fef3c7;8687 --st-column-editor-text-color: #78716c;8889 --st-checkbox-border-color: #d6d3d1;9091 --st-dropdown-group-label-color: #78716c;9293 --st-datepicker-weekday-color: #78716c;94 --st-datepicker-other-month-color: #a8a29e;9596 --st-filter-button-disabled-background-color: #d6d3d1;97 --st-filter-button-disabled-text-color: #78716c;9899 --st-sub-header-background-color: #8b5cf6;100 --st-sub-cell-background-color: #fef8dc;101 --st-sub-cell-hover-background-color: #fef3c7;102 --st-dragging-sub-header-background-color: #c4b5fd;103 --st-selected-sub-cell-background-color: #ede9fe;104 --st-selected-sub-cell-color: #4c1d95;105106 --st-chart-color: #8b5cf6;107 --st-chart-fill-color: #c4b5fd;108109 --st-drag-separator-color: #8b5cf6;110}111112.theme-custom .st-header-label {113 font-weight: 600 !important;114 letter-spacing: 0.025em !important;115}116
1import { Component, Input } from "@angular/core";2import {SimpleTableComponent} from "@simple-table/angular";import type { AngularColumnDef, Row, Theme } from "@simple-table/angular";3import { customThemeConfig } from "./custom-theme.demo-data";4import "@simple-table/angular/styles.css";5import "./custom-theme.css";67@Component({8 selector: "custom-theme-demo",9 standalone: true,10 imports: [SimpleTableComponent],11 template: `12 <simple-table13 [rows]="rows"14 [columns]="headers"15 [height]="height"16 [theme]="resolvedTheme"17 [customTheme]="customThemeOverrides"18 [columnResizing]="true"19 [selectableCells]="true"20 ></simple-table>21 `,22})23export class CustomThemeDemoComponent {24 @Input() height: string | number = "400px";25 @Input() theme?: Theme;2627 readonly rows: Row[] = customThemeConfig.rows;28 readonly headers: AngularColumnDef[] = customThemeConfig.headers;29 readonly customThemeOverrides = customThemeConfig.tableProps.customTheme;3031 get resolvedTheme(): Theme {32 return this.theme ?? "custom";33 }34}353637// custom-theme.css38.theme-custom {39 --st-border-radius: 8px;40 --st-cell-padding: 12px;4142 --st-spacing-small: 6px;43 --st-spacing-medium: 10px;4445 --st-scrollbar-bg-color: #f5f5f4;46 --st-scrollbar-thumb-color: #8b5cf6;4748 --st-border-color: #e7e5e4;49 --st-odd-row-background-color: #fffbeb;50 --st-even-row-background-color: #fef3c7;51 --st-odd-column-background-color: #fffbeb;52 --st-even-column-background-color: var(--st-white);53 --st-hover-row-background-color: #fde68a;54 --st-selected-row-background-color: #f5f3ff;55 --st-header-background-color: #7c3aed;56 --st-header-label-color: var(--st-white);57 --st-header-icon-color: var(--st-white);58 --st-dragging-background-color: #f5f3ff;59 --st-selected-cell-background-color: #f5f3ff;60 --st-selected-first-cell-background-color: #ede9fe;61 --st-footer-background-color: #f5f5f4;62 --st-cell-color: #44403c;63 --st-cell-odd-row-color: #44403c;64 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),65 0 2px 4px -1px rgba(124, 58, 237, 0.06);66 --st-selected-cell-color: #5b21b6;67 --st-selected-first-cell-color: #5b21b6;68 --st-resize-handle-color: #a78bfa;69 --st-resize-handle-selected-color: var(--st-white);70 --st-separator-border-color: #e7e5e4;71 --st-last-group-row-separator-border-color: #d6d3d1;7273 --st-selected-border-color: #8b5cf6;74 --st-editable-cell-focus-border-color: #8b5cf6;7576 --st-checkbox-checked-background-color: #8b5cf6;77 --st-checkbox-checked-border-color: #7c3aed;78 --st-column-editor-background-color: var(--st-white);79 --st-column-editor-popout-background-color: var(--st-white);80 --st-button-hover-background-color: #f5f3ff;81 --st-button-active-background-color: #7c3aed;82 --st-cell-flash-color: #ddd6fe;83 --st-copy-flash-color: #8b5cf6;84 --st-warning-flash-color: var(--st-red-300);8586 --st-header-selected-background-color: #6d28d9;87 --st-header-selected-label-color: var(--st-white);88 --st-header-selected-icon-color: var(--st-white);8990 --st-header-highlight-indicator-color: #d6d3d1;91 --st-selection-highlight-indicator-color: #d6d3d1;9293 --st-next-prev-btn-color: #57534e;94 --st-next-prev-btn-disabled-color: #a8a29e;9596 --st-page-btn-color: #57534e;97 --st-page-btn-hover-background-color: #fef3c7;9899 --st-column-editor-text-color: #78716c;100101 --st-checkbox-border-color: #d6d3d1;102103 --st-dropdown-group-label-color: #78716c;104105 --st-datepicker-weekday-color: #78716c;106 --st-datepicker-other-month-color: #a8a29e;107108 --st-filter-button-disabled-background-color: #d6d3d1;109 --st-filter-button-disabled-text-color: #78716c;110111 --st-sub-header-background-color: #8b5cf6;112 --st-sub-cell-background-color: #fef8dc;113 --st-sub-cell-hover-background-color: #fef3c7;114 --st-dragging-sub-header-background-color: #c4b5fd;115 --st-selected-sub-cell-background-color: #ede9fe;116 --st-selected-sub-cell-color: #4c1d95;117118 --st-chart-color: #8b5cf6;119 --st-chart-fill-color: #c4b5fd;120121 --st-drag-separator-color: #8b5cf6;122}123124.theme-custom .st-header-label {125 font-weight: 600 !important;126 letter-spacing: 0.025em !important;127}128129130// custom-theme.demo-data.ts131// Self-contained demo table setup for this example.132import type { AngularColumnDef, Row } from "@simple-table/angular";133134135export const customThemeData: Row[] = [136 { id: 1, name: "Alice Johnson", phone: "2125551234", email: "alice@corp.com", city: "New York", status: "active" },137 { id: 2, name: "Bob Martinez", phone: "3105559876", email: "bob@corp.com", city: "Los Angeles", status: "active" },138 { id: 3, name: "Clara Chen", phone: "4155553210", email: "clara@corp.com", city: "San Francisco", status: "inactive" },139 { id: 4, name: "David Kim", phone: "3125557654", email: "david@corp.com", city: "Chicago", status: "active" },140 { id: 5, name: "Elena Rossi", phone: "6175554321", email: "elena@corp.com", city: "Boston", status: "active" },141 { id: 6, name: "Frank Müller", phone: "2065558765", email: "frank@corp.com", city: "Seattle", status: "inactive" },142 { id: 7, name: "Grace Park", phone: "5125552468", email: "grace@corp.com", city: "Austin", status: "active" },143 { id: 8, name: "Henry Patel", phone: "3035551357", email: "henry@corp.com", city: "Denver", status: "active" },144];145146function formatPhone(raw: string): string {147 if (raw.length === 10) {148 return `(${raw.slice(0, 3)}) ${raw.slice(3, 6)}-${raw.slice(6)}`;149 }150 return raw;151}152153export const customThemeHeaders: AngularColumnDef[] = [154 { accessor: "id", label: "ID", width: 60, type: "number" },155 { accessor: "name", label: "Name", width: 170, type: "string", sortable: true },156 {157 accessor: "phone",158 label: "Phone",159 width: 150,160 type: "string",161 valueFormatter: ({ value }) => formatPhone(value as string),162 },163 { accessor: "email", label: "Email", width: 180, type: "string" },164 { accessor: "city", label: "City", width: 140, type: "string", sortable: true },165 { accessor: "status", label: "Status", width: 100, type: "string" },166];167168export const customThemeConfig = {169 headers: customThemeHeaders,170 rows: customThemeData,171 tableProps: {172 theme: "custom" as const,173 customTheme: {174 rowHeight: 40,175 headerHeight: 44,176 },177 },178} as const;179
1<script lang="ts">2 import {SimpleTable} from "@simple-table/svelte"; import type { Theme } from "@simple-table/svelte";3 import { customThemeConfig } from "./custom-theme.demo-data";4 import "@simple-table/svelte/styles.css";5 import "./custom-theme.css";67 let { height = "400px", theme }: { height?: string | number; theme?: Theme } = $props();8</script>910<SimpleTable11 columns={customThemeConfig.headers}12 rows={customThemeConfig.rows}13 theme={theme ?? "custom"}14 customTheme={customThemeConfig.tableProps.customTheme}15 columnResizing={true}16 selectableCells={true}17 {height}18/>192021// custom-theme.css22.theme-custom {23 --st-border-radius: 8px;24 --st-cell-padding: 12px;2526 --st-spacing-small: 6px;27 --st-spacing-medium: 10px;2829 --st-scrollbar-bg-color: #f5f5f4;30 --st-scrollbar-thumb-color: #8b5cf6;3132 --st-border-color: #e7e5e4;33 --st-odd-row-background-color: #fffbeb;34 --st-even-row-background-color: #fef3c7;35 --st-odd-column-background-color: #fffbeb;36 --st-even-column-background-color: var(--st-white);37 --st-hover-row-background-color: #fde68a;38 --st-selected-row-background-color: #f5f3ff;39 --st-header-background-color: #7c3aed;40 --st-header-label-color: var(--st-white);41 --st-header-icon-color: var(--st-white);42 --st-dragging-background-color: #f5f3ff;43 --st-selected-cell-background-color: #f5f3ff;44 --st-selected-first-cell-background-color: #ede9fe;45 --st-footer-background-color: #f5f5f4;46 --st-cell-color: #44403c;47 --st-cell-odd-row-color: #44403c;48 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),49 0 2px 4px -1px rgba(124, 58, 237, 0.06);50 --st-selected-cell-color: #5b21b6;51 --st-selected-first-cell-color: #5b21b6;52 --st-resize-handle-color: #a78bfa;53 --st-resize-handle-selected-color: var(--st-white);54 --st-separator-border-color: #e7e5e4;55 --st-last-group-row-separator-border-color: #d6d3d1;5657 --st-selected-border-color: #8b5cf6;58 --st-editable-cell-focus-border-color: #8b5cf6;5960 --st-checkbox-checked-background-color: #8b5cf6;61 --st-checkbox-checked-border-color: #7c3aed;62 --st-column-editor-background-color: var(--st-white);63 --st-column-editor-popout-background-color: var(--st-white);64 --st-button-hover-background-color: #f5f3ff;65 --st-button-active-background-color: #7c3aed;66 --st-cell-flash-color: #ddd6fe;67 --st-copy-flash-color: #8b5cf6;68 --st-warning-flash-color: var(--st-red-300);6970 --st-header-selected-background-color: #6d28d9;71 --st-header-selected-label-color: var(--st-white);72 --st-header-selected-icon-color: var(--st-white);7374 --st-header-highlight-indicator-color: #d6d3d1;75 --st-selection-highlight-indicator-color: #d6d3d1;7677 --st-next-prev-btn-color: #57534e;78 --st-next-prev-btn-disabled-color: #a8a29e;7980 --st-page-btn-color: #57534e;81 --st-page-btn-hover-background-color: #fef3c7;8283 --st-column-editor-text-color: #78716c;8485 --st-checkbox-border-color: #d6d3d1;8687 --st-dropdown-group-label-color: #78716c;8889 --st-datepicker-weekday-color: #78716c;90 --st-datepicker-other-month-color: #a8a29e;9192 --st-filter-button-disabled-background-color: #d6d3d1;93 --st-filter-button-disabled-text-color: #78716c;9495 --st-sub-header-background-color: #8b5cf6;96 --st-sub-cell-background-color: #fef8dc;97 --st-sub-cell-hover-background-color: #fef3c7;98 --st-dragging-sub-header-background-color: #c4b5fd;99 --st-selected-sub-cell-background-color: #ede9fe;100 --st-selected-sub-cell-color: #4c1d95;101102 --st-chart-color: #8b5cf6;103 --st-chart-fill-color: #c4b5fd;104105 --st-drag-separator-color: #8b5cf6;106}107108.theme-custom .st-header-label {109 font-weight: 600 !important;110 letter-spacing: 0.025em !important;111}112
1import {SimpleTable} from "@simple-table/solid";import type { Theme } from "@simple-table/solid";2import { customThemeConfig } from "./custom-theme.demo-data";3import "@simple-table/solid/styles.css";4import "./custom-theme.css";56export default function CustomThemeDemo(props: { height?: string | number; theme?: Theme }) {7 return (8 <SimpleTable9 columns={customThemeConfig.headers}10 rows={customThemeConfig.rows}11 height={props.height ?? "400px"}12 theme={props.theme ?? "custom"}13 customTheme={customThemeConfig.tableProps.customTheme}14 columnResizing15 selectableCells16 />17 );18}192021// custom-theme.css22.theme-custom {23 --st-border-radius: 8px;24 --st-cell-padding: 12px;2526 --st-spacing-small: 6px;27 --st-spacing-medium: 10px;2829 --st-scrollbar-bg-color: #f5f5f4;30 --st-scrollbar-thumb-color: #8b5cf6;3132 --st-border-color: #e7e5e4;33 --st-odd-row-background-color: #fffbeb;34 --st-even-row-background-color: #fef3c7;35 --st-odd-column-background-color: #fffbeb;36 --st-even-column-background-color: var(--st-white);37 --st-hover-row-background-color: #fde68a;38 --st-selected-row-background-color: #f5f3ff;39 --st-header-background-color: #7c3aed;40 --st-header-label-color: var(--st-white);41 --st-header-icon-color: var(--st-white);42 --st-dragging-background-color: #f5f3ff;43 --st-selected-cell-background-color: #f5f3ff;44 --st-selected-first-cell-background-color: #ede9fe;45 --st-footer-background-color: #f5f5f4;46 --st-cell-color: #44403c;47 --st-cell-odd-row-color: #44403c;48 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),49 0 2px 4px -1px rgba(124, 58, 237, 0.06);50 --st-selected-cell-color: #5b21b6;51 --st-selected-first-cell-color: #5b21b6;52 --st-resize-handle-color: #a78bfa;53 --st-resize-handle-selected-color: var(--st-white);54 --st-separator-border-color: #e7e5e4;55 --st-last-group-row-separator-border-color: #d6d3d1;5657 --st-selected-border-color: #8b5cf6;58 --st-editable-cell-focus-border-color: #8b5cf6;5960 --st-checkbox-checked-background-color: #8b5cf6;61 --st-checkbox-checked-border-color: #7c3aed;62 --st-column-editor-background-color: var(--st-white);63 --st-column-editor-popout-background-color: var(--st-white);64 --st-button-hover-background-color: #f5f3ff;65 --st-button-active-background-color: #7c3aed;66 --st-cell-flash-color: #ddd6fe;67 --st-copy-flash-color: #8b5cf6;68 --st-warning-flash-color: var(--st-red-300);6970 --st-header-selected-background-color: #6d28d9;71 --st-header-selected-label-color: var(--st-white);72 --st-header-selected-icon-color: var(--st-white);7374 --st-header-highlight-indicator-color: #d6d3d1;75 --st-selection-highlight-indicator-color: #d6d3d1;7677 --st-next-prev-btn-color: #57534e;78 --st-next-prev-btn-disabled-color: #a8a29e;7980 --st-page-btn-color: #57534e;81 --st-page-btn-hover-background-color: #fef3c7;8283 --st-column-editor-text-color: #78716c;8485 --st-checkbox-border-color: #d6d3d1;8687 --st-dropdown-group-label-color: #78716c;8889 --st-datepicker-weekday-color: #78716c;90 --st-datepicker-other-month-color: #a8a29e;9192 --st-filter-button-disabled-background-color: #d6d3d1;93 --st-filter-button-disabled-text-color: #78716c;9495 --st-sub-header-background-color: #8b5cf6;96 --st-sub-cell-background-color: #fef8dc;97 --st-sub-cell-hover-background-color: #fef3c7;98 --st-dragging-sub-header-background-color: #c4b5fd;99 --st-selected-sub-cell-background-color: #ede9fe;100 --st-selected-sub-cell-color: #4c1d95;101102 --st-chart-color: #8b5cf6;103 --st-chart-fill-color: #c4b5fd;104105 --st-drag-separator-color: #8b5cf6;106}107108.theme-custom .st-header-label {109 font-weight: 600 !important;110 letter-spacing: 0.025em !important;111}112
1import { SimpleTableVanilla } from "simple-table-core";2import type { Theme } from "simple-table-core";3import { customThemeConfig } from "./custom-theme.demo-data";4import "simple-table-core/styles.css";5import "./custom-theme.css";67export function renderCustomThemeDemo(8 container: HTMLElement,9 options?: { height?: string | number; theme?: Theme }10): SimpleTableVanilla {11 const table = new SimpleTableVanilla(container, {12 columns: [...customThemeConfig.headers],13 rows: customThemeConfig.rows,14 height: options?.height ?? "400px",15 theme: options?.theme ?? "custom",16 customTheme: customThemeConfig.tableProps.customTheme,17 columnResizing: true,18 selectableCells: true,19 });20 return table;21}222324// custom-theme.css25.theme-custom {26 --st-border-radius: 8px;27 --st-cell-padding: 12px;2829 --st-spacing-small: 6px;30 --st-spacing-medium: 10px;3132 --st-scrollbar-bg-color: #f5f5f4;33 --st-scrollbar-thumb-color: #8b5cf6;3435 --st-border-color: #e7e5e4;36 --st-odd-row-background-color: #fffbeb;37 --st-even-row-background-color: #fef3c7;38 --st-odd-column-background-color: #fffbeb;39 --st-even-column-background-color: var(--st-white);40 --st-hover-row-background-color: #fde68a;41 --st-selected-row-background-color: #f5f3ff;42 --st-header-background-color: #7c3aed;43 --st-header-label-color: var(--st-white);44 --st-header-icon-color: var(--st-white);45 --st-dragging-background-color: #f5f3ff;46 --st-selected-cell-background-color: #f5f3ff;47 --st-selected-first-cell-background-color: #ede9fe;48 --st-footer-background-color: #f5f5f4;49 --st-cell-color: #44403c;50 --st-cell-odd-row-color: #44403c;51 --st-edit-cell-shadow: 0 4px 6px -1px rgba(124, 58, 237, 0.1),52 0 2px 4px -1px rgba(124, 58, 237, 0.06);53 --st-selected-cell-color: #5b21b6;54 --st-selected-first-cell-color: #5b21b6;55 --st-resize-handle-color: #a78bfa;56 --st-resize-handle-selected-color: var(--st-white);57 --st-separator-border-color: #e7e5e4;58 --st-last-group-row-separator-border-color: #d6d3d1;5960 --st-selected-border-color: #8b5cf6;61 --st-editable-cell-focus-border-color: #8b5cf6;6263 --st-checkbox-checked-background-color: #8b5cf6;64 --st-checkbox-checked-border-color: #7c3aed;65 --st-column-editor-background-color: var(--st-white);66 --st-column-editor-popout-background-color: var(--st-white);67 --st-button-hover-background-color: #f5f3ff;68 --st-button-active-background-color: #7c3aed;69 --st-cell-flash-color: #ddd6fe;70 --st-copy-flash-color: #8b5cf6;71 --st-warning-flash-color: var(--st-red-300);7273 --st-header-selected-background-color: #6d28d9;74 --st-header-selected-label-color: var(--st-white);75 --st-header-selected-icon-color: var(--st-white);7677 --st-header-highlight-indicator-color: #d6d3d1;78 --st-selection-highlight-indicator-color: #d6d3d1;7980 --st-next-prev-btn-color: #57534e;81 --st-next-prev-btn-disabled-color: #a8a29e;8283 --st-page-btn-color: #57534e;84 --st-page-btn-hover-background-color: #fef3c7;8586 --st-column-editor-text-color: #78716c;8788 --st-checkbox-border-color: #d6d3d1;8990 --st-dropdown-group-label-color: #78716c;9192 --st-datepicker-weekday-color: #78716c;93 --st-datepicker-other-month-color: #a8a29e;9495 --st-filter-button-disabled-background-color: #d6d3d1;96 --st-filter-button-disabled-text-color: #78716c;9798 --st-sub-header-background-color: #8b5cf6;99 --st-sub-cell-background-color: #fef8dc;100 --st-sub-cell-hover-background-color: #fef3c7;101 --st-dragging-sub-header-background-color: #c4b5fd;102 --st-selected-sub-cell-background-color: #ede9fe;103 --st-selected-sub-cell-color: #4c1d95;104105 --st-chart-color: #8b5cf6;106 --st-chart-fill-color: #c4b5fd;107108 --st-drag-separator-color: #8b5cf6;109}110111.theme-custom .st-header-label {112 font-weight: 600 !important;113 letter-spacing: 0.025em !important;114}115116117// custom-theme.demo-data.ts118// Self-contained demo table setup for this example.119import type { ColumnDef, Row } from "simple-table-core";120121122export const customThemeData: Row[] = [123 { id: 1, name: "Alice Johnson", phone: "2125551234", email: "alice@corp.com", city: "New York", status: "active" },124 { id: 2, name: "Bob Martinez", phone: "3105559876", email: "bob@corp.com", city: "Los Angeles", status: "active" },125 { id: 3, name: "Clara Chen", phone: "4155553210", email: "clara@corp.com", city: "San Francisco", status: "inactive" },126 { id: 4, name: "David Kim", phone: "3125557654", email: "david@corp.com", city: "Chicago", status: "active" },127 { id: 5, name: "Elena Rossi", phone: "6175554321", email: "elena@corp.com", city: "Boston", status: "active" },128 { id: 6, name: "Frank Müller", phone: "2065558765", email: "frank@corp.com", city: "Seattle", status: "inactive" },129 { id: 7, name: "Grace Park", phone: "5125552468", email: "grace@corp.com", city: "Austin", status: "active" },130 { id: 8, name: "Henry Patel", phone: "3035551357", email: "henry@corp.com", city: "Denver", status: "active" },131];132133function formatPhone(raw: string): string {134 if (raw.length === 10) {135 return `(${raw.slice(0, 3)}) ${raw.slice(3, 6)}-${raw.slice(6)}`;136 }137 return raw;138}139140export const customThemeHeaders: ColumnDef[] = [141 { accessor: "id", label: "ID", width: 60, type: "number" },142 { accessor: "name", label: "Name", width: 170, type: "string", sortable: true },143 {144 accessor: "phone",145 label: "Phone",146 width: 150,147 type: "string",148 valueFormatter: ({ value }) => formatPhone(value as string),149 },150 { accessor: "email", label: "Email", width: 180, type: "string" },151 { accessor: "city", label: "City", width: 140, type: "string", sortable: true },152 { accessor: "status", label: "Status", width: 100, type: "string" },153];154155export const customThemeConfig = {156 headers: customThemeHeaders,157 rows: customThemeData,158 tableProps: {159 theme: "custom" as const,160 customTheme: {161 rowHeight: 40,162 headerHeight: 44,163 },164 },165} as const;166
Combining Both Approaches
You can use both CSS theming and the customTheme prop together for complete control over your table's appearance:
Best Practice
Use CSS variables for all color and visual styling (backgrounds, borders, fonts, shadows), and use the customTheme prop for dimensions that affect layout calculations (heights, widths, spacing). This separation ensures optimal performance and maintainability.
New in v2.4.1: Column Editor Styling
Version 2.4.1 introduces new CSS classes and variables for styling the enhanced column editor with drag-and-drop and search functionality.
New Column Editor CSS Classes
.st-column-editor-search-wrapper- Search input container.st-column-editor-search- Search input wrapper.st-column-editor-list- Column list container.st-column-label-container- Column label wrapper.st-drag-icon-container- Drag handle container.st-column-editor-drag-separator- Drag drop indicator line
New CSS Variables:
--st-drag-separator-color- Color of the drag drop indicator line (theme-specific)
See the Column Editing documentation for more details on the column editor features.
Sub-Column Styling
Dedicated CSS variables for styling sub-columns (child columns within collapsible column groups). These variables give you fine-grained control over the appearance of nested column structures.
New Sub-Column CSS Variables
--st-sub-cell-hover-background-color- Background color when hovering over sub-cells--st-dragging-sub-header-background-color- Background color when dragging sub-headers--st-selected-sub-cell-background-color- Background color for selected sub-cells--st-selected-sub-cell-color- Text color for selected sub-cells
These variables complement the existing sub-column variables:
--st-sub-header-background-color- Background color for sub-column headers--st-sub-cell-background-color- Background color for sub-column cells
See the Collapsible Columns documentation for more details on using these variables.