A lightweight CodePen-inspired online code editor built with React and Vite. This application allows users to write HTML, CSS, and JavaScript code in separate editors and instantly preview the output in real time. Users can also download their project as a ZIP file containing index.html, style.css, and script.js.
- ๐ Separate editors for HTML, CSS, and JavaScript
- โก Live preview with automatic updates
- ๐พ Auto-save using Local Storage
- ๐ฆ Download the complete project as a ZIP file
- ๐ฑ Responsive interface
- ๐จ Syntax highlighting for all three languages
- ๐ฝ Expand/Collapse editor panels
- โ๏ธ Lightweight and fast with Vite
- React 19
- Vite
- JavaScript (ES6+)
- HTML5
- CSS3
- CodeMirror 6
- @uiw/react-codemirror
- Font Awesome
- JSZip
- FileSaver.js
- Local Storage API
- iframe (Live Preview)
codepen-clone/
โ
โโโ public/
โ
โโโ src/
โ โโโ assets/
โ โ
โ โโโ components/
โ โ โโโ DownloadButton.jsx
โ โ โโโ Editor.jsx
โ โ
โ โโโ hooks/
โ โ โโโ useLocalStorage.jsx
โ โ
โ โโโ App.jsx
โ โโโ App.css
โ โโโ index.css
โ โโโ main.jsx
โ
โโโ package.json
โโโ vite.config.js
โโโ README.md
Clone the repository
git clone https://github.com/shuvomdhar/codepen-clone.gitGo inside the project
cd codepen-cloneInstall dependencies
npm installStart the development server
npm run devOpen your browser and visit
http://localhost:5173
npm install @uiw/react-codemirror
npm install @codemirror/lang-html
npm install @codemirror/lang-css
npm install @codemirror/lang-javascript
npm install jszip
npm install file-saver
npm install @fortawesome/react-fontawesome
npm install @fortawesome/free-solid-svg-iconsStart the application.
You'll see three code editors.
- HTML
- CSS
- JavaScript
Write your HTML.
Example
<h1>Hello World</h1>
<p>Welcome to my CodePen Clone.</p>Write your CSS.
body{
background:#282c34;
color:white;
text-align:center;
}
h1{
color:tomato;
}Write your JavaScript.
document.querySelector("h1").onclick = () => {
alert("Hello!");
}The output will be displayed instantly in the preview panel.
No page refresh is required.
Click the Download ZIP button.
The application downloads
codepen-project.zip
โ
โโโ index.html
โโโ style.css
โโโ script.js
Extract the ZIP file and open index.html in your browser.
The application automatically stores your code in the browser using Local Storage.
This means:
- Refreshing the page won't erase your work.
- Closing and reopening the browser keeps your code.
- No manual save button is required.
The preview updates automatically while you type.
The generated page is rendered inside an iframe, providing a safe and isolated environment for running your HTML, CSS, and JavaScript.
The Download ZIP feature creates a complete web project containing
- index.html
- style.css
- script.js
The HTML file is automatically linked with the CSS and JavaScript files, allowing the downloaded project to run immediately after extraction.
The interface is designed to work on different screen sizes.
- Desktop
- Laptop
- Tablet
- Mobile (basic support)
Some possible future enhancements include:
- ๐ Dark / Light Mode
- ๐ Open Existing Project
- ๐ Multiple Files Support
- ๐ Search & Replace
- ๐ Theme Selection
- ๐๏ธ Font Size Controls
- ๐ค Shareable Project Links
- โ๏ธ Cloud Storage
- ๐ Auto Formatting (Prettier)
- ๐ฅ Console Output Panel
- ๐ Copy Project to Clipboard
- ๐งฉ Additional Language Support (TypeScript, SCSS, Markdown)
Contributions are welcome!
- Fork the repository.
- Create a new branch.
git checkout -b feature-name- Commit your changes.
git commit -m "Added new feature"- Push to GitHub.
git push origin feature-name- Open a Pull Request.
- Browser security restrictions apply to code executed inside the preview iframe.
- JavaScript errors written by the user will appear in the browser console.
- Very large projects are not intended to run inside this lightweight editor.
This project is only for educational pursose.
Shuvom Dhar
GitHub: https://github.com/shuvomdhar
LinkedIn: https://linkedin.com/in/shuvom-dhar