A collection of reusable, well-documented Svelte 5 component templates. Each component is production-ready, fully commented, and designed to be easily copied into your projects.
- Human Readable: Clear, extensive comments explaining every part of the code
- Easy to Edit: Simple to customise and adapt to your needs
- Copy-Paste Ready: Just copy the component files and use them
- Production Quality: Built with best practices and performance in mind
Interactive horizontal card displays with hover and swipe interactions. Perfect for image galleries, product showcases, or content carousels.
Variants:
CardStack.svelte- Interactive selection with direction-detecting hover, keyboard nav, swipe gesturesCardStackMotionFlip.svelte- 3D roll effect with 4-directional swipe using FLIP animation
Infinite scrolling content displays for logos, testimonials, or featured content.
Variants:
Marquee.svelte- Static scroll with pause-on-hoverMarqueeDraggable.svelte- Interactive with drag-to-scroll and momentum
Cards with mouse-tracking spotlight effects and dynamic border glow. Perfect for feature highlights or premium content.
File: MagicCard.svelte
Animated border wrapper with horizontal shine animation. Zero dependencies, pure CSS animations.
File: ShineBorder.svelte
Animated CTA button with text slide animation and background expansion. No icon library dependencies.
File: SwishButton.svelte
Card with layout transitions between compact and expanded states using Svelte's built-in transitions.
File: ExpandingCard.svelte
Links with image preview on hover using blur transitions. Perfect for documentation and references.
File: LinkImageHover.svelte
Responsive navigation with mobile hamburger menu and smooth panel animations.
File: Navbar.svelte
Animated navigation menu with staggered entrance animations and active state highlighting.
File: StaggeredMenu.svelte
- Copy the component file(s) you need from
src/lib/components/ - Paste into your Svelte 5 project
- Import and use:
<script>
import CardStack from '$lib/components/CardStack.svelte';
const cards = [
{ image: '/image.jpg', title: 'Title', content: 'Description' }
];
</script>
<CardStack {cards} />-
Clone the repository:
git clone <repository-url> cd tfeSvelteTemplates
-
Install dependencies:
bun install
-
Set up environment variables (optional):
cp .env.example .env # Edit .env with your Neon database URL -
Run the development server:
bun run dev
-
Open your browser: Navigate to
http://localhost:5173
The component demos now label whether data came from the database, static fixtures, or a database error path. Authentication and write flows require a real Postgres connection.
- Create a free account at neon.tech
- Create a new project and database
- Copy your connection string
- Run the database schemas in your Neon SQL Editor:
# Auth tables database/schema_better_auth.sql # Component demo tables database/schema.sql database/schema_v2.sql
- Add connection string to
.env:DATABASE_URL=your_connection_string_here BETTER_AUTH_SECRET=your_long_random_secret BETTER_AUTH_URL=http://localhost:5173
Auth pages show "Auth Offline" until DATABASE_URL, BETTER_AUTH_SECRET, and BETTER_AUTH_URL are configured.
For local OSS demos, you can seed an explicit demo login after the auth schema exists:
bun run seed:demo-userThat creates tester@test.com with password test1. The seed is manual-only and refuses to run with NODE_ENV=production unless explicitly overridden.
For the hosted OSS demo, set PUBLIC_DEMO_AUTH=true after seeding the demo database. That exposes a "Try demo" login on the sign-in page. The public demo account is treated as read-only for mutating API routes until user-owned demo data is in place.
tfeSvelteTemplates/
βββ src/
β βββ lib/
β β βββ components/ # Reusable components
β β β βββ CardStack.svelte
β β β βββ Marquee.svelte
β β β βββ ExpandingCard.svelte
β β β βββ LinkImageHover.svelte
β β β βββ DatabaseStatus.svelte
β β βββ server/ # Server utilities
β β β βββ cards.ts
β β β βββ testimonials.ts
β β β βββ expandingCards.ts
β β β βββ linkPreviews.ts
β β βββ types.ts # TypeScript interfaces
β β βββ constants.ts # Demo fixture data
β β βββ utils.ts # Helper functions
β βββ routes/
β β βββ api/cards/
β β β βββ +server.ts # API endpoint
β β βββ +page.svelte # Home page
β β βββ +page.server.ts # Server-side data loading
β β βββ cardstack/
β β βββ marquee/
β β βββ expandingcard/
β β βββ linkimagehover/
β βββ app.html # HTML template
βββ database/
β βββ schema.sql # CardStack data schema
β βββ schema_v2.sql # Additional components schema
βββ static/ # Static assets
βββ .env.example # Environment variables template
βββ package.json # Dependencies
βββ svelte.config.js # SvelteKit configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md # This file
- Framework: SvelteKit with Svelte 5
- Language: TypeScript
- Database: Neon (Serverless Postgres)
- Hosting: Vercel
- Styling: Scoped CSS (no external dependencies)
Each component includes:
- Extensive inline comments explaining logic and behaviour
- JSDoc-style documentation for props and functions
- Usage examples in the demo page
- Customisation guidance in comments
| Prop | Type | Default | Description |
|---|---|---|---|
cards |
Card[] |
[] |
Array of card objects with image, title, content |
cardWidth |
number |
300 |
Width of card container in pixels |
cardHeight |
number |
400 |
Height of card container in pixels |
partialRevealSide |
'left' | 'right' |
'right' |
Which side stays hidden on hover |
interface Card {
image?: string; // Optional image URL
title?: string; // Optional title text
content?: string; // Optional HTML content
}All properties are optional, allowing flexibility in card content.
All components are designed to be easily customised:
- Colours: Modify the CSS variables and colours in the
<style>section - Dimensions: Pass
cardWidthandcardHeightprops - Animations: Adjust transition timings in the CSS
- Rotation: Modify rotation calculations in the transform functions
- Push your code to GitHub
- Import project in Vercel
- Add environment variables (DATABASE_URL if using Neon)
- Deploy!
The project is pre-configured with the Vercel adapter.
.envfiles are excluded from git via.gitignore.env.exampleprovided as a template (no sensitive data)- Database credentials only used server-side
- No hardcoded secrets in the codebase
This project is intended as a template collection. Feel free to use, modify, and integrate these components into your projects.
This is a template library. If you create additional templates following the same principles (well-commented, easy to use, production-ready), contributions are welcome!
For issues or questions:
- Check component comments for implementation details
- Review the demo page for usage examples
- Consult the database schema at database/schema.sql for data structure
- Chrome/Edge 90+
- Firefox 88+
- Safari 14.1+
- Opera 76+
- CSS Grid and Flexbox
- CSS Custom Properties (CSS Variables)
- CSS Transforms and Transitions
- Touch Events API
- Backdrop Filter (progressive enhancement)
Note: Backdrop filter may not work on older browsers but degrades gracefully.
- Node.js 18.x or higher
- bun 1.0.0 or higher
- Neon account for database hosting
- Vercel account for deployment
- Ensure
cardsarray is passed to the component - Check browser console for errors
- Verify images URLs are accessible
- Verify
DATABASE_URLis set in.env - Check Neon database is running
- Review server console for error messages
- Verify
database/schema_better_auth.sqlhas been run before using auth
- Run
bun installto ensure dependencies are up-to-date - Clear
.svelte-kitdirectory and rebuild - Check Node.js version matches requirements
Built with Svelte 5, TypeScript, and modern web technologies.