minimax-m1 LMArena Human Preference 140K
Write a basic svelte 5 counter component
- User
Write a basic svelte 5 counter component
- Assistant
Here's a modern Svelte 5 counter component with clean styling:
<script> let count = $state(0); const increment = () => count++; const decrement = () => count--; </script> <div class="counter-container"> <h2>Interactive Counter</h2> <div class="counter-display">{count}</div> <div class="button-group"> <button class="btn-decrement" onclick={decrement}>-</button> <button class="btn-increment" onclick={increment}>+</button> </div> </div> <style> .counter-container { max-width: 400px; margin: 2rem auto; padding: 2rem; background: #ffffff; border-radius: 16px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); text-align: center; } h2 { color: #1e293b; margin-bottom: 1.5rem; font-size: 1.5rem; } .counter-display { font-size: 3rem; font-weight: 700; color: #334155; margin: 1.5rem 0; } .button-group { display: flex; gap: 1rem; justify-content: center; } button { padding: 0.75rem 1.5rem; border: none; border-radius: 8px; font-size: 1.2rem; cursor: pointer; transition: all 0.2s ease; } .btn-increment { background: #3b82f6; color: white; } .btn-decrement { background: #ef4444; color: white; } button:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); } button:active { transform: translateY(0); } </style>This component features:
- Clean, modern UI with shadow and rounded corners
- Responsive design
- Smooth hover animations
- Clear color-coded buttons
- Proper spacing and typography
- Reactive state management using Svelte 5 runes
- Single-file component structure
To use this component:
- Save it as
Counter.svelte - Import into your Svelte app
- Place inside your main component or page
The counter will automatically update when clicking the buttons, with visual feedback through button animations. The styling uses a neutral background with accent colors for the buttons, making it easy to integrate into any design system.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.