Development
Web Artifacts Builder
Build interactive web artifacts and components. Use when users need self-contained HTML, React components, or interactive web elements.
Build interactive web artifacts and components. Use when users need self-contained HTML, React components, or interactive web elements.
Build interactive web artifacts and self-contained components.
Self-contained HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Artifact Title</title>
<style>
/* All styles inline */
</style>
</head>
<body>
<!-- Content -->
<script>
// All JavaScript inline
</script>
</body>
</html>
Component Structure:
function MyComponent({ prop1, prop2 }) {
const [state, setState] = useState(initialValue);
return (
<div className="container">
{/* Component content */}
</div>
);
}
Define the Artifact:
Component Architecture:
HTML Artifact:
<!DOCTYPE html>
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: system-ui, sans-serif;
padding: 2rem;
}
</style>
</head>
<body>
<div id="app"></div>
<script>
const app = document.getElementById('app');
// Interactive logic
</script>
</body>
</html>
React Artifact:
function App() {
const [count, setCount] = useState(0);
return (
<div>
<h1>Counter: {count}</h1>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</div>
);
}
Cross-browser Testing:
Performance Optimization:
<!DOCTYPE html>
<html>
<head>
<style>
.dashboard {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
}
.card {
padding: 1.5rem;
border: 1px solid #e5e5e5;
border-radius: 0.5rem;
}
</style>
</head>
<body>
<div class="dashboard" id="dashboard"></div>
<script>
// Dashboard logic
</script>
</body>
</html>
function Form() {
const [formData, setFormData] = useState({
name: '',
email: ''
});
const handleSubmit = (e) => {
e.preventDefault();
console.log(formData);
};
return (
<form onSubmit={handleSubmit}>
<input
type="text"
value={formData.name}
onChange={(e) => setFormData({...formData, name: e.target.value})}
placeholder="Name"
/>
<input
type="email"
value={formData.email}
onChange={(e) => setFormData({...formData, email: e.target.value})}
placeholder="Email"
/>
<button type="submit">Submit</button>
</form>
);
}