Calm motion: animations on this site only fade, with no movement
Spreadsheet
A grid of cells that you edit with the keyboard and paste into
Lets people type or paste rows of plain data, as in a spreadsheet app. For example, a list of episodes with their plays. It has no formulas: your code reads the cells and does the math. To show data with sort and filter, use the data table.
Basic
| Episode | Title | Plays | Minutes | |
|---|---|---|---|---|
| 1 | Ep. 41 | Home studio | 1240 | 38 |
| 2 | Ep. 40 | Guest: Budi | 1105 | 41 |
| 3 | Ep. 39 | Mic test | 980 | 29 |
| 4 | Ep. 38 | Listener Q&A | 1310 | 45 |
Total plays: 4635
v-modelis the cells, row by row, as text.columnsnames the columns. With no names, the columns are A, B, C, and so on.min-columnssets the number of columns of an empty sheet.- The arrow keys move the active cell. Shift and an arrow key make a selection. Home and End go to the start and the end of the row. With Ctrl or ⌘, they go to the first and the last cell.
- To edit a cell, start to type, or press Enter or F2, or double-click it. In the edit, Enter saves and goes down, Tab saves and goes right, and Escape cancels. Enter on the last row adds a new row.
- Delete or Backspace clears the selected cells.
- Copy gives the selection as text with tabs, so a spreadsheet app can read it. Paste writes the cells from the active cell. If the sheet is too short, paste adds rows at the end. Cut copies and clears.
- A cell that holds a number aligns to the end. Set the width of a column with the
--bless-spreadsheet-columnCSS variable (default7.5rem). readonlykeeps the moves, the selection, and copy, but stops all changes.- The sheet is a
gridfor screen readers, with one tab stop.labelnames the grid.
Usage
ts
import { BlessSpreadsheet } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
columns | string[] | — | the names over the columns; default: A, B, C … |
minColumns | number | 0 | at least this many columns, for an empty sheet |
readonly | boolean | — | |
label | string | "Spreadsheet" | names the grid for screen readers |
modelValue | string[][] | [] | the cells, row by row, as text |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: string[][]] |