A modern Electron application template built with React, TypeScript, Vite, and shadcn/ui components. This template provides a solid foundation for building beautiful desktop applications with a complete UI component system and theme support.
Modern Electron application with shadcn/ui components, featuring theme toggle and responsive design
- β‘ Electron 39.0 - Cross-platform desktop app framework
- βοΈ React 19.2 - Modern React with latest features and concurrent rendering
- π· TypeScript 5.9 - Type-safe development with advanced type inference
- π Rolldown Vite 7.1.20 - Next-generation Rust-based bundler replacing traditional Vite for enhanced performance
- π¨ shadcn/ui - Complete component library with 50+ components built on Radix UI primitives
- π Tailwind CSS 4.1.16 - Latest utility-first CSS framework with enhanced performance
- π Advanced Theme System - Light, dark, and system theme modes with intelligent toggle and persistence
- π± Responsive Design - Mobile-first approach with Tailwind breakpoints
- π― Lucide React 0.552 - Beautiful, customizable SVG icons (1000+ icons)
- π¨ CSS Variables - Dynamic theming with CSS custom properties
- Layout Components: Button, Card, Dialog, Sheet, Tabs, Accordion, Sidebar
- Form Controls: Input, Label, Select, Checkbox, Radio Group, Switch, Slider, Textarea
- Navigation: Navigation Menu, Breadcrumb, Pagination, Command Palette
- Feedback: Alert, Toast, Progress, Skeleton, Sonner notifications
- Data Display: Table, Avatar, Badge, Separator, Calendar, Charts (Recharts)
- Overlay Components: Popover, Tooltip, Hover Card, Context Menu, Drawer
- Advanced Components: Carousel, Resizable Panels, Input OTP, Date Picker
- π TanStack Query 5.90 - Powerful data fetching, caching, and synchronization
- π React Hook Form 7.66 - Performant forms with minimal re-renders
- β Zod 4.1 - TypeScript-first schema validation with runtime type checking
- ποΈ Class Variance Authority - Type-safe component variants and styling
- π Hookform Resolvers - Seamless integration between forms and validation
- π§ TanStack Router 1.134 - Type-safe routing with automatic code generation
- π File-based Routes - Intuitive file-system based routing with nested layouts
- π 100% Type-safe Navigation - Full TypeScript inference for routes, params, and search
- β Error Handling - Comprehensive error boundaries with user-friendly error pages
- π― Route Devtools - Built-in developer tools for debugging routes and navigation
- β‘ Code Splitting - Automatic route-based code splitting and lazy loading
- π Multi-Theme Support - Light, dark, and system preference detection
- π Theme Toggle - Intuitive cycling through theme modes with visual indicators
- βΏ Accessibility First - WCAG compliant components with proper ARIA attributes
- π¨ Design Tokens - Consistent spacing, colors, and typography system
- π± Responsive Breakpoints - Mobile, tablet, and desktop optimized layouts
- π§ Electron Forge 7.10 - Complete build and packaging toolchain
- β‘ React Compiler - Automatic React optimizations with babel-plugin-react-compiler
- π¦ Modern Tooling - ESLint 9.39 with flat config, Rolldown Vite bundler
- π― Developer Experience - Hot reload, TypeScript path mapping, and comprehensive linting
- π GitHub Actions - Automated CI/CD with cross-platform builds
- π Type Safety - End-to-end TypeScript with strict configuration
- π Path Aliases - Clean imports with @ prefix for better code organization
- π§ͺ Vitest 4.0 - Fast unit testing with native ES modules support
- π Playwright 1.56 - End-to-end testing across multiple browsers
- π Prettier 3.6 - Consistent code formatting with automatic styling
- π Testing Library - React component testing utilities with user-centric queries
- π Coverage Reports - Comprehensive test coverage analysis and reporting
- π― Multi-Browser E2E - Chromium, Firefox, and WebKit testing support
- Node.js (v18 or higher)
- npm or yarn
-
Clone this template
git clone https://github.com/rohitsoni007/electron-shadcn.git my-electron-app cd my-electron-app -
Install dependencies
npm install
-
Start development
npm start
npm start- Start the Electron app in development modenpm run lint- Run ESLint with modern flat confignpm run type-check- Run TypeScript type checkingnpm run format- Format code with Prettiernpm run format:check- Check code formattingnpm run routes:generate- Generate TanStack Router route treenpm run routes:watch- Watch and auto-generate routes during development
npm run test- Run unit tests with Vitestnpm run test:watch- Run unit tests in watch modenpm run test:ui- Run unit tests with UI interfacenpm run test:coverage- Run tests with coverage reportnpm run test:e2e- Run end-to-end tests with Playwrightnpm run test:e2e:ui- Run E2E tests with interactive UInpm run test:e2e:headed- Run E2E tests with visible browser
npm run build- Build the applicationnpm run package- Package the app for distributionnpm run make- Create distributable packagesnpm run publish- Publish the app
src/
βββ components/ # React components
β βββ ui/ # shadcn/ui components
β βββ Layout.tsx # Main layout component
β βββ ThemeProvider.tsx # Theme context provider
β βββ ThemeToggle.tsx # Theme toggle button
βββ hooks/ # Custom React hooks
βββ lib/ # Utility functions
βββ pages/ # Page components
β βββ Home.tsx
β βββ About.tsx
β βββ Settings.tsx
βββ routes/ # TanStack Router file-based routes
β βββ __root.tsx # Root route layout
β βββ index.tsx # Home route (/)
β βββ about.tsx # About route (/about)
β βββ settings.tsx # Settings route (/settings)
βββ test/ # Unit test setup and utilities
βββ App.tsx # Main App component
βββ main.ts # Electron main process
βββ routeTree.gen.ts # Auto-generated route tree (do not edit)
βββ index.css # Global styles
tests/
βββ e2e/ # End-to-end tests
βββ example.spec.ts # Playwright E2E tests
Configuration Files:
βββ eslint.config.mts # ESLint 9 flat configuration
βββ playwright.config.ts # Playwright E2E test configuration
βββ vitest.config.ts # Vitest unit test configuration
βββ tsr.config.json # TanStack Router configuration
βββ .prettierrc # Prettier formatting rules
This template includes a complete set of shadcn/ui components and modern libraries:
- Layout & Structure: Button, Card, Dialog, Sheet, Tabs, Accordion, Sidebar, Resizable Panels
- Form Controls: Input, Textarea, Label, Select, Checkbox, Radio Group, Switch, Slider, Input OTP
- Navigation: Navigation Menu, Breadcrumb, Pagination, Command Palette, Menubar
- Feedback & Status: Alert, Alert Dialog, Toast, Progress, Skeleton, Sonner notifications
- Data Display: Table, Avatar, Badge, Separator, Calendar, Charts (Recharts integration)
- Overlay & Interaction: Popover, Tooltip, Hover Card, Context Menu, Drawer (Vaul)
- Advanced Components: Carousel (Embla), Collapsible, Toggle, Toggle Group, Aspect Ratio
- Form Integration: Form wrapper components with React Hook Form integration
- React Hook Form 7.66 - Form state management with minimal re-renders and validation
- Zod 4.1 - Runtime type validation and schema parsing with TypeScript inference
- TanStack Query 5.90 - Server state management, caching, and background updates
- Lucide React 0.552 - Consistent icon system with 1000+ customizable SVG icons
- Tailwind Merge - Intelligent class merging for dynamic styles and conditional classes
- Class Variance Authority - Type-safe component variant system with IntelliSense
- Next Themes - Advanced theme management with system preference detection
- Sonner - Beautiful toast notifications with stacking and positioning
- Recharts - Composable charting library for data visualization
- Embla Carousel - Lightweight, extensible carousel with touch support
- Vaul - Drawer component for mobile-first interactions
This template includes the React Compiler for automatic performance optimizations:
- Automatic Memoization - Eliminates the need for manual
useMemo,useCallback, andReact.memo - Smart Re-rendering - Reduces unnecessary component re-renders automatically
- Zero Configuration - Works out of the box with your existing React code
- Better Performance - Optimizes your components without code changes
The React Compiler is configured in vite.renderer.config.mts and will automatically optimize your React components during the build process.
The template includes a complete theme system with:
- Light Mode - Clean, bright interface
- Dark Mode - Easy on the eyes
- System Mode - Follows OS preference
- Theme Toggle - Easy switching between modes
- Persistent Settings - Theme preference saved to localStorage
import { useTheme } from "@/components/ThemeProvider";
function MyComponent() {
const { theme, setTheme } = useTheme();
return (
<button onClick={() => setTheme("dark")}>
Switch to Dark Mode
</button>
);
}The template uses TanStack Router for type-safe, file-based routing:
- Create a route file in
src/routes/:
// src/routes/my-page.tsx
import { createFileRoute } from '@tanstack/react-router';
import MyPage from '../pages/MyPage';
export const Route = createFileRoute('/my-page')({
component: MyPage,
});- Generate the route tree:
npm run routes:generate- Type-safe navigation with full TypeScript inference
- Automatic code splitting for better performance
- Built-in devtools for debugging routes
- Search params and route params with validation
- Nested layouts and error boundaries
- Route-level data loading with loaders
This template includes a comprehensive testing setup with both unit and end-to-end testing capabilities.
Vitest provides fast unit testing with native ES modules support:
// src/test/example.test.tsx
import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import MyComponent from '../components/MyComponent';
describe('MyComponent', () => {
it('renders correctly', () => {
render(<MyComponent />);
expect(screen.getByText('Hello World')).toBeInTheDocument();
});
});Features:
- Fast execution with native ES modules
- React Testing Library integration
- jsdom environment for DOM testing
- Coverage reports with built-in coverage
- Watch mode for development
Playwright enables comprehensive E2E testing across multiple browsers:
// tests/e2e/app.spec.ts
import { test, expect } from '@playwright/test';
test('app loads correctly', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/Electron/);
// Test navigation
await page.click('text=About');
await expect(page).toHaveURL(/.*about/);
});Features:
- Multi-browser testing (Chromium, Firefox, WebKit)
- Auto-wait for elements and network requests
- Screenshots and videos on test failures
- Trace viewer for debugging
- Parallel execution for faster test runs
# Unit tests
npm run test # Run once
npm run test:watch # Watch mode
npm run test:ui # Interactive UI
npm run test:coverage # With coverage
# E2E tests
npm run test:e2e # Headless mode
npm run test:e2e:ui # Interactive mode
npm run test:e2e:headed # Visible browsernpx shadcn@latest add [component-name]- Create component in
src/components/ - Use TypeScript and follow the existing patterns
- Import and use in your pages
Modify build settings in vite.renderer.config.mjs:
export default defineConfig({
// Your custom Vite config
});npm run packagenpm run makeThis will create platform-specific distributables in the out/ directory.
This template includes GitHub Actions workflows for automated building and releasing:
- Triggers: Push to main, pull requests, and tags
- Platforms: Windows, macOS, and Linux
- Outputs: Executable files for all platforms
- Artifacts: Automatically uploaded and stored for 30 days
- Note: Regular pushes to main only build and test - no release is created
- Triggers: Manual trigger from GitHub Actions interface or git tags
- Features:
- Cross-platform builds
- Manual GitHub releases
- Release notes generation
- Custom or timestamped versions
The workflow supports manual release creation through GitHub Actions interface:
-
Create a manual release:
- Go to Actions tab in your GitHub repository
- Select "Build and Release" workflow
- Click "Run workflow" button
- Choose options:
- β Create a release: Check this box
- π Release tag: Enter custom tag (e.g.,
v1.0.0) or leave empty for auto-generated
-
Alternative: Git tag releases:
# Create and push a version tag for automatic release git tag v1.0.0 git push origin v1.0.0 # β This triggers build and release automatically
-
GitHub Actions will:
- Build for all platforms (Windows, macOS, Linux)
- Create distributable packages (.exe, .dmg, .deb, .rpm, .zip)
- Create a GitHub release with all artifacts
- Generate release notes from commits
-
Release naming options:
- Custom tag:
v1.0.0(if specified in manual trigger) - Git tag: Uses the pushed tag name
- Auto-generated:
v1.0.0-20241103-183045(version + timestamp)
- Custom tag:
-
Release artifacts include:
- Windows:
.exeinstaller and.zipportable - macOS:
.dmginstaller and.zipportable - Linux:
.deband.rpmpackages, plus.zipportable
- Windows:
Manual control - create releases when you're ready!
For production releases, you can set up code signing by adding these secrets to your GitHub repository:
macOS Code Signing:
APPLE_CERTIFICATE- Base64 encoded .p12 certificateAPPLE_CERTIFICATE_PASSWORD- Certificate passwordAPPLE_ID- Apple ID for notarizationAPPLE_APP_SPECIFIC_PASSWORD- App-specific passwordAPPLE_TEAM_ID- Apple Developer Team IDKEYCHAIN_PASSWORD- Keychain password
Windows Code Signing:
WINDOWS_CERTIFICATE- Base64 encoded certificateWINDOWS_CERTIFICATE_PASSWORD- Certificate password
- Hot Reload - The development server supports hot reload for fast iteration
- TypeScript - Use TypeScript for better development experience
- Component Library - Leverage the included shadcn/ui components
- Theme Consistency - Use CSS variables for consistent theming
- Path Aliases - Use
@/imports for cleaner code organization
- Electron Documentation
- React Documentation
- shadcn/ui Documentation
- Tailwind CSS Documentation
- Vite Documentation
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Happy coding! π
Built with β€οΈ using Electron + shadcn/ui
