Explore

Explore snippets

Discover reusable code snippets, examples, fixes, and ideas shared by developers, students, and teams.

Clear
37 public snippets
Open
HTML / Markup
Public

Simple Login Form

A basic HTML form for user login with username and password fields.

HTML / Markup Preview
<form action="/login" method="post">
  <label for="username">Username:</label>
  <input type="text" id="username" name="username" required>
  <br>
  <label for="password">Password:</label>
  <input type="password" id="password" name="password" required>
  <br>
Pluto
Pluto
Updated: 2026-09-07 12:26
Public snippets
0 #273
Open
HTML / Markup
Public

FAQ Section Markup

A simple FAQ section using semantic HTML and details/summary elements.

HTML / Markup Preview
<section class="faq-section" aria-labelledby="faq-title">
  <h2 id="faq-title">Frequently asked questions</h2>

  <details>
    <summary>Can I use CodShot for free?</summary>
    <p>Yes. The free plan is a good way to try the platform.</p>
  </details>
#html #faq #semantic #beginner
CodShot user
CodShot user
Updated: 2026-09-05 16:52
Public snippets
0 #58
Open
PHP
Public

Language Detection and Translation Loader

Manages front-end language detection, session and cookie handling, and loads language translation scopes from PHP files with fallback suppor...

PHP Preview
<?php

declare(strict_types=1);

