Skip to main content

Themes

Themes in EverShop control the visual presentation and user interface of your store. They contain React components that render the pages your customers see, while keeping business logic separate in extensions.

What are Themes?

Themes provide:
  • Visual design and styling with Tailwind CSS
  • React components for pages and UI elements
  • Responsive layouts for mobile and desktop
  • Brand customization (colors, fonts, logos)
  • User experience enhancements
Extensions vs Themes: Extensions handle business logic (APIs, GraphQL, cron jobs), while themes handle presentation (React components, styling). This separation allows you to change your store’s appearance without affecting functionality.

Directory Structure

Themes live in the themes/ directory:

Activating a Theme

Set your active theme in config/default.json:
config/default.json
You can only have one active theme at a time. The theme name must match a directory in themes/.

Creating a Theme

Page Components

Page components are React components with special exports that tell EverShop where and when to render them.

Basic Component Structure

Every theme component needs:
  1. A default export (the React component)
  2. A layout export (defines placement and order)
  3. Optional query export (for GraphQL data fetching)
themes/anasuplements/src/pages/homepage/Hero.tsx

Layout Export

The layout export determines where the component appears:
Common areaId values:
  • header - Top of all pages
  • footer - Bottom of all pages
  • content - Main content area
  • productPageBottom - Below product details
  • checkoutPaymentMethod - Payment method selection area

GraphQL Data Fetching

Use the query export to fetch data:
themes/anasuplements/src/pages/all/Header.tsx

Page Areas

Organize components by the pages they appear on:

Global Components (all/)

Components that appear on every page:

Homepage Components (homepage/)

Components specific to the homepage:
themes/anasuplements/src/pages/homepage/FeaturedProducts.tsx

Account Pages (account/)

User account-related components:

Styling with Tailwind CSS

EverShop uses Tailwind CSS for styling. The Ana’s Suplements theme uses a custom color palette:
Use Tailwind’s utility classes for responsive design:
  • sm: - Small screens (640px+)
  • md: - Medium screens (768px+)
  • lg: - Large screens (1024px+)
  • xl: - Extra large screens (1280px+)

TypeScript Props

Always define TypeScript types for your component props:

Accessing EverShop Hooks

EverShop provides React hooks for common operations:

Best Practices

Name components based on what they represent, not how they look:
  • Good: ProductCard, HeroSection, FeaturedProducts
  • Bad: GreenBox, BigText, ThreeColumns
Break large components into smaller, reusable pieces:
Avoid custom CSS files. Use Tailwind utility classes for all styling:
Use Tailwind’s spacing scale consistently:
  • p-4, p-6, p-8 for padding
  • mb-4, mb-6, mb-8 for margins
  • gap-4, gap-6, gap-8 for grid/flex gaps

anasuplements Theme Example

The included Ana’s Suplements theme demonstrates:
  • Custom color palette: Green (#2D5A3D) with pearl white backgrounds
  • Responsive design: Mobile-first layouts that adapt to larger screens
  • Component organization: Logical separation of homepage, account, and global components
  • TypeScript types: Proper type definitions for all props
  • Tailwind styling: Consistent use of utility classes
themes/anasuplements/

Next Steps