Bindings
React uses controlled inputs: you set value={state} and update it yourself in onChange. This is deliberate — one-way data flow keeps state changes explicit. Svelte offers bind:value for two-way binding, which wires the input and the variable together automatically. There is no direct React equivalent — it is a genuine Svelte superpower.
Text input: controlled vs bind:value
Section titled “Text input: controlled vs bind:value”function NameForm() { const [name, setName] = React.useState(''); return ( <> <input value={name} onChange={e => setName(e.target.value)} placeholder="Your name" /> <p>Hello, {name || 'stranger'}!</p> </> );}<script> let name = $state('');</script>
<input bind:value={name} placeholder="Your name" /><p>Hello, {name || 'stranger'}!</p>bind:value replaces both value={name} and onChange={e => setName(e.target.value)} in a single directive.
Checkbox: bind:checked
Section titled “Checkbox: bind:checked”function Opt() { const [agreed, setAgreed] = React.useState(false); return ( <label> <input type="checkbox" checked={agreed} onChange={e => setAgreed(e.target.checked)} /> I agree </label> );}<script> let agreed = $state(false);</script>
<label> <input type="checkbox" bind:checked={agreed} /> I agree</label><p>Agreed: {agreed}</p>Select / dropdown
Section titled “Select / dropdown”function Picker() { const [color, setColor] = React.useState('red'); return ( <select value={color} onChange={e => setColor(e.target.value)}> <option value="red">Red</option> <option value="green">Green</option> <option value="blue">Blue</option> </select> );}<script> let color = $state('red');</script>
<select bind:value={color}> <option value="red">Red</option> <option value="green">Green</option> <option value="blue">Blue</option></select><p>Chosen: {color}</p>