Email or username:

Password:

Forgot your password?
Top-level
Simon Willison

Released an improved version that uses the built-in browser dialog.showModal() method - it's just 4.47KB now, 1.1KB minified and gzipped github.com/simonw/prompts-js/r

2 comments
Simon Willison

Added some notes on things I've learned from hacking on this project (using o1 and Claude 3.5 Sonnet): simonwillison.net/2024/Dec/7/p

Plus a TIL about publishing to NPM using GitHub Actions and GitHub Releases: til.simonwillison.net/npm/npm-

The const name = await askUserSomething() pattern really does work, and it feels great. I love the idea of being able to await a potentially lengthy user interaction like this.
HTML <dialog> elements are usable across multiple browsers now.
Using a <dialog> means you can skip implementing an overlay that dims out the rest of the screen yourself—that will happen automatically.
A <dialog> also does the right thing with respect to accessibility and preventing keyboard access to other elements on the page while that dialog is open.
If you set <form method="dialog"> in a form inside a dialog, submitting that form will close the dialog automatically.
The dialog.returnValue will be set to the value of the button used to submit the form.
Jmelloy

@simon const blah = await is great, except for the 999 pull requests I have for “whoops, missed an await”.

Go Up