Skip to content

armgit / ui

Public Imported from GitHub
0
TypeScript
2.0 KB
Raw Blame
---
title: Document Viewer Sidebar
description: Shared responsive thumbnail sidebar behavior for PDF, DOCX, and other document viewers.
component: true
---

Document Viewer Sidebar provides the responsive shell used by document viewers to show thumbnail navigation inline on wider layouts and as an overlay on narrower layouts.

<DocumentViewerSidebarDemo />

## Installation

<CodeTabs>

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

```bash
npx shadcn@latest add @extend/document-viewer-sidebar
```

</TabsContent>

<TabsContent value="manual">

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

<Step>
  Copy `components/extend/document-viewer-sidebar.tsx` from the registry item
  into your project.
</Step>

<DocumentViewerSidebarSource />

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

</Steps>

</TabsContent>

</CodeTabs>

## API Reference

### DocumentViewerThumbnailSidebar

The DocumentViewerThumbnailSidebar component renders a responsive sidebar container for document thumbnails.

| Prop        | Type              | Default | Required |
| ----------- | ----------------- | ------- | -------- |
| `children`  | `React.ReactNode` | `-`     | Yes      |
| `className` | `string`          | `-`     | No       |
| `inline`    | `boolean`         | `-`     | Yes      |
| `open`      | `boolean`         | `-`     | Yes      |

### DocumentViewerSidebarSkeleton

The DocumentViewerSidebarSkeleton component renders the sidebar loading state used while document thumbnails are not ready.

| Prop     | Type      | Default | Required |
| -------- | --------- | ------- | -------- |
| `inline` | `boolean` | `-`     | Yes      |

### useElementWidth

The useElementWidth hook returns a ref and measured width for responsive viewer layout decisions.

### useInlineThumbnailSidebar

The useInlineThumbnailSidebar hook returns whether the sidebar should render inline for a measured viewer width.