> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vibedoc-ai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Template System

> Customize document appearance with powerful template configuration

## Overview

VibeDoc's template system gives you complete control over document styling. Customize colors, fonts, spacing, and layout to match your brand or create distinct document types.

<img src="https://mintcdn.com/vibedoc/nyIpYqCdQSz9ZFvN/images/templates-demo.png?fit=max&auto=format&n=nyIpYqCdQSz9ZFvN&q=85&s=64101b3caf2958bdcf6441baadea9aa9" alt="Template Customization" className="rounded-lg border" data-path="images/templates-demo.png" />

## Template Components

<CardGroup cols={2}>
  <Card title="Colors" icon="palette">
    Primary, secondary, accent, and text colors
  </Card>

  <Card title="Typography" icon="font">
    Font families, sizes, weights, and line heights
  </Card>

  <Card title="Spacing" icon="ruler">
    Margins, padding, and gaps between elements
  </Card>

  <Card title="Layout" icon="table-layout">
    Headers, footers, and page dimensions
  </Card>
</CardGroup>

## Color Configuration

### Primary Colors

Define your brand colors:

```yaml theme={null}
Template Colors:
  Primary: #3B82F6 (Blue)
  Secondary: #8B5CF6 (Purple)
  Accent: #10B981 (Green)
  Text: #1F2937 (Dark Gray)
  Background: #FFFFFF (White)
```

<Tabs>
  <Tab title="Primary">
    **Primary Color** - Main brand color

    Used for:

    * Headings
    * Links
    * Buttons
    * Emphasis
  </Tab>

  <Tab title="Secondary">
    **Secondary Color** - Supporting color

    Used for:

    * Subheadings
    * Icons
    * Borders
    * Secondary CTAs
  </Tab>

  <Tab title="Accent">
    **Accent Color** - Highlight color

    Used for:

    * Callouts
    * Badges
    * Highlights
    * Special elements
  </Tab>
</Tabs>

### Color Presets

Quick-start with built-in color schemes:

<CardGroup cols={3}>
  <Card title="Blue Professional" icon="briefcase">
    Blue & Indigo - Corporate, trustworthy
  </Card>

  <Card title="Green Growth" icon="seedling">
    Green & Teal - Fresh, eco-friendly
  </Card>

  <Card title="Purple Creative" icon="wand-magic-sparkles">
    Purple & Pink - Creative, modern
  </Card>

  <Card title="Red Bold" icon="fire">
    Red & Orange - Energetic, urgent
  </Card>

  <Card title="Gray Minimal" icon="circle">
    Grayscale - Clean, minimal
  </Card>

  <Card title="Multicolor" icon="rainbow">
    Full spectrum - Playful, diverse
  </Card>
</CardGroup>

### Applying Colors

Colors automatically apply to:

* All heading blocks
* Text emphasis
* Table headers
* Callout borders
* Signature blocks
* Divider lines

<Info>
  Colors are applied consistently across preview, PDF export, and shared links for perfect brand matching.
</Info>

## Typography

### Font Families

Choose from professional font stacks:

| Font Family          | Style                | Best For      |
| -------------------- | -------------------- | ------------- |
| **Geist Sans**       | Modern sans-serif    | General use   |
| **Inter**            | Versatile sans-serif | Business docs |
| **Roboto**           | Clean geometric      | Tech docs     |
| **Merriweather**     | Classic serif        | Reports       |
| **Lora**             | Elegant serif        | Formal docs   |
| **Playfair Display** | Decorative serif     | Creative      |
| **IBM Plex Mono**    | Monospace            | Code, data    |

<Tip>
  Use sans-serif fonts for digital reading and serif fonts for printed documents.
</Tip>

### Heading Sizes

Configure all six heading levels:

```yaml theme={null}
Heading Sizes:
  H1:
    fontSize: 36px
    lineHeight: 1.2
    fontWeight: 700
  H2:
    fontSize: 28px
    lineHeight: 1.3
    fontWeight: 600
  H3:
    fontSize: 22px
    lineHeight: 1.4
    fontWeight: 600
  H4:
    fontSize: 18px
    lineHeight: 1.5
    fontWeight: 600
  H5:
    fontSize: 16px
    lineHeight: 1.5
    fontWeight: 500
  H6:
    fontSize: 14px
    lineHeight: 1.6
    fontWeight: 500
```

### Text Sizing

Control body text appearance:

<AccordionGroup>
  <Accordion title="Base Font Size">
    **Default: 16px**

    Affects all text blocks. Recommended range: 14-18px
  </Accordion>

  <Accordion title="Line Height">
    **Default: 1.6**

    Spacing between lines. Recommended: 1.4-1.8
  </Accordion>

  <Accordion title="Letter Spacing">
    **Default: 0**

    Space between characters. Recommended: -0.02em to 0.05em
  </Accordion>

  <Accordion title="Paragraph Spacing">
    **Default: 16px**

    Gap between paragraphs. Recommended: 12-24px
  </Accordion>
