#1578·valibot

Support console.clear in playground

Author: mootariCreated Aug 5, 2026Updated Aug 5, 2026
Labelsenhancement

Clearing the playground log output currently requires clicking the Clear button or pressing Meta+Backspace.

When prototyping it's a fairly common practice to include console.clear() in one's code to automatically clear the console on every rerun. Sadly this has no effect in the playground because the iframe only forwards standard console levels (log, warn, etc).

Proposed solution

  1. In the iframe context, override console.clear to instead send a message of type "clear" to the parent context: https://github.com/open-circle/valibot/blob/e789528650716333ecef5cc60188e0d7489d89b0/website/src/routes/playground/iframeCode.js#L129-L136
  2. When receiving a message of type "clear" in the parent context, invoke clearLogs(): https://github.com/open-circle/valibot/blob/e789528650716333ecef5cc60188e0d7489d89b0/website/src/routes/playground/index.tsx#L170-L174