// ------------------------------------------------------------
// Global language code list
// ------------------------------------------------------------
if (!defined('ALLOWED_LANG_CODES')) {
Pluto
Pluto
Updated: 2026-09-01 16:05
Public snippets
0 #35
Open
PHP
Public

Simple PHP Router with Dynamic User ID Route

This code implements a basic PHP router that directs static URLs to specific files and handles dynamic user ID routes, returning a 404 error...

PHP Preview
<?php

$routes = [
    '/' => 'home.php',
    '/about' => 'about.php',
    '/user' => 'user.php'
];

$requestUri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

function handleRoute($uri, $routes)
{
    if (array_key_exists($uri, $routes)) {
Pluto
Pluto
Updated: 2026-08-24 08:10
Public snippets
0 #6
Open
PHP
Public

Load PHPMailer Library Once

This function loads the three essential PHPMailer files only once to prevent multiple inclusions during execution.

PHP Preview
<?php

function mailer_require_phpmailer(): void
{
    static $loaded = false;

    if ($loaded) {
        return;
    }

    $base = APP_PATH . '/libraries/PHPMailer/src';

    require_once $base . '/Exception.php';
    require_once $base . '/PHPMailer.php';
Pluto
Pluto
Updated: 2026-08-24 08:10
Public snippets
0 #7
Open
HTML / Markup
Public

Animated Modern Login Form

A sleek, animated login form with email and password fields, glowing Sign In button, and smooth hover effects.

HTML / Markup Preview
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Animated Login Form</title>
<style>
Geri
Geri
Updated: 2026-08-17 15:47
Public snippets
0 #248
Open
HTML / Markup
Public

Modern Animated Login Form

An animated login form with email and password fields, glowing Sign In button, and smooth hover effects.

HTML / Markup Preview
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Animated Login Form</title>
  <style>
Geri
Geri
Updated: 2026-08-17 14:32
Public snippets
0 #246
Open
HTML / Markup
Public

Animated Login Form

A modern login form with email and password fields, glowing Sign In button, and smooth hover animations.

HTML / Markup Preview
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Animated Login Form</title>
<style>
Geri
Geri
Updated: 2026-08-17 14:27
Public snippets
0 #245
Open
HTML / Markup
Public

Responsive Bootstrap Product Card

A modern responsive product card built with Bootstrap 5, featuring a hover animation and a call-to-action button.

HTML / Markup Preview
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Product Card</title>

    <!-- Bootstrap -->
#első #valami #akármi
Pluto
Pluto
Updated: 2026-08-09 11:16
Public snippets
0 #8
Open
JavaScript
Public

Cross-Tab State Sync with BroadcastChannel

Synchronize lightweight UI state between tabs from the same origin.

JavaScript Preview
const channel = new BroadcastChannel('app-preferences');

const preferences = {
  theme: 'dark',
  compactMode: true,
};

channel.addEventListener('message', (event) => {
  if (event.data?.type !== 'preferences-updated') {
    return;
  }
#javascript #broadcastchannel #browser-api #state
CodShot user
CodShot user
Updated: 2026-08-06 18:36
Public snippets
0 #240
Open
TypeScript
Public

Async Generator for Paginated API Data

Iterate through paginated API responses without loading every page into memory.

TypeScript Preview
type Page<T> = {
  items: T[];
  nextCursor: string | null;
};

export async function* paginate<T>(
  buildUrl: (cursor: string | null) => string,
): AsyncGenerator<T, void, void> {
  let cursor: string | null = null;

  do {
#typescript #async #pagination #api
CodShot user
CodShot user
Updated: 2026-08-06 18:36
Public snippets
0 #234
Open
TSX
Public

Next.js Loading Skeleton

Provide instant loading UI for an App Router segment with loading.tsx.

TSX Preview
// app/dashboard/loading.tsx

export default function DashboardLoading() {
  return (
    <main aria-busy="true" aria-label="Loading dashboard">
      <div className="skeleton skeleton-title" />

      <div className="skeleton-grid">
#nextjs #suspense #loader #ui
CodShot user
CodShot user
Updated: 2026-08-06 18:36
Public snippets
0 #228
Open
TSX
Public

Next.js Server Action Form with useActionState

Connect a Next.js Server Action to a client form with validation and pending state.

TSX Preview
// app/actions.ts
'use server';

export type CreateUserState = {
  message: string;
  errors: {
    email?: string;
  };
};

export async function createUser(
  previousState: CreateUserState,
  formData: FormData,
): Promise<CreateUserState> {
#nextjs #server-actions #form #typescript
CodShot user
CodShot user
Updated: 2026-08-06 18:36
Public snippets
0 #222
Open
TSX
Public

React Error Boundary Component

Catch rendering errors in a subtree and provide a retryable fallback UI.

TSX Preview
import {
  Component,
  type ErrorInfo,
  type ReactNode,
} from 'react';

type Props = {
  children: ReactNode;
  fallback?: ReactNode;
};

type State = {
  hasError: boolean;
};

export class ErrorBoundary extends Component<Props, State> {
  state: State = {
#react #error-handling #ui #typescript
CodShot user
CodShot user
Updated: 2026-08-06 18:36
Public snippets
0 #221
Open
TSX
Public

Dynamic Page with notFound

Render the nearest not-found UI when a requested App Router record does not exist.

TSX Preview
// app/products/[id]/page.tsx

import { notFound } from 'next/navigation';

type PageProps = {
  params: Promise<{
    id: string;
  }>;
};

export default async function ProductPage({
  params,
}: PageProps) {
  const { id } = await params;
#nextjs #app-router #routing #error-handling
CodShot user
CodShot user
Updated: 2026-08-06 18:36
Public snippets
0 #217
Open
TSX
Public

Non-Blocking Tabs with useTransition

Switch expensive tab content without blocking urgent UI updates.

TSX Preview
'use client';

import { useState, useTransition } from 'react';

const tabs = ['overview', 'activity', 'settings'] as const;
type Tab = (typeof tabs)[number];

export function DashboardTabs() {
  const [activeTab, setActiveTab] = useState<Tab>('overview');
#react #hooks #performance #ui
CodShot user
CodShot user
Updated: 2026-08-06 18:36
Public snippets
0 #214
Open
TSX
Public

Optimistic Todo List with useOptimistic

Show a new todo immediately while the asynchronous save operation completes in the background.

TSX Preview
'use client';

import { startTransition, useOptimistic, useState } from 'react';

type Todo = {
  id: string;
  text: string;
  pending?: boolean;
};

type Props = {
  initialTodos: Todo[];
  createTodo: (text: string) => Promise<Todo>;
};
#react #hooks #state #optimistic-ui
CodShot user
CodShot user
Updated: 2026-08-06 18:36
Public snippets
0 #212
Open
TSX
Public

React Form Validation with useActionState

Manage form validation, submission status, and server-style action results with React useActionState.

TSX Preview
'use client';

import { useActionState } from 'react';

type FormState = {
  message: string;
  errors: {
    email?: string;
  };
};

const initialState: FormState = {
  message: '',
  errors: {},
};

async function subscribe(
  previousState: FormState,
#react #hooks #form #validation
CodShot user
CodShot user
Updated: 2026-08-06 18:36
Public snippets
0 #211
Open
PHP
Public

PHP Read JSON Request Body

Read and validate a JSON request body in PHP.

PHP Preview
<?php

$rawBody = file_get_contents('php://input');
$data = json_decode($rawBody, true);

if (!is_array($data) || json_last_error() !== JSON_ERROR_NONE) {
    http_response_code(400);
    echo json_encode(['error' => 'Invalid JSON body.']);
    exit;
}
#php #api #json #validation
CodShot user
CodShot user
Updated: 2026-06-08 14:33
Public snippets
0 #127
Open
HTML / Markup
Public

Card Grid with Equal Height Cards

Create a responsive Bootstrap card grid where cards keep equal height.

HTML / Markup Preview
<div class="row g-4">
    <div class="col-md-6 col-lg-4">
        <div class="card h-100">
            <div class="card-body d-flex flex-column">
                <h5 class="card-title">Feature title</h5>
#bootstrap #card #grid #responsive
CodShot user
CodShot user
Updated: 2026-06-08 14:33
Public snippets
0 #123
Open
HTML / Markup
Public

Offcanvas Sidebar Layout

Open a mobile-friendly offcanvas sidebar with Bootstrap.

HTML / Markup Preview
<button class="btn btn-outline-secondary" data-bs-toggle="offcanvas" data-bs-target="#accountMenu">
    Menu
</button>

<div class="offcanvas offcanvas-start" tabindex="-1" id="accountMenu">
    <div class="offcanvas-header">
#bootstrap #offcanvas #sidebar #responsive
CodShot user
CodShot user
Updated: 2026-06-08 14:33
Public snippets
0 #122
Open
HTML / Markup
Public

Responsive Navbar Starter

A simple Bootstrap responsive navbar with collapse behavior.

HTML / Markup Preview
<nav class="navbar navbar-expand-lg bg-body-tertiary">
    <div class="container">
        <a class="navbar-brand" href="/">CodShot</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav">
#bootstrap #navbar #responsive #layout
CodShot user
CodShot user
Updated: 2026-06-08 14:33
Public snippets
0 #121
Open
HTML / Markup
Public

Bootstrap Modal Form Skeleton

A small Bootstrap 5 modal with a form and submit button.

HTML / Markup Preview
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#newItemModal">
    New item
</button>

<div class="modal fade" id="newItemModal" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog">
#bootstrap #modal #form #ui
CodShot user
CodShot user
Updated: 2026-06-08 14:33
Public snippets
0 #120
Open
HTML / Markup
Public

Bootstrap Toast Notification

Show a Bootstrap 5 toast message from JavaScript.

HTML / Markup Preview
<button class="btn btn-primary" id="showToastBtn">Show toast</button>

<div class="toast-container position-fixed bottom-0 end-0 p-3">
    <div id="demoToast" class="toast" role="status" aria-live="polite" aria-atomic="true">
        <div class="toast-header">
#bootstrap #toast #ui #javascript
CodShot user
CodShot user
Updated: 2026-06-08 14:33
Public snippets
0 #119
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support