What are Components?
Components in Quartz are modular, reusable pieces that make up your site’s layout and functionality. Each component is responsible for rendering a specific part of your site, such as navigation, search, or content display.Component Architecture
All Quartz components follow a consistent pattern defined by theQuartzComponent type:
quartz/components/types.ts
- CSS styles - Component-specific styling
- beforeDOMLoaded script - JavaScript that runs before the DOM is ready
- afterDOMLoaded script - JavaScript that runs after the DOM is loaded
Component Types
Quartz components fall into several categories:Layout Components
Layout Components
Components that define the structure and layout of your pages:
- Head - HTML head metadata
- PageTitle - Site title in the header
- Header - Custom header content
- Footer - Site footer with links
- Spacer - Adds vertical spacing
Navigation Components
Navigation Components
Content Components
Content Components
Components that display page content and metadata:
- Content - Main page content
- ArticleTitle - Article heading
- ContentMeta - Date and reading time
- TagList - Page tags
- Backlinks - Pages linking to current page
- RecentNotes - Latest content list
Utility Components
Utility Components
Components that add functionality or control display:
- Darkmode - Theme toggle button
- ReaderMode - Reader mode toggle
- Comments - Giscus comments integration
- DesktopOnly - Show only on desktop
- MobileOnly - Show only on mobile
- Flex - Flexbox layout wrapper
- ConditionalRender - Conditionally display components
Page Components
Page Components
Full-page templates for different content types:
- Content - Single page display
- TagContent - Tag listing page
- FolderContent - Folder listing page
- NotFound - 404 error page
Component Configuration
Components are configured in yourquartz.layout.ts file. Quartz provides two main layout configurations:
Shared Layout
Components that appear on every page:quartz.layout.ts
Page Layout
Components positioned in different areas of your pages:quartz.layout.ts
Layout Areas
Components can be placed in five main areas:head
HTML
<head> section - metadata, scripts, and stylesheader
Top of every page - typically navigation or branding
beforeBody
Above main content - breadcrumbs, title, metadata
left
Left sidebar - navigation, search, explorer
right
Right sidebar - table of contents, graph, backlinks
footer
Bottom of every page - copyright, links
Component Constructor Pattern
Most Quartz components use a constructor pattern that allows configuration:- Default options that can be overridden
- Type-safe configuration
- Consistent API across all components
Props and Context
Components receive rich context through their props:Current page data including frontmatter, content, and metadata
All files in your vault for cross-referencing
Global Quartz configuration from
quartz.config.tsOptional CSS class for responsive display (
mobile-only or desktop-only)AST representation of the current page content
Next Steps
Built-in Components
Explore all available components and their configuration options
Custom Components
Learn how to create your own custom components