본문으로 건너뛰기Skip to content
예제 첫화면Examples home

부트스트랩·테일윈드·머티리얼 모양 테마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.

입문Beginner
직접 써 보기Live preview부트스트랩·테일윈드·머티리얼 모양 테마Bootstrap, Tailwind and Material look presets

코드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)

빌드 도구(Vite 등)를 쓰는 프로젝트용 모듈 파일이에요. 설치 없이 바로 돌려 보려면 HTML 탭이나 직접 해보기를 쓰세요.

이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/themes/presets @maxgrid/themes로 설치하세요.

버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.

index.html
<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>
main.js
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));
example.js
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}` });
  },
};

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

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.

index.html
<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>
main.js
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));
example.js
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}`);
  },
};