Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-5-sonnet-20241022· AnthropicHugging Face LMArena Human Preference 140K

svelte 5 counter component

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-235b-a22b-no-thinking’s answer.
  1. User

    svelte 5 counter component

  2. Claude Assistant

    I'll help you create a simple counter component in Svelte 5, which introduces some new features like runes. Here's a basic implementation:

    <script>
      import { $state } from 'svelte';
      
      let count = $state(0);
      
      function increment() {
        count++;
      }
      
      function decrement() {
        count--;
      }
    </script>
    
    <div class="counter">
      <button on:click={decrement}>-</button>
      <span>{count}</span>
      <button on:click={increment}>+</button>
    </div>
    
    <style>
      .counter {
        display: flex;
        gap: 1rem;
        align-items: center;
      }
      
      button {
        padding: 0.5rem 1rem;
        font-size: 1.2rem;
      }
      
      span {
        font-size: 1.5rem;
      }
    </style>
    

    Key differences from Svelte 4:

    • Uses the new $state rune instead of the previous reactive declarations
    • No need for $: reactive statements for this simple case
    • State management is more explicit with the rune system

    Would you like me to explain any part of this code in more detail or show you how to add more features to the counter?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.