Document how to write CustomComponent setter that works with and without `yield` or how to animate change of `SignalValue`

Author: MaPePeRCreated Aug 10, 2025Updated Aug 10, 2025
Labelsb-documentation

Description The Documentation for custom components has an example of a toggle method that animates turning the toggle on and off.

It would be great, if there would also be an example for a state(toggled: bool, duration?: number) function that can be used for just immedietly setting the value, so it can be just called with state(false) instead of yield* state(false, 0), but can also be called with yield* state(false, 0.6) to animate it like toggle does?

So similar how all the provided position, opacity, etc. functions work.

Its probably easily possible with a state: SignalValue/SimpleSignal? But I couldn't figure it out and an example would be great to have.

Thank you for the amazing software!

Source: motion-canvas/motion-canvas