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

셀에 마우스를 올리면 말풍선Tooltips on cells

컬럼에서 말풍선을 켜면 셀에 마우스를 올릴 때(터치는 누를 때) 설명이 떠요. '켬'은 보이는 글자 전체를 보여 줘서 잘린 글을 읽을 수 있고, 행마다 다른 설명을 달 수도 있어요.Turn on a column's tooltip and a bubble appears on hover (or press on touch). Plain on shows the full cell text for cut-off values, and each row can have its own text.

입문Beginner
직접 써 보기Live preview셀에 마우스를 올리면 말풍선Tooltips on cells

코드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: 200px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { options } from './example';
const api = createGrid(document.getElementById('grid'), options);
example.js
// tooltip: true면 셀에 보이는 글자를 그대로 말풍선으로 보여 줘요. 칸이 좁아 글자가 잘려도 마우스를 올리면 끝까지 읽혀요.
// 함수를 주면 행마다 다른 설명을 달 수 있어요(undefined를 돌려주면 그 셀은 말풍선이 없어요).
export const options = {
  tooltipDelay: 150,
  columns: [
    { id: 'id', title: '번호', width: 70, align: 'end' },
    { id: 'product', title: '품명', width: 140 },
    { id: 'description', title: '설명 (올려 보세요)', width: 200, tooltip: true },
    {
      id: 'stock',
      title: '재고',
      kind: 'number',
      width: 90,
      align: 'end',
      tooltip: (row) => row.stock < 20 ? `안전 재고(20개)보다 ${20 - row.stock}개 부족해요` : undefined,
    },
  ],
  rows: [
    {
      id: 1,
      product: '핸드 파레트 트럭',
      description: '수동 유압식 2.5톤, 포크 길이 1,150mm, 바퀴 폴리우레탄',
      stock: 14,
    },
    {
      id: 2,
      product: '라벨 프린터',
      description: '4인치 배송 라벨용 열전사 프린터, USB와 랜 연결 지원',
      stock: 6,
    },
    {
      id: 3,
      product: '스트레치 필름',
      description: '투명 스트레치 필름 500mm x 300m, 17미크론, 6롤 1박스',
      stock: 120,
    },
    {
      id: 4,
      product: '철제 선반',
      description: '조립식 5단 선반, 한 단 하중 200kg, 폭 900mm',
      stock: 31,
    },
  ],
  rowKey: 'id',
};

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: 200px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { options } from './example';
const api = createGrid(document.getElementById('grid'), options);
example.js
// tooltip: true shows the text visible in the cell as a bubble. Even if the cell is narrow and the text is cut off, hovering reads it to the end.
// A function can give each row a different note (return undefined and that cell has no bubble).
export const options = {
  tooltipDelay: 150,
  columns: [
    { id: 'id', title: 'No', width: 70, align: 'end' },
    { id: 'product', title: 'Product', width: 140 },
    { id: 'description', title: 'Description (hover)', width: 200, tooltip: true },
    {
      id: 'stock',
      title: 'Stock',
      kind: 'number',
      width: 90,
      align: 'end',
      tooltip: (row) => row.stock < 20 ? `${20 - row.stock} short of the safety stock (20 units)` : undefined,
    },
  ],
  rows: [
    {
      id: 1,
      product: 'Hand Pallet Truck',
      description: 'Manual hydraulic 2.5 t, fork length 1,150 mm, polyurethane wheels',
      stock: 14,
    },
    {
      id: 2,
      product: 'Label Printer',
      description: 'Thermal transfer printer for 4-inch shipping labels, USB and LAN support',
      stock: 6,
    },
    {
      id: 3,
      product: 'Stretch Film',
      description: 'Clear stretch film 500mm x 300m, 17 micron, 6 rolls per box',
      stock: 120,
    },
    {
      id: 4,
      product: 'Steel Shelf',
      description: 'Assembled 5-tier shelf, 200kg per tier, width 900mm',
      stock: 31,
    },
  ],
  rowKey: 'id',
};