---
title: "Lamp | LemonadeJS v3"
description: "LemonadeJS v3 archive. A simple state change example using LemonadeJS."
source: https://lemonadejs.com/docs/v3/examples/lamp/
---

Lamp
====

A LemonadeJS `{self}` property value will be synchronized with the HTML attribute.  
  

A working example
-----------------

  
  

### Source code

  
```html
<html>
<script src="https://cdn.jsdelivr.net/npm/lemonadejs@3/dist/lemonade.js"></script>
<div id='root'></div>
<script>
function Lamp() {
    const self = this;
    return `<>
        <img src="/img/example-lamp-{{self.state?'on':'off'}}.jpg">
        <br/>
        <input type="button" onclick="self.state = 1" value="Light on" />
        <input type="button" onclick="self.state = 0" value="Light off" />
    </>`;
}
lemonade.render(Lamp, document.getElementById('root'));
</script>
</html>
```
```javascript
import lemonade from 'lemonadejs';

export default function Lamp() {
    const self = this;
    return `<>
        <img src="/img/example-lamp-{{self.state?'on':'off'}}.jpg">
        <br/>
        <input type="button" onclick="self.state = 1" value="Light on" />
        <input type="button" onclick="self.state = 0" value="Light off" />
    </>`;
}
```

  
[See this example on codesandbox](https://codesandbox.io/s/reactive-javascript-library-83xmr7)