Skip to content

armgit / ui

Public Imported from GitHub
0
TypeScript
2.6 KB
Raw Blame
---
title: Layout Blocks
description: Inspect layout text blocks, lines, words, and confidence overlays on top of PDF pages.
component: true
---

Layout Blocks help users debug and review the text layer behind scanned or image-heavy PDFs. They should show document structure without replacing the original page image.

The [PDF Layout Blocks](/blocks#layout-blocks) and [DOCX Layout Blocks](/blocks#docx-layout-blocks) previews share the same panel, cards, and type badges.

<OcrBlocksDemo />

## Installation

<CodeTabs>

<TabsList>
  <TabsTrigger value="cli">Command</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

```bash
npx shadcn@latest add @extend/layout-blocks
```

</TabsContent>

<TabsContent value="manual">

<Steps className="mb-0 pt-2">

<Step>Install the following dependencies:</Step>

```bash
npm install @tanstack/react-virtual@^3.13.26 react-markdown@^10.1.0 rehype-raw@^7.0.0 rehype-sanitize@^6.0.0 remark-gfm@^4.0.1
```

<Step>Install the icon library configured in your `components.json`:</Step>

The component source references icons through the shadcn CLI's
`IconPlaceholder`, which supports every `iconLibrary` the CLI does: `lucide`,
`tabler`, `hugeicons`, `phosphor`, and `remixicon`. Installing with the CLI
replaces each placeholder with the matching icon from your configured library,
so make sure that library's package is installed. When copying the source
manually, replace each `IconPlaceholder` element with the icon named by the
prop for your library.

<Step>Install the shared panel, then copy the PDF layout component.</Step>

```bash
npx shadcn@latest add @extend/layout-blocks-panel
```

<OcrBlocksSource />

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</CodeTabs>

## Useful behaviors

- Toggleable block, line, and word overlays.
- Confidence coloring for low-quality layout regions.
- Hover and selection states that reveal text and geometry.
- Region navigation from layout results to the rendered PDF page.

## API Reference

### OcrBlocksPanel

The OcrBlocksPanel component renders selectable layout results with type, markdown text, confidence, and page context.

| Prop            | Type                        | Default | Required |
| --------------- | --------------------------- | ------- | -------- |
| `activeBlockId` | `string`                    | `-`     | No       |
| `blocks`        | `OcrBlock[]`                | `-`     | Yes      |
| `className`     | `string`                    | `-`     | No       |
| `onBlockFocus`  | `(block: OcrBlock) => void` | `-`     | No       |