Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

Trellis

Trellis is a layout engine for web apps where users arrange their own workspace. Panels nest inside panels as deep as users like, and the view zooms to whichever part they need, with every view kept mounted. Users can also drag, split, float and hide tabbed panels.

See the idea in the 2-minute video that started the project.

Packages

Package
@danfessler/trellisThe framework-agnostic core: model, runtime and styles.
@danfessler/trellis-reactReact components and hooks.
@danfessler/trellis-element<trellis-workspace> custom element, including a standalone script build.

Quick start (React)

Install the core and the React adapter:

npm install @danfessler/trellis @danfessler/trellis-react

Declare the view types, then the initial layout:

import { Workspace, ViewType, Split, Stage, Panel, View, useView } from "@danfessler/trellis-react";
import "@danfessler/trellis/style.css";

function Document() {
  const view = useView<{ file: string }>();
  return <Canvas file={view.params.file} />;
}

export function App() {
  return (
    <Workspace theme="dark" storageKey="my-app" version={1}>
      <ViewType id="document" title={(v) => String(v.params.file)} placement="stage" allow={{ side: false }}>
        <Document />
      </ViewType>
      <ViewType id="layers" title="Layers" singleton allow={{ stage: false }}>
        <Layers />
      </ViewType>

      <Split weights={[4, 1]}>
        <Stage empty={<OpenFilePrompt />}>
          <Panel>
            <View type="document" params={{ file: "cover.psd" }} />
          </Panel>
        </Stage>
        <View type="layers" />
      </Split>
    </Workspace>
  );
}

Quick start (vanilla)

Install the core:

npm install @danfessler/trellis

Create a workspace in an element:

import { createWorkspace, layout as L } from "@danfessler/trellis";
import "@danfessler/trellis/style.css";

const ws = createWorkspace(document.getElementById("app")!, {
  types: {
    notes: { title: "Notes", mount: (el) => void (el.innerHTML = "<textarea></textarea>") },
    docs: { title: "Docs", iframe: "https://example.com" },
  },
  defaultLayout: L.row([L.view("notes"), L.stage(L.panel(L.view("docs")))], [1, 3]),
});

ws.open("notes", { placement: "float" });

Documentation

Development

npm install
npm run dev          # website and docs at http://localhost:5320
npm test             # unit tests (Vitest)
npm run test:e2e     # browser tests (Playwright: Chromium and Firefox; WebKit in CI)
npm run typecheck
npm run build        # the three packages
npm run build:all    # packages + website with examples (site/dist)
npm run verify:pack  # pack tarballs and build a fresh app against React 18 and 19

The examples live in examples/:

ExampleShowsRun
paintAn art program: documents on the stage, tool palettes, floating navigator, close guards, persistencenpm run dev -w trellis-example-paint
ideAn editor with explorer, terminal, live-preview iframe, command palette and status barnpm run dev -w trellis-example-ide
desktopA desktop environment built from public primitives, with stage floats, free zoom, a dock and a minimapnpm run dev -w trellis-example-desktop
vanillaA framework-free ops dashboard, plus a <trellis-workspace> page declared in HTMLnpm run dev -w trellis-example-vanilla

License

Trellis is free for non-commercial use. Commercial use requires an active GitHub Sponsorship at the applicable tier (organizations of 10 or fewer developers), and larger organizations need an enterprise license. See LICENSE.md.

关于 About

Fractal layouts for web apps: nest panels to any depth, zoom to the part you need, and keep every view alive.

语言 Languages

TypeScript81.5%
CSS15.0%
JavaScript3.0%
HTML0.5%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
51
Total Commits
峰值: 51次/周
Less
More

核心贡献者 Contributors