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

좁은 화면에서는 아래 시트로A bottom sheet on narrow screens

combobox 목록은 좁은 화면이나 낮은 터치 화면에서 날짜 선택기처럼 아래에서 올라오는 시트로 열려요. 항목은 44px 이상이고 어두운 막을 누르면 목록만 닫혀요. 넓은 화면에서는 셀 아래 팝업이고 자리가 모자라면 위로 뒤집혀요.On a narrow or low touch screen the combobox list opens as a bottom sheet like the date picker. Items are at least 44px and pressing the dark backdrop closes only the list. On a wide screen it is a popup below the cell that flips above when there is no room.

활용Intermediate
직접 써 보기Live preview좁은 화면에서는 아래 시트로A bottom sheet on narrow screens

코드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 탭이나 직접 해보기를 쓰세요.

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

index.html
<div id="app">
  <div id="grid" style="height: 260px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
example.js
const COUNTRIES = [
  '대한민국',
  '일본',
  '중국',
  '미국',
  '캐나다',
  '멕시코',
  '브라질',
  '영국',
  '프랑스',
  '독일',
  '이탈리아',
  '스페인',
  '인도',
  '호주',
  '뉴질랜드',
  '베트남',
  '태국',
  '싱가포르',
].map((value) => ({ value }));
const rows = [
  { id: 1, name: '김하늘', country: '대한민국' },
  { id: 2, name: '이도윤', country: '' },
  { id: 3, name: '박서연', country: '일본' },
];
// 좁은 화면(520px 이하)이나 낮은 터치 화면에서는 목록이 아래에서 올라오는 시트로 열려요.
// 항목은 44px 이상이고, 어두운 막을 누르면 목록만 닫혀요. 데스크톱에서는 셀 아래 팝업이에요.
export const options = {
  columns: [
    { id: 'name', title: '이름', width: 110 },
    {
      id: 'country',
      title: '국가',
      width: 180,
      editable: true,
      cellEditor: 'combobox',
      editorOptions: COUNTRIES,
      editorParams: { placeholder: '국가 검색', maxHeight: 280 },
    },
  ],
  rows,
  rowKey: 'id',
};
export function setup(api, log) {
  log({
    ko: '창을 좁히거나 휴대폰에서 "국가" 칸을 두 번 눌러 보세요. 목록이 아래 시트로 열려요.',
    en: 'Narrow the window or use a phone and double-click a "국가" (country) cell. The list opens as a bottom sheet.',
  });
  const offs = [
    api.on('editCommitted', (e) => log({
      ko: `행 ${e.rowKey}: ${e.columnId} = ${String(e.newValue)}`,
      en: `Row ${e.rowKey}: ${e.columnId} = ${String(e.newValue)}`,
    })),
  ];
  return () => offs.forEach((off) => off());
}

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

When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.

index.html
<div id="app">
  <div id="grid" style="height: 260px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
example.js
const COUNTRIES = [
  'South Korea',
  'Japan',
  'China',
  'United States',
  'Canada',
  'Mexico',
  'Brazil',
  'United Kingdom',
  'France',
  'Germany',
  'Italy',
  'Spain',
  'India',
  'Australia',
  'New Zealand',
  'Vietnam',
  'Thailand',
  'Singapore',
].map((value) => ({ value }));
const rows = [
  { id: 1, name: 'Liam Carter', country: 'South Korea' },
  { id: 2, name: 'Emma Stone', country: '' },
  { id: 3, name: 'Noah Kim', country: 'Japan' },
];
// On a narrow screen (520px or less) or a low touch screen the list opens as a sheet sliding up from the bottom.
// Items are at least 44px, and pressing the dark backdrop closes only the list. On desktop it is a popup below the cell.
export const options = {
  columns: [
    { id: 'name', title: 'Name', width: 130 },
    {
      id: 'country',
      title: 'Country',
      width: 180,
      editable: true,
      cellEditor: 'combobox',
      editorOptions: COUNTRIES,
      editorParams: { placeholder: 'Search country', maxHeight: 280 },
    },
  ],
  rows,
  rowKey: 'id',
};
export function setup(api, log) {
  log('Narrow the window or use a phone and double-click a "Country" cell. The list opens as a bottom sheet.');
  const offs = [
    api.on('editCommitted', (e) => log(`Row ${e.rowKey}: ${e.columnId} = ${String(e.newValue)}`)),
  ];
  return () => offs.forEach((off) => off());
}