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 thethemes/ directory:
Activating a Theme
Set your active theme inconfig/default.json:
config/default.json
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:- A default export (the React component)
- A
layoutexport (defines placement and order) - Optional
queryexport (for GraphQL data fetching)
themes/anasuplements/src/pages/homepage/Hero.tsx
Layout Export
Thelayout export determines where the component appears:
areaId values:
header- Top of all pagesfooter- Bottom of all pagescontent- Main content areaproductPageBottom- Below product detailscheckoutPaymentMethod- Payment method selection area
GraphQL Data Fetching
Use thequery 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:TypeScript Props
Always define TypeScript types for your component props:Accessing EverShop Hooks
EverShop provides React hooks for common operations:Best Practices
Use semantic component names
Use semantic component names
Name components based on what they represent, not how they look:
- Good:
ProductCard,HeroSection,FeaturedProducts - Bad:
GreenBox,BigText,ThreeColumns
Keep components focused and reusable
Keep components focused and reusable
Break large components into smaller, reusable pieces:
Use Tailwind classes directly
Use Tailwind classes directly
Avoid custom CSS files. Use Tailwind utility classes for all styling:
Maintain consistent spacing
Maintain consistent spacing
Use Tailwind’s spacing scale consistently:
p-4,p-6,p-8for paddingmb-4,mb-6,mb-8for marginsgap-4,gap-6,gap-8for 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
- Learn about Extensions for adding functionality
- Understand Routing for page configuration
- Explore the GraphQL API for data fetching