</AccordionGroup>

## Spacing & Layout

### Margins

Control document edges with visual cross-layout editor:

<Info>
  **Visual Editor**: VibeDoc includes an interactive cross-layout margin editor with real-time preview. See margins adjust as you type!
</Info>

```yaml theme={null}
Margins:
  Page:
    Top: 60px
    Right: 80px
    Bottom: 60px
    Left: 80px

  Blocks:
    Above: 24px
    Below: 24px
```

**Visual Features:**

* Cross-layout positioning (Top, Right, Bottom, Left inputs)
* Connecting lines to page preview
* Real-time visual feedback
* Intuitive controls with labels

### Padding

Internal spacing for elements:

```yaml theme={null}
Padding:
  Callouts: 16px
  Tables: 12px
  Signatures: 20px
```

### Grid System

Align content with an invisible grid (coming soon):

* **Columns:** 12-column system
* **Gutters:** Configurable gaps
* **Breakpoints:** Responsive sizing

## Header & Footer

### Header Configuration

Customize document headers:

<Tabs>
  <Tab title="Content">
    **Header Content:**

    * Logo image
    * Company name
    * Document title
    * Date
    * Custom text
  </Tab>

  <Tab title="Styling">
    **Header Styles:**

    * Height: 40-120px
    * Background color
    * Border (top/bottom)
    * Text alignment
    * Font size
  </Tab>

  <Tab title="Visibility">
    **Display Options:**

    * All pages
    * First page only
    * All except first
    * None
  </Tab>
</Tabs>

### Footer Configuration

Customize document footers:

<Tabs>
  <Tab title="Content">
    **Footer Content:**

    * Page numbers
    * Copyright notice
    * Contact info
    * Website URL
    * Custom text
  </Tab>

  <Tab title="Styling">
    **Footer Styles:**

    * Height: 30-80px
    * Background color
    * Border (top/bottom)
    * Text alignment
    * Font size
  </Tab>

  <Tab title="Visibility">
    **Display Options:**

    * All pages
    * All except first
    * Last page only
    * None
  </Tab>
</Tabs>

### Border Configuration

Add borders to header/footer:

```yaml theme={null}
Border Options:
  Position: Top | Bottom | Both
  Style: Solid | Dashed | Dotted | Double
  Width: 1-5px
  Color: Any hex color
```

### Branding & Watermarks

Protect and brand your documents:

<CardGroup cols={2}>
  <Card title="Logo" icon="image">
    Add company logo to header or footer with size and position controls
  </Card>

  <Card title="Watermarks" icon="droplet" href="/features/watermark">
    Add text or image watermarks with full customization →
  </Card>
</CardGroup>

<Tip>
  **New in v1.6.0**: Advanced watermark system with text/image support, repeat patterns (diagonal, grid, sparse), and comprehensive styling options. [Learn more →](/features/watermark)
</Tip>

<Note>
  Header, footer, and branding settings are **Pro features**. Free plan uses default header/footer.
</Note>

## Page Settings

### Page Size

Currently, all documents use **A4** (210mm × 297mm):

<Info>
  **Coming Soon:**

  * Letter (US standard)
  * Legal
  * A3, A5
  * Custom dimensions
</Info>

### Orientation

Toggle between:

* **Portrait** (vertical) - Default - Represented by vertical paper icon
* **Landscape** (horizontal) - Represented by horizontal paper icon

<Info>
  **Visual Selection**: Choose orientation with intuitive SVG paper icons showing actual page orientation. Portrait displays a vertical paper sheet, landscape shows a horizontal document.
</Info>

Affects all pages in the document. Orientation can also be set during PDF export for format-specific output.

### Page Breaks

Control where pages break (coming soon):

```yaml theme={null}
Page Break Options:
  - Avoid breaks inside blocks
  - Force break after block
  - Keep heading with following content
  - Orphan/widow control
```

## Template Library

### Built-in Templates

Start with pre-configured templates:

<CardGroup cols={2}>
  <Card title="Business Proposal" icon="briefcase">
    Professional blue theme with clean typography
  </Card>

  <Card title="Legal Contract" icon="gavel">
    Serif font with formal spacing and structure
  </Card>

  <Card title="Creative Brief" icon="lightbulb">
    Colorful with modern sans-serif fonts
  </Card>

  <Card title="Technical Report" icon="code">
    Monospace accents, tight spacing, data-focused
  </Card>

  <Card title="Invoice" icon="file-invoice">
    Minimal design with emphasis on tables
  </Card>

  <Card title="Resume" icon="user">
    Compact layout with professional styling
  </Card>
</CardGroup>

### Custom Templates

Create your own templates (Pro feature):

