@gridui/grid

中文文档
2.3.0发布于 2026/11/01UNLICENSEDTypeScriptES Module

GridUI React grid

原始使用文档

Grid foundation

See the usage handbook and Grid contract for practical usage.

@gridui/grid owns Container, Grid, GridItem, Split, Stack, Row, PageFrame, FrameSections, FrameSection, frame chrome, rails, textures, FrameRegion/FrameRegionRow for composed edge geometry, and the public FrameBoundary primitive for structural boundaries. It does not know website routes or domain state. Load its explicit styles.css export after Theme and before styles of composed families. Theme supplies token values; @gridui/style-utils/responsive supplies the React-free spacing and breakpoint-value calculations.

Use Grid for two-dimensional tracks and Split for a linear, non-wrapping sequence of regions. Split's direction and seam accept scalar or responsive values; it owns only the seam between direct child regions. Put functional controls and tables inside those regions so their own borders remain intact. See linear regions for the full contract.

FrameSection and FrameFooter accept tone="neutral" | "brand" | "warning" | "danger". Non-neutral tones reuse Theme's public paletteClass contract for background, foreground, muted text, borders, controls, and focus colors. Theme owns both palette values and their scoped semantic mapping; Grid owns region geometry. Nested non-neutral tones establish their own palette; tone="neutral" continues to inherit its surroundings. Use paletteClass("neutral") from @gridui/theme on a native content surface for an explicit reset to registered application neutral colors without adding a section or boundary.

FrameSection owns its leading separator and inline frame edges. Use boundary="none" and edges="none" when an enclosing region owns them. Both FrameSection and FrameFooter accept these leading boundary styles:

boundaryAppearance
line (default)One thin rule
bandTheme-tinted 12px band with top and bottom rules
stripeThe same band geometry with continuous 135-degree brand-colored stripes
spaceTransparent 40px spacing with no rules or fill
noneNo boundary element or extra spacing

--gridui-band-size owns band and stripe height; --gridui-boundary-space-size owns whitespace height. Stripe and space default to no edge decoration. Band still defaults to nodes. Set decoration explicitly to choose an edge treatment.

<FrameSection boundary="stripe">Next chapter</FrameSection>
<FrameSection boundary="space">Related reading</FrameSection>

At a section seam, a non-neutral tone takes precedence over neutral; between two non-neutral tones, the lower section supplies the color. The lower section still draws the only separator. This works across React section groups without changing either region's content palette. Astro host elements require an application-owned adapter. The page filler uses the final section's tone for its leading line. Grid frame="cells" owns outer and cell edges; frame="internal" owns seams inside an existing frame. Use fillLastRow with direct GridItem children to fill incomplete rows at every breakpoint. Explicit gaps are disallowed in framed grids. For wrapping lists with a container-driven track count, use columns="auto" with minItemWidth and optional responsive gap. The minimum is capped to available space. Grid asChild and GridItem asChild preserve native ul/ol/li hosts without wrapper elements. Adaptive mode excludes frames and fillLastRow; root asChild also excludes fillLastRow, preserving the fixed planner's direct-item contract. Hover/focus outlines paint above neighboring seams and page lines. Table cell lines belong to Table; functional control borders belong to their Core families.

See the Grid contract for geometry and API.

Source organization

The package root src/index.ts declares the public API, and src/styles.css imports component styles. Neither entry point contains component implementation.

Every public component owns a matching directory, such as src/grid/, src/grid-item/, src/split/, and src/frame-section/. Private parts, styles, and helpers stay beside their owner. src/shared/ contains only collaborators used by multiple components: track planning, inherited frame geometry, region tones, and shared boundary/chrome rules. Responsive spacing comes from Style-utils.

Cross-package browser fixtures live in root scripts/development/preview/fixtures and use public exports. Browser specifications live separately in scripts/testing/browser/specs.

Unit tests mirror these owners under test/unit/primitives/ and test/unit/frame/. Tests can combine public primitives to protect their collaboration. Keep ordinary presentation in the owner's CVA style.ts. Retain track resolution, seams, and decorative geometry in colocated CSS imported by the root stylesheet. See the source conventions. Consumers use the package root and explicit stylesheet export; internal file paths are private.

See quarterly release history for prepared release notes and consumption records.

DashboardFrame supplies full-height workspace gutters and structural edges without creating a main landmark. See dashboard frames.

版本与发布记录

@gridui/grid 共发布 12 个版本,首次发布于 2026/10/22;过去 12 个月发布了 12 个版本。

版本发布日期距今
2.3.0latest2026/11/012 天前
2.2.12026/11/012 天前
2.1.42026/10/313 天前
2.1.32026/10/295 天前
2.1.22026/10/295 天前
2.1.12026/10/277 天前

关于 @gridui/grid 的常见问题

@gridui/grid 是什么?

GridUI React网格

如何安装 @gridui/grid?

在项目目录运行 npm install @gridui/grid,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gridui/grid 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gridui/grid 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@gridui/grid 可以商用吗?

@gridui/grid 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@gridui/grid 还在维护吗?

最新版本 2.3.0 发布于 2026/11/01(2 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/10/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。