fat-design
v0.1.7
Published
A React component library for admin applications, data-intensive dashboards, and configuration-driven interfaces. It combines everyday UI components with schema-driven forms, query forms, and advanced data tables.
Readme
fat-design
A React component library for admin applications, data-intensive dashboards, and configuration-driven interfaces. It combines everyday UI components with schema-driven forms, query forms, and advanced data tables.
Documentation · Interactive demos · npm · Repository
Features
- Forms and filters: schema-driven fields, validation, conditional visibility, field dependencies, and asynchronous options.
- Data tables:
Table,TablePro, andEditableTablefor list pages, filtering, pagination, row selection, and inline editing. - Application UI: dialogs, drawers, notifications, navigation, trees, date pickers, uploads, and image previews.
- Layout and interaction: responsive layout components, virtual lists, and sortable lists.
- Developer experience: TypeScript declarations, live examples with source code, and ESM and UMD distributions.
Requirements
| Dependency | Supported versions | | --- | --- | | React | 16.8, 17, and 18 | | ReactDOM | The same major version as React |
React and ReactDOM are provided by the host application. React versions below 16.8 and React 19 are not supported.
Initialize the ReactDOM adapter once at application startup. Imperative APIs such as Message, Notification, and Dialog use this adapter to render outside the main application root.
Installation
For a React 18 application:
npm install fat-design react@18 react-dom@18If React is already installed, keep its supported version and install the component library:
npm install fat-designQuick start
React 18
import React from 'react';
import * as ReactDOM from 'react-dom';
import * as ReactDOMClient from 'react-dom/client';
import { Button, Message, configReactDOM18 } from 'fat-design';
import 'fat-design/style.css';
configReactDOM18(ReactDOM, ReactDOMClient);
function App() {
return (
<Button type="primary" onClick={() => Message.success('Ready to go!')}>
Show message
</Button>
);
}
const container = document.getElementById('root');
if (container) {
ReactDOMClient.createRoot(container).render(<App />);
}Pass both ReactDOM modules to configReactDOM18. Initialize the adapter before calling imperative component APIs.
React 16.8 and 17
import React from 'react';
import * as ReactDOM from 'react-dom';
import { Button, Message, configReactDOM } from 'fat-design';
import 'fat-design/style.css';
configReactDOM(ReactDOM);
ReactDOM.render(
<Button type="primary" onClick={() => Message.success('Ready to go!')}>
Show message
</Button>,
document.getElementById('root'),
);Use configReactDOM for these versions; do not import react-dom/client in a React 16 or 17 application.
Components
| Area | Components |
| --- | --- |
| Data entry | Input, Select, Checkbox, Radio, DatePicker, TimePicker, Upload |
| Forms | Form, QueryForm |
| Tables | Table, TablePro, EditableTable |
| Feedback | Message, Notification, Dialog, Drawer, Loading |
| Navigation | Menu, Nav, Tab, Breadcrumb, Pagination |
| Content and layout | Box, Grid, Card, Image, Calendar, Tree |
| Specialized interactions | BatchInput, SortableList, VirtualList |
TablePro.useTablePro coordinates query form, pagination, and table state for data-heavy pages. Form supports both schema configuration and JSX fields, including dependencies and conditional field behavior.
See the component documentation for API details and the interactive demos for runnable examples and source code.
TablePro 自动固定表头
高度行为与 Element UI 的流体高度一致:只限制最大高度,不强制填充。TablePro 在此基础上自动计算可用空间并预留分页区域。
const table = TablePro.useTablePro({
onQuery: fetchRows,
initTableProps: { primaryKey: 'id', columns },
initPaginationProps: { pageSize: 50 },
});
<TablePro {...table} autoFixedHeader autoFixedHeaderOffsetTop={72} />autoFixedHeader:默认false。开启后自动设置fixedHeader=true、maxBodyHeight,内容超过可用空间时由表体承担滚动,分页区保留在视口底部并留出 5px。数据不足以占满可用空间时按自然高度显示,分页器紧随表格,不留占位空白。autoFixedHeaderOffsetTop:窗口顶部预留高度,单位 px,默认0。页面有固定导航时设置为导航实际高度。- 表头吸顶后继续滚动页面,会继续增大
maxBodyHeight,利用底部剩余空间;当当前页全部内容已能完整展示时停止增高,允许滚动离开表格。 - 自动测量分组表头、边框、分页及选择提示的实际高度,响应窗口缩放、页面/容器滚动和周围布局变化;关闭模式后恢复原
tableProps配置。 - 开启模式时不使用
tableProps.stickyHeader,避免其传统无限高表体模式覆盖自动高度。无需自行计算maxBodyHeight。 - 表格尚未滚入窗口、窗口剩余空间不足以容纳表头和分页器时,先滚动至表格区域;不会裁掉表头或分页器。表格离开其所属区域后表头正常退出,不遮盖后续内容。
- 页面滚动模式不要在表格祖先上设置额外的
overflow: auto/hidden包装;它会成为 CSS sticky 的滚动容器。需要容器滚动时,为该容器设置明确的高度,组件会在容器可见范围内布局。 - 交互实验,源码:
demo/demo-table-pro-auto-header.tsx。
Styles and themes
Load the base stylesheet once:
import 'fat-design/style.css';To customize the palette, load a theme after the base stylesheet:
import 'fat-design/style.css';
import 'fat-design/libs/theme/theme-green.css';The package includes blue, green, orange, pink, purple, and red theme stylesheets under libs/theme/. Choose one palette for your application.
Script-tag usage
The UMD build exposes window.FatDesign. Host the package assets on your own server or CDN, then load React, ReactDOM, the stylesheet, and index.umd.js before your application script.
With the React 18 UMD builds loaded:
<link rel="stylesheet" href="/vendor/fat-design/style.css" />
<script src="/vendor/fat-design/index.umd.js"></script>
<script>
FatDesign.configReactDOM18(ReactDOM, ReactDOM);
ReactDOM.createRoot(document.getElementById('root')).render(
React.createElement(FatDesign.Button, {
type: 'primary',
onClick: function () {
FatDesign.Message.success('Ready to go!');
}
}, 'Show message')
);
</script>The /vendor/ paths are placeholders for your hosted assets. Use a regular script tag for the UMD build, not type="module". Dynamically loaded applications must share the same React instance as their host.
Local development
Install dependencies and start the demo application:
pnpm install
npm run devUse the development URL printed by Vite.
| Command | Purpose |
| --- | --- |
| npm run dev | Start the local demo application |
| npm run build | Build the npm distribution with a beta version |
| npm run build:prod | Build the npm distribution using the package version |
| npm run build:demo | Build the standalone demo site |
| npm run buildDeployRelease | Build, upload, and publish the demo site using configured deployment access |
Library builds write to dist/, including JavaScript, CSS, type declarations, and this README. The standalone demo writes to demo-dist/; its deployment does not publish the npm package.