<Steps>
  <Step title="Start with Base">
    Choose a built-in template or start blank
  </Step>

  <Step title="Customize Settings">
    Adjust colors, fonts, spacing, headers/footers
  </Step>

  <Step title="Preview">
    See real-time preview of changes
  </Step>

  <Step title="Save Template">
    Give it a name and save to your library
  </Step>

  <Step title="Apply Anytime">
    Apply saved templates to any document
  </Step>
</Steps>

### Sharing Templates

Share custom templates with team (Enterprise feature, coming soon):

* Export template configuration as JSON
* Import templates from others
* Team template library
* Version control for templates

## Advanced Customization

### CSS Overrides (Enterprise)

Add custom CSS for ultimate control:

```css theme={null}
/* Example custom CSS */
.heading-1 {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.callout-info {
  border-left: 4px solid #3B82F6;
  border-radius: 8px;
}

.table th {
  background: linear-gradient(to bottom, #3B82F6, #2563EB);
}
```

<Warning>
  Custom CSS requires understanding of document structure. Incorrect CSS can break layouts.
</Warning>

### JavaScript Hooks (Enterprise)

Execute custom logic on document events:

```javascript theme={null}
// Example: Add current date to footer
vibedoc.onRender((doc) => {
  doc.footer.text = `© ${new Date().getFullYear()} Your Company`;
});
```

### API Configuration

Set templates programmatically:

```javascript theme={null}
// Future API
await vibedoc.updateTemplate(documentId, {
  colors: {
    primary: '#3B82F6',
    secondary: '#8B5CF6'
  },
  fonts: {
    heading: 'Inter',
    body: 'Inter'
  },
  spacing: {
    marginTop: 80,
    marginBottom: 80
  }
});
```

## Template Management

### Saving Templates

Save current configuration as reusable template:

1. **Configure Document** - Style to your liking
2. **Open Template Menu** - Click "Templates" in toolbar
3. **Save as New** - Click "Save Current as Template"
4. **Name Template** - Give it a descriptive name
5. **Confirmation** - Template saved to your library

### Applying Templates

Apply saved templates to documents:

<Tabs>
  <Tab title="New Documents">
    Select template when creating new document
  </Tab>

  <Tab title="Existing Documents">
    Open document → Templates menu → Select template → Apply
  </Tab>

  <Tab title="Multiple Documents">
    Bulk apply template to multiple docs (coming soon)
  </Tab>
</Tabs>

### Editing Templates

Modify saved templates:

* Load template into document
* Make changes
* Save over existing template (replaces)
* Or save as new template (creates variant)

### Deleting Templates

Remove templates you no longer need:

* Open Template Library
* Hover over template
* Click delete icon
* Confirm deletion

<Warning>
  Deleting a template doesn't affect documents already using it.
</Warning>

## Best Practices

<AccordionGroup>
  <Accordion icon="check" title="Consistency is Key">
    Use the same template for related documents to maintain brand consistency.
  </Accordion>

  <Accordion icon="check" title="Test on PDF">
    Always export a test PDF to verify template looks correct in final output.
  </Accordion>

  <Accordion icon="check" title="Less is More">
    Avoid over-styling. Clean, simple templates are more professional.
  </Accordion>

  <Accordion icon="check" title="Readable Fonts">
    Choose legible fonts at appropriate sizes. Minimum 14px for body text.
  </Accordion>

  <Accordion icon="check" title="Contrast">
    Ensure sufficient color contrast for accessibility (WCAG AA minimum).
  </Accordion>

  <Accordion icon="xmark" title="Don't: Too Many Colors">
    Stick to 2-3 main colors. More creates visual chaos.
  </Accordion>

  <Accordion icon="xmark" title="Don't: Tiny Margins">
    Leave adequate white space. Minimum 60px margins recommended.
  </Accordion>

  <Accordion icon="xmark" title="Don't: Mix Too Many Fonts">
    Use 1-2 font families maximum. More looks unprofessional.
  </Accordion>
</AccordionGroup>

## Responsive Templates

Templates adapt to different contexts:

| Context             | Adjustments             |
| ------------------- | ----------------------- |
| **Desktop Preview** | Full template applied   |
| **PDF Export**      | Print-optimized layout  |
| **Mobile View**     | Responsive sizing       |
| **Share Page**      | Web-optimized rendering |

<Info>
  Templates automatically adjust spacing, font sizes, and margins for each context.
</Info>

## Next Steps

<CardGroup cols={2}>
  <Card title="Creating Documents" icon="file-plus" href="/guides/creating-documents">
    Apply templates to new documents
  </Card>

  <Card title="Export" icon="file-pdf" href="/features/export">
    See templates in PDF output
  </Card>

  <Card title="Block Editor" icon="cube" href="/features/block-editor">
    Style content with templates
  </Card>

  <Card title="Sharing" icon="share-nodes" href="/features/sharing">
    Share styled documents
  </Card>
</CardGroup>
