Custom Theme Example
Custom Theme Example
Section titled “Custom Theme Example”This example shows how to create a fully customized theme for your podcast using the CMS-driven theme system.
Create a custom theme with:
- Brand colors (red and orange)
- Custom fonts (Roboto and Montserrat)
- Rounded corners
- Spacious layout
Step-by-Step
Section titled “Step-by-Step”Step 1: Open Sanity Studio
Section titled “Step 1: Open Sanity Studio”npm run dev:sanityVisit http://localhost:3333
Step 2: Create Theme
Section titled “Step 2: Create Theme”- Click “Theme” in sidebar
- Click “Create new Theme”
- Name: “Brand Theme”
Step 3: Configure Colors
Section titled “Step 3: Configure Colors”Primary Color: Red
R: 220G: 38B: 38Secondary Color: Orange
R: 234G: 88B: 12Accent Color: Light Orange
R: 251G: 146B: 60Background: White
R: 255G: 255B: 255Text: Dark Gray
R: 17G: 24B: 39Header Background: Red (same as primary)
R: 220G: 38B: 38Header Text: White
R: 255G: 255B: 255Footer Background: Dark Gray
R: 31G: 41B: 55Footer Text: White
R: 255G: 255B: 255Step 4: Configure Typography
Section titled “Step 4: Configure Typography”Font Family: “Roboto”
Heading Font: “Montserrat”
Step 5: Configure Layout
Section titled “Step 5: Configure Layout”Border Radius: “rounded-xl” (very rounded)
Spacing: “spacious”
Step 6: Publish Theme
Section titled “Step 6: Publish Theme”Click “Publish”
Step 7: Apply to Podcast
Section titled “Step 7: Apply to Podcast”- Click “Podcast” in sidebar
- Open your podcast document
- Scroll to “Theme” field
- Select “Brand Theme”
- Click “Publish”
Step 8: Preview
Section titled “Step 8: Preview”Refresh your website → Custom theme applied!
Result
Section titled “Result”Your podcast now has:
Colors:
- Red primary color on buttons and links
- Orange accents
- White background
- Dark text for readability
Typography:
- Roboto for body text (clean, modern)
- Montserrat for headings (distinctive)
Layout:
- Extra rounded corners on cards
- Generous spacing between sections
- Breathable, spacious design
Code Implementation
Section titled “Code Implementation”The theme is automatically converted to CSS:
:root { /* Colors */ --color-primary: 220, 38, 38; /* Red */ --color-secondary: 234, 88, 12; /* Orange */ --color-accent: 251, 146, 60; /* Light orange */ --color-background: 255, 255, 255; /* White */ --color-text: 17, 24, 39; /* Dark gray */ --color-header-bg: 220, 38, 38; /* Red */ --color-header-text: 255, 255, 255; /* White */ --color-footer-bg: 31, 41, 55; /* Dark gray */ --color-footer-text: 255, 255, 255; /* White */
/* Typography */ --font-family: Roboto, sans-serif; --font-heading: Montserrat, sans-serif;}
/* Google Fonts auto-loaded */@import url('https://fonts.googleapis.com/css2?family=Roboto&family=Montserrat&display=swap');Using Theme in Custom Components
Section titled “Using Theme in Custom Components”<div class="card"> <h3>Custom Component</h3> <p>Uses theme colors automatically</p> <button>Click Me</button></div>
<style> .card { background: rgb(var(--color-background)); border: 2px solid rgb(var(--color-primary)); padding: 2rem; border-radius: 1rem; /* matches rounded-xl */ }
.card h3 { color: rgb(var(--color-primary)); font-family: var(--font-heading); }
.card button { background: rgb(var(--color-primary)); color: white; padding: 0.75rem 1.5rem; border-radius: 0.5rem; }
.card button:hover { background: rgba(var(--color-primary), 0.9); }</style>Advanced Customization
Section titled “Advanced Customization”Multiple Themes
Section titled “Multiple Themes”Create themes for different purposes:
Theme 1: Brand Theme (production)Theme 2: Holiday Theme (seasonal)Theme 3: Dark Theme (alternative)Switch by updating Podcast’s theme reference.
Theme Variations
Section titled “Theme Variations”Create variations of your theme:
Light Variation:
Background: 255, 255, 255 (white)Text: 17, 24, 39 (dark)Dark Variation:
Background: 17, 24, 39 (dark)Text: 249, 250, 251 (light)Per-Page Theme Overrides
Section titled “Per-Page Theme Overrides”Use different theme for specific pages:
---import { mergeTheme, defaultTheme, generateThemeCSS } from '@rejected-media/podcast-framework-core';
const pageTheme = mergeTheme(defaultTheme, { colors: { primary: '16, 185, 129', // Green for this page }});
const themeCSS = generateThemeCSS(pageTheme);---
<style set:html={themeCSS}></style>
<!-- Page uses green theme -->Color Palette Generator
Section titled “Color Palette Generator”Use these tools to create harmonious color palettes:
- coolors.co - Generate palettes
- paletton.com - Color scheme designer
- colorhunt.co - Curated palettes
Then convert to RGB:
Hex: #DC2626↓RGB: 220, 38, 38↓Sanity: R: 220, G: 38, B: 38Complete Theme Configuration
Section titled “Complete Theme Configuration”{ _type: 'theme', name: 'Brand Theme',
colors: { primary: { r: 220, g: 38, b: 38 }, // Red-600 secondary: { r: 234, g: 88, b: 12 }, // Orange-600 accent: { r: 251, g: 146, b: 60 }, // Orange-400 background: { r: 255, g: 255, b: 255 }, // White text: { r: 17, g: 24, b: 39 }, // Gray-900 headerBg: { r: 220, g: 38, b: 38 }, // Red-600 headerText: { r: 255, g: 255, b: 255 }, // White footerBg: { r: 31, g: 41, b: 55 }, // Gray-800 footerText: { r: 255, g: 255, b: 255 } // White },
typography: { fontFamily: 'Roboto', headingFont: 'Montserrat' },
layout: { borderRadius: 'rounded-xl', spacing: 'spacious' }}Testing Your Theme
Section titled “Testing Your Theme”Visual Testing
Section titled “Visual Testing”Check theme on all pages:
# Homepagehttp://localhost:4321/
# Episodeshttp://localhost:4321/episodes
# Individual episodehttp://localhost:4321/episodes/welcome-to-the-show
# Abouthttp://localhost:4321/aboutResponsive Testing
Section titled “Responsive Testing”Test on multiple screen sizes:
- Mobile: 375px
- Tablet: 768px
- Desktop: 1024px
- Large: 1440px
Accessibility Testing
Section titled “Accessibility Testing”Check contrast ratios:
Tool: WebAIM Contrast Checker
Text on Background:- Foreground: rgb(17, 24, 39)- Background: rgb(255, 255, 255)- Ratio: 18:1 ✅ (WCAG AAA)
Button Text:- Foreground: rgb(255, 255, 255)- Background: rgb(220, 38, 38)- Ratio: 5.9:1 ✅ (WCAG AA)Related
Section titled “Related”- Theming Guide - Complete theming guide
- Theme Configuration - Configure in Sanity
- Theme System API - Theme utilities
Next Steps
Section titled “Next Steps”- Component Overrides - Customize components
- Basic Podcast Example - Complete example
- Deployment - Deploy your themed site