# How to have a simple pushbutton toggle bits

**URL:** <https://forum.inductiveautomation.com/t/how-to-have-a-simple-pushbutton-toggle-bits/103142>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [March 3, 2025, 1:41pm UTC](https://forum.inductiveautomation.com/t/how-to-have-a-simple-pushbutton-toggle-bits/103142 "2025-03-03T13:41:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris4](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@chris4](https://forum.inductiveautomation.com/u/chris4)\
**Post date:** [March 3, 2025, 1:41pm UTC](https://forum.inductiveautomation.com/t/how-to-have-a-simple-pushbutton-toggle-bits/103142/1 "2025-03-03T13:41:35Z")

</div>

I am new to ignition perspective and I am trying to get a script for having a pushbutton toggle a bit when clicked, any help is appreciated.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 3, 2025, 1:45pm UTC](https://forum.inductiveautomation.com/t/how-to-have-a-simple-pushbutton-toggle-bits/103142/2 "2025-03-03T13:45:53Z")

</div>

Something like:

```python
YourTag = not YourTag

```

Edit, this assumes you have a custom prop named `YourTag`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 3, 2025, 2:16pm UTC](https://forum.inductiveautomation.com/t/how-to-have-a-simple-pushbutton-toggle-bits/103142/3 "2025-03-03T14:16:56Z")

</div>

To elaborate a bit more:

- Create a custom property on your button, call it `target` or something meaningful for your purpose.
- Bind that custom property to your boolean tag, and set it to be **bidirectional**.
- Add an `actionPerformed` script to your button with this:

```python
	self.custom.target = not self.custom.target

```

Edit: You may also want to look at the toggle button component....

---

<div class="post-metadata">

**Author:** ![chris4](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@chris4](https://forum.inductiveautomation.com/u/chris4)\
**Post date:** [March 3, 2025, 3:47pm UTC](https://forum.inductiveautomation.com/t/how-to-have-a-simple-pushbutton-toggle-bits/103142/4 "2025-03-03T15:47:24Z")

</div>

Perfect I got it thank you.
