@gravity-ui/react-unipika

中文文档
0.8.1发布于 2026/07/04MITTypeScriptESM + CJS零依赖近 30 天下载 4894

The library helps to create dialogs with forms by using registered field-types. Also it is possible to extend it with your own field-types.

原始使用文档
文档目录10 节
  1. Short description
  2. Features
  3. Install
  4. Usage
  5. Window Scroll (default)
  6. Container Scroll
  7. YSON notice
  8. Props
  9. ReactUnipika Component Props
  10. UnipikaSettings

Short description

The purpose of @gravity-ui/react-unipika is visualizing of JSON and YSON data objects. The library uses @gravity-ui/unipika and @gravity-ui/table internally.

Features

  • virtualization
  • two scroll modes: window scroll and container scroll
  • collapse/expand objects/arrays
  • search substring of key/value (case-sensitive and case-insensitive)
  • render one literal per line
    • long strings are truncated by ellipsis
      • full value might be seen in dialog

Install

$ npm install @gravity-ui/react-unipika

Depending on your package manager you may need to install peerDependencies manually.

Usage

The library provides two entry points depending on your scrolling needs:

Window Scroll (default)

Use this when you want the component to scroll with the browser window:

import '@gravity-ui/uikit/styles/styles.scss';
import '@gravity-ui/unipika/styles/unipika.scss';

import {ReactUnipika} from '@gravity-ui/react-unipika/window-scroll';

function renderJson(data: any) {
  return <ReactUnipika value={data} />;
}

Container Scroll

Use this when you want the component to scroll within a specific container. You must provide a ref to the scroll container:

import '@gravity-ui/uikit/styles/styles.scss';
import '@gravity-ui/unipika/styles/unipika.scss';

import {ReactUnipika} from '@gravity-ui/react-unipika/container-scroll';

function renderJson(data: any) {
  const scrollContainerRef = React.useRef<HTMLDivElement>(null);

  return (
    <div ref={scrollContainerRef} style={{height: '500px', overflow: 'auto'}}>
      <ReactUnipika value={data} scrollContainerRef={scrollContainerRef} />
    </div>
  );
}

YSON notice

The library does not support YSON-format "as is", i.e. it is impossible to use/parse YSON data. But it provides the way to render JSON-objects as YSON, such JSON-objects has reserved field names like $attributes, $value.

See more examples in storybook.

Props

ReactUnipika Component Props

PropTypeDefaultDescription
valueanyrequiredThe data to be rendered
settingsUnipikaSettingsSee belowSettings for Unipika formatting
inlinebooleanfalseRender in inline mode
childrenReact.ReactNode-React nodes to render as children
extraToolsReact.ReactNode-Additional React nodes for tools
virtualizedbooleantrueEnable virtualization for better performance with large data
classNamestring-Custom CSS class name
customLayout(args: {toolbar: React.ReactNode; content: React.ReactNode}) => React.ReactNode-Function to customize the layout
toolbarStickyTopnumber0Top position in pixels for sticky toolbar
renderToolbar(props: ToolbarProps) => React.ReactNode-Custom toolbar renderer function
collapseIconTypeCollapseIconType-Type of collapse/expand icon to use
showContainerSizeboolean-Show the size of containers (objects/arrays)
initiallyCollapsedboolean-Whether to render the tree initially collapsed
caseInsensitiveSearchboolean-Enable case-insensitive search
renderError(error: unknown) => React.ReactNode-Custom error renderer function
renderRowExtraTools(params: RenderRowExtraToolsParams) => React.ReactNode-Render custom tools for each row
scrollContainerRefReact.RefObject<Element | null>-Required for container-scroll only. Reference to the scroll container element

UnipikaSettings

SettingTypeDefaultDescription
asHTMLbooleantrueRender as HTML
formatstring'json'Format type ('json', 'yson', 'raw-json')
compactbooleanfalseUse compact rendering
escapeWhitespacebooleantrueEscape whitespace characters
showDecodedbooleantrueShow decoded values
binaryAsHexbooleantrueDisplay binary data as hexadecimal
nonBreakingIndentboolean-Use non-breaking spaces for indentation
escapeYQLStringsboolean-Escape YQL strings
decodeUTF8boolean-Decode UTF-8 encoded strings
indentnumber-Indentation size
breakboolean-Add line breaks
maxListSizenumber-Maximum number of items to display in a list
maxStringSizenumber-Maximum string length to display before truncating
omitStructNullboolean-Omit null values in structures
treatValAsDataboolean-Treat values as data

版本与发布记录

@gravity-ui/react-unipika 共发布 17 个版本,首次发布于 2025/05/12;过去 12 个月发布了 11 个版本。

版本发布日期距今
0.8.1latest2026/07/044 个月前
0.8.02026/07/024 个月前
0.7.12026/06/095 个月前
0.7.02026/05/295 个月前
0.6.42026/05/225 个月前
0.6.32026/05/146 个月前

关于 @gravity-ui/react-unipika 的常见问题

@gravity-ui/react-unipika 是什么?

The library helps to create dialogs with forms by using registered field-types. Also it is possible to extend it with your own field-types.

如何安装 @gravity-ui/react-unipika?

在项目目录运行 npm install @gravity-ui/react-unipika,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@bem-react/classname(^1.6.0)、@gravity-ui/i18n(^1.0.0)、@gravity-ui/icons(^2.0.0)、@gravity-ui/table(^1.10.1)、@gravity-ui/uikit(^7.1.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gravity-ui/react-unipika 支持 TypeScript 吗?

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

@gravity-ui/react-unipika 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gravity-ui/react-unipika 可以商用吗?

@gravity-ui/react-unipika 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gravity-ui/react-unipika 的下载量有多少?

根据 npm 官方下载统计,@gravity-ui/react-unipika 在 2026/10/17 – 2026/11/15 这 30 天内被下载 4,894 次,日均约 163 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gravity-ui/react-unipika 还在维护吗?

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