부트스트랩·테일윈드·머티리얼 모양 테마Bootstrap, Tailwind and Material look presets
쓰는 사이트의 모양에 맞는 테마를 골라 한 줄로 적용해요. 글꼴은 사이트 글꼴을 그대로 써요.Pick the preset that matches your site and apply it in one line. The grid uses your site's own font.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)
이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/themes/presets @maxgrid/themes로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<select aria-label="프리셋" id="preset">
<option value="default" selected>기본</option>
<option value="bootstrap">부트스트랩</option>
<option value="tailwind">테일윈드</option>
<option value="material">머티리얼</option>
</select>
</div>
<div id="grid" style="height: 360px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('preset').addEventListener('change', (event) => actions.preset(api, event.target.value));import { applyTheme } from '@maxgrid/themes';
import { presets } from '@maxgrid/themes/presets';
const names = ['김하늘', '이도윤', '박서연', '최지우', '정민준', '강서준', '윤하은', '임지호'];
const depts = ['개발', '디자인', '영업', '인사'];
export const options = {
columns: [
{ id: 'name', title: '이름', width: 150, sortable: true },
{ id: 'dept', title: '부서', width: 120, sortable: true },
{ id: 'qty', title: '주문 수', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: '월 급여(원)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4],
qty: 12 + i * 5,
salary: 3200000 + i * 410000,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// 프리셋은 createTheme으로 만든 밝은 테마와 어두운 테마 한 쌍이에요. 사이트의 밝음·어두움 전환을 따라가요.
// 프리셋 CSS 파일(`@maxgrid/themes/preset-bootstrap.css` 등)을 쓰면 스크립트 없이 같은 모양이 돼요.
const siteMode = () => document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore;
let say = () => { };
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset)
return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
export function setup(api, log) {
say = log;
api.setSelectedKeys([2, 3]);
log({
ko: '프리셋을 고르면 이 표의 강조색, 선택 색, 모서리 둥글기, 줄 높이가 바뀌어요.',
en: 'Pick a preset to change the accent, selection, border radius and row height of this grid.',
});
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
export const actions = {
preset: (_api, value) => {
choice = value ?? 'default';
show();
say(choice === 'default'
? { ko: '기본 테마로 돌아왔어요', en: 'Back to the default theme' }
: { ko: `프리셋: ${choice}`, en: `Preset: ${choice}` });
},
}; 이 HTML은 추가 번들(위 script 태그)도 함께 불러오고 전역 변수로 써요. 별도 설치는 필요 없어요.
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>부트스트랩·테일윈드·머티리얼 모양 테마</title>
</head>
<body>
<div class="toolbar">
<select aria-label="프리셋" id="preset">
<option value="default" selected>기본</option>
<option value="bootstrap">부트스트랩</option>
<option value="tailwind">테일윈드</option>
<option value="material">머티리얼</option>
</select>
</div>
<div id="grid" style="height: 360px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.themes-presets.min.js"></script>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.themes.min.js"></script>
<script>
const { applyTheme } = MaxGrid.themes;
const { presets } = MaxGridThemesPresets;
const names = ['김하늘', '이도윤', '박서연', '최지우', '정민준', '강서준', '윤하은', '임지호'];
const depts = ['개발', '디자인', '영업', '인사'];
const options = {
columns: [
{ id: 'name', title: '이름', width: 150, sortable: true },
{ id: 'dept', title: '부서', width: 120, sortable: true },
{ id: 'qty', title: '주문 수', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: '월 급여(원)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4],
qty: 12 + i * 5,
salary: 3200000 + i * 410000,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// 프리셋은 createTheme으로 만든 밝은 테마와 어두운 테마 한 쌍이에요. 사이트의 밝음·어두움 전환을 따라가요.
// 프리셋 CSS 파일(`@maxgrid/themes/preset-bootstrap.css` 등)을 쓰면 스크립트 없이 같은 모양이 돼요.
const siteMode = () => document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore;
let say = () => { };
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset)
return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
function setup(api, log) {
say = log;
api.setSelectedKeys([2, 3]);
log({
ko: '프리셋을 고르면 이 표의 강조색, 선택 색, 모서리 둥글기, 줄 높이가 바뀌어요.',
en: 'Pick a preset to change the accent, selection, border radius and row height of this grid.',
});
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
const actions = {
preset: (_api, value) => {
choice = value ?? 'default';
show();
say(choice === 'default'
? { ko: '기본 테마로 돌아왔어요', en: 'Back to the default theme' }
: { ko: `프리셋: ${choice}`, en: `Preset: ${choice}` });
},
};
options.ariaLabel = "부트스트랩·테일윈드·머티리얼 모양 테마";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('preset').addEventListener('change', (event) => actions.preset(api, event.target.value));
</script>
</body>
</html> 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/react @maxgrid/themes/presets @maxgrid/themes로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<select
aria-label="프리셋"
disabled={!api}
onChange={(event) => api && actions.preset(api, event.target.value)}
>
<option value="default">기본</option>
<option value="bootstrap">부트스트랩</option>
<option value="tailwind">테일윈드</option>
<option value="material">머티리얼</option>
</select>
</div>
<Grid style={{ height: 360 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
import { applyTheme } from '@maxgrid/themes';
import { presets } from '@maxgrid/themes/presets';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
dept: string;
qty: number;
salary: number;
}
const names = ['김하늘', '이도윤', '박서연', '최지우', '정민준', '강서준', '윤하은', '임지호'];
const depts = ['개발', '디자인', '영업', '인사'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 150, sortable: true },
{ id: 'dept', title: '부서', width: 120, sortable: true },
{ id: 'qty', title: '주문 수', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: '월 급여(원)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4] as string,
qty: 12 + i * 5,
salary: 3200000 + i * 410000,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// 프리셋은 createTheme으로 만든 밝은 테마와 어두운 테마 한 쌍이에요. 사이트의 밝음·어두움 전환을 따라가요.
// 프리셋 CSS 파일(`@maxgrid/themes/preset-bootstrap.css` 등)을 쓰면 스크립트 없이 같은 모양이 돼요.
const siteMode = (): 'light' | 'dark' =>
document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore: (() => void) | undefined;
let say: (message: LogText) => void = () => {};
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset) return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
api.setSelectedKeys([2, 3]);
log({
ko: '프리셋을 고르면 이 표의 강조색, 선택 색, 모서리 둥글기, 줄 높이가 바뀌어요.',
en: 'Pick a preset to change the accent, selection, border radius and row height of this grid.',
});
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
export const actions = {
preset: (_api: GridApi<Row>, value?: string) => {
choice = value ?? 'default';
show();
say(
choice === 'default'
? { ko: '기본 테마로 돌아왔어요', en: 'Back to the default theme' }
: { ko: `프리셋: ${choice}`, en: `Preset: ${choice}` },
);
},
}; 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/vue @maxgrid/themes/presets @maxgrid/themes로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<select
aria-label="프리셋"
:disabled="!api"
@change="api && actions.preset(api, ($event.target as HTMLSelectElement).value)"
>
<option value="default" selected>기본</option>
<option value="bootstrap">부트스트랩</option>
<option value="tailwind">테일윈드</option>
<option value="material">머티리얼</option>
</select>
</div>
<Grid style="height: 360px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
import { applyTheme } from '@maxgrid/themes';
import { presets } from '@maxgrid/themes/presets';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
dept: string;
qty: number;
salary: number;
}
const names = ['김하늘', '이도윤', '박서연', '최지우', '정민준', '강서준', '윤하은', '임지호'];
const depts = ['개발', '디자인', '영업', '인사'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 150, sortable: true },
{ id: 'dept', title: '부서', width: 120, sortable: true },
{ id: 'qty', title: '주문 수', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: '월 급여(원)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4] as string,
qty: 12 + i * 5,
salary: 3200000 + i * 410000,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// 프리셋은 createTheme으로 만든 밝은 테마와 어두운 테마 한 쌍이에요. 사이트의 밝음·어두움 전환을 따라가요.
// 프리셋 CSS 파일(`@maxgrid/themes/preset-bootstrap.css` 등)을 쓰면 스크립트 없이 같은 모양이 돼요.
const siteMode = (): 'light' | 'dark' =>
document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore: (() => void) | undefined;
let say: (message: LogText) => void = () => {};
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset) return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
api.setSelectedKeys([2, 3]);
log({
ko: '프리셋을 고르면 이 표의 강조색, 선택 색, 모서리 둥글기, 줄 높이가 바뀌어요.',
en: 'Pick a preset to change the accent, selection, border radius and row height of this grid.',
});
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
export const actions = {
preset: (_api: GridApi<Row>, value?: string) => {
choice = value ?? 'default';
show();
say(
choice === 'default'
? { ko: '기본 테마로 돌아왔어요', en: 'Back to the default theme' }
: { ko: `프리셋: ${choice}`, en: `Preset: ${choice}` },
);
},
}; 이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i @maxgrid/angular @maxgrid/themes/presets @maxgrid/themes로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="프리셋"
[disabled]="!api"
(change)="api && actions.preset(api, $any($event.target).value)"
>
<option value="default" selected>기본</option>
<option value="bootstrap">부트스트랩</option>
<option value="tailwind">테일윈드</option>
<option value="material">머티리얼</option>
</select>
</div>
<mx-grid style="height: 360px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
import { applyTheme } from '@maxgrid/themes';
import { presets } from '@maxgrid/themes/presets';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
dept: string;
qty: number;
salary: number;
}
const names = ['김하늘', '이도윤', '박서연', '최지우', '정민준', '강서준', '윤하은', '임지호'];
const depts = ['개발', '디자인', '영업', '인사'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 150, sortable: true },
{ id: 'dept', title: '부서', width: 120, sortable: true },
{ id: 'qty', title: '주문 수', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: '월 급여(원)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4] as string,
qty: 12 + i * 5,
salary: 3200000 + i * 410000,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// 프리셋은 createTheme으로 만든 밝은 테마와 어두운 테마 한 쌍이에요. 사이트의 밝음·어두움 전환을 따라가요.
// 프리셋 CSS 파일(`@maxgrid/themes/preset-bootstrap.css` 등)을 쓰면 스크립트 없이 같은 모양이 돼요.
const siteMode = (): 'light' | 'dark' =>
document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore: (() => void) | undefined;
let say: (message: LogText) => void = () => {};
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset) return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
api.setSelectedKeys([2, 3]);
log({
ko: '프리셋을 고르면 이 표의 강조색, 선택 색, 모서리 둥글기, 줄 높이가 바뀌어요.',
en: 'Pick a preset to change the accent, selection, border radius and row height of this grid.',
});
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
export const actions = {
preset: (_api: GridApi<Row>, value?: string) => {
choice = value ?? 'default';
show();
say(
choice === 'default'
? { ko: '기본 테마로 돌아왔어요', en: 'Back to the default theme' }
: { ko: `프리셋: ${choice}`, en: `Preset: ${choice}` },
);
},
}; This example needs an extra package. To run it locally, install with npm i maxgrid @maxgrid/themes/presets @maxgrid/themes.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<select aria-label="Preset" id="preset">
<option value="default" selected>Default</option>
<option value="bootstrap">Bootstrap</option>
<option value="tailwind">Tailwind</option>
<option value="material">Material</option>
</select>
</div>
<div id="grid" style="height: 360px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('preset').addEventListener('change', (event) => actions.preset(api, event.target.value));import { applyTheme } from '@maxgrid/themes';
import { presets } from '@maxgrid/themes/presets';
const names = [
'Liam Carter',
'Emma Stone',
'Noah Brooks',
'Olivia Reed',
'Ethan Hall',
'Ava Morgan',
'Mason Gray',
'Mia Foster',
];
const depts = ['Dev', 'Design', 'Sales', 'HR'];
export const options = {
columns: [
{ id: 'name', title: 'Name', width: 150, sortable: true },
{ id: 'dept', title: 'Dept', width: 120, sortable: true },
{ id: 'qty', title: 'Orders', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: 'Monthly pay ($)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4],
qty: 12 + i * 5,
salary: 3200 + i * 410,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// A preset is a light and a dark theme made with createTheme; the grid follows the site's light/dark switch.
// The preset CSS files (`@maxgrid/themes/preset-bootstrap.css` and so on) do the same without any script.
const siteMode = () => document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore;
let say = () => { };
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset)
return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
export function setup(api, log) {
say = log;
api.setSelectedKeys([2, 3]);
log('Pick a preset to change the accent, selection, border radius and row height of this grid.');
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
export const actions = {
preset: (_api, value) => {
choice = value ?? 'default';
show();
say(choice === 'default' ? 'Back to the default theme' : `Preset: ${choice}`);
},
};This HTML also loads an extra bundle (the extra script tag above) and uses it as a global. No install is needed.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Bootstrap, Tailwind and Material look presets</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Preset" id="preset">
<option value="default" selected>Default</option>
<option value="bootstrap">Bootstrap</option>
<option value="tailwind">Tailwind</option>
<option value="material">Material</option>
</select>
</div>
<div id="grid" style="height: 360px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.themes-presets.min.js"></script>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.themes.min.js"></script>
<script>
const { applyTheme } = MaxGrid.themes;
const { presets } = MaxGridThemesPresets;
const names = [
'Liam Carter',
'Emma Stone',
'Noah Brooks',
'Olivia Reed',
'Ethan Hall',
'Ava Morgan',
'Mason Gray',
'Mia Foster',
];
const depts = ['Dev', 'Design', 'Sales', 'HR'];
const options = {
columns: [
{ id: 'name', title: 'Name', width: 150, sortable: true },
{ id: 'dept', title: 'Dept', width: 120, sortable: true },
{ id: 'qty', title: 'Orders', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: 'Monthly pay ($)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4],
qty: 12 + i * 5,
salary: 3200 + i * 410,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// A preset is a light and a dark theme made with createTheme; the grid follows the site's light/dark switch.
// The preset CSS files (`@maxgrid/themes/preset-bootstrap.css` and so on) do the same without any script.
const siteMode = () => document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore;
let say = () => { };
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset)
return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
function setup(api, log) {
say = log;
api.setSelectedKeys([2, 3]);
log('Pick a preset to change the accent, selection, border radius and row height of this grid.');
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
const actions = {
preset: (_api, value) => {
choice = value ?? 'default';
show();
say(choice === 'default' ? 'Back to the default theme' : `Preset: ${choice}`);
},
};
options.ariaLabel = "Bootstrap, Tailwind and Material look presets";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('preset').addEventListener('change', (event) => actions.preset(api, event.target.value));
</script>
</body>
</html> This example needs an extra package. To run it locally, install with npm i @maxgrid/react @maxgrid/themes/presets @maxgrid/themes.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<select
aria-label="Preset"
disabled={!api}
onChange={(event) => api && actions.preset(api, event.target.value)}
>
<option value="default">Default</option>
<option value="bootstrap">Bootstrap</option>
<option value="tailwind">Tailwind</option>
<option value="material">Material</option>
</select>
</div>
<Grid style={{ height: 360 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
import { applyTheme } from '@maxgrid/themes';
import { presets } from '@maxgrid/themes/presets';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
dept: string;
qty: number;
salary: number;
}
const names = [
'Liam Carter',
'Emma Stone',
'Noah Brooks',
'Olivia Reed',
'Ethan Hall',
'Ava Morgan',
'Mason Gray',
'Mia Foster',
];
const depts = ['Dev', 'Design', 'Sales', 'HR'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 150, sortable: true },
{ id: 'dept', title: 'Dept', width: 120, sortable: true },
{ id: 'qty', title: 'Orders', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: 'Monthly pay ($)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4] as string,
qty: 12 + i * 5,
salary: 3200 + i * 410,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// A preset is a light and a dark theme made with createTheme; the grid follows the site's light/dark switch.
// The preset CSS files (`@maxgrid/themes/preset-bootstrap.css` and so on) do the same without any script.
const siteMode = (): 'light' | 'dark' =>
document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore: (() => void) | undefined;
let say: (message: LogText) => void = () => {};
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset) return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
api.setSelectedKeys([2, 3]);
log('Pick a preset to change the accent, selection, border radius and row height of this grid.');
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
export const actions = {
preset: (_api: GridApi<Row>, value?: string) => {
choice = value ?? 'default';
show();
say(choice === 'default' ? 'Back to the default theme' : `Preset: ${choice}`);
},
}; This example needs an extra package. To run it locally, install with npm i @maxgrid/vue @maxgrid/themes/presets @maxgrid/themes.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<select
aria-label="Preset"
:disabled="!api"
@change="api && actions.preset(api, ($event.target as HTMLSelectElement).value)"
>
<option value="default" selected>Default</option>
<option value="bootstrap">Bootstrap</option>
<option value="tailwind">Tailwind</option>
<option value="material">Material</option>
</select>
</div>
<Grid style="height: 360px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
import { applyTheme } from '@maxgrid/themes';
import { presets } from '@maxgrid/themes/presets';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
dept: string;
qty: number;
salary: number;
}
const names = [
'Liam Carter',
'Emma Stone',
'Noah Brooks',
'Olivia Reed',
'Ethan Hall',
'Ava Morgan',
'Mason Gray',
'Mia Foster',
];
const depts = ['Dev', 'Design', 'Sales', 'HR'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 150, sortable: true },
{ id: 'dept', title: 'Dept', width: 120, sortable: true },
{ id: 'qty', title: 'Orders', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: 'Monthly pay ($)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4] as string,
qty: 12 + i * 5,
salary: 3200 + i * 410,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// A preset is a light and a dark theme made with createTheme; the grid follows the site's light/dark switch.
// The preset CSS files (`@maxgrid/themes/preset-bootstrap.css` and so on) do the same without any script.
const siteMode = (): 'light' | 'dark' =>
document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore: (() => void) | undefined;
let say: (message: LogText) => void = () => {};
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset) return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
api.setSelectedKeys([2, 3]);
log('Pick a preset to change the accent, selection, border radius and row height of this grid.');
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
export const actions = {
preset: (_api: GridApi<Row>, value?: string) => {
choice = value ?? 'default';
show();
say(choice === 'default' ? 'Back to the default theme' : `Preset: ${choice}`);
},
}; This example needs an extra package. To run it locally, install with npm i @maxgrid/angular @maxgrid/themes/presets @maxgrid/themes.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="Preset"
[disabled]="!api"
(change)="api && actions.preset(api, $any($event.target).value)"
>
<option value="default" selected>Default</option>
<option value="bootstrap">Bootstrap</option>
<option value="tailwind">Tailwind</option>
<option value="material">Material</option>
</select>
</div>
<mx-grid style="height: 360px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
import { applyTheme } from '@maxgrid/themes';
import { presets } from '@maxgrid/themes/presets';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
name: string;
dept: string;
qty: number;
salary: number;
}
const names = [
'Liam Carter',
'Emma Stone',
'Noah Brooks',
'Olivia Reed',
'Ethan Hall',
'Ava Morgan',
'Mason Gray',
'Mia Foster',
];
const depts = ['Dev', 'Design', 'Sales', 'HR'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 150, sortable: true },
{ id: 'dept', title: 'Dept', width: 120, sortable: true },
{ id: 'qty', title: 'Orders', kind: 'number', width: 100, align: 'end', sortable: true },
{ id: 'salary', title: 'Monthly pay ($)', kind: 'number', width: 140, align: 'end' },
],
rows: names.map((name, i) => ({
id: i + 1,
name,
dept: depts[i % 4] as string,
qty: 12 + i * 5,
salary: 3200 + i * 410,
})),
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
};
// A preset is a light and a dark theme made with createTheme; the grid follows the site's light/dark switch.
// The preset CSS files (`@maxgrid/themes/preset-bootstrap.css` and so on) do the same without any script.
const siteMode = (): 'light' | 'dark' =>
document.documentElement.dataset.mxgTheme === 'dark' ? 'dark' : 'light';
let choice = 'default';
let restore: (() => void) | undefined;
let say: (message: LogText) => void = () => {};
function show() {
restore?.();
restore = undefined;
const root = document.querySelector('.mxg');
const preset = presets.find((p) => p.name === choice);
if (!root || !preset) return;
restore = applyTheme(root, siteMode() === 'dark' ? preset.dark : preset.light);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
api.setSelectedKeys([2, 3]);
log('Pick a preset to change the accent, selection, border radius and row height of this grid.');
const watcher = new MutationObserver(show);
watcher.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-mxg-theme'],
});
return () => {
watcher.disconnect();
restore?.();
};
}
export const actions = {
preset: (_api: GridApi<Row>, value?: string) => {
choice = value ?? 'default';
show();
say(choice === 'default' ? 'Back to the default theme' : `Preset: ${choice}`);
},
};