Files
puter/src/docs/src/UI/showFontPicker.md
T
sabrimete cdb3110857
Backend Tests / changes (push) Waiting to run
Maintain Release Merge PR / update-release-pr (push) Waiting to run
Notify HeyPuter / notify (push) Waiting to run
release-please / release-please (push) Waiting to run
fix(ui): honor the default font in showFontPicker on the desktop (#4340)
* fix(ui): honor the default font in showFontPicker on the desktop

String arguments are normalized to { defaultFont } in the IPC handler,
matching showColorPicker, instead of throwing on property assignment.
UIWindowFontPicker reads defaultValue/defaultFont/default case-
insensitively, and the SDK fallback and docs accept the same aliases.

* fix(ui): document the showFontPicker cancel result and alias order

The JSDoc gains overloads for the string and options call forms and
states that closing the picker resolves false in an app and null on a
website; the docs page and examples match. e2e coverage adds a
scroll-into-view check for the preselected font and a close-without-
selecting case.
2026-11-03 00:07:05 -07:00

1.4 KiB
Executable File

title, description, platforms
title description platforms
puter.ui.showFontPicker() Presents a list of fonts for previewing and selecting.
websites
apps

Presents the user with a list of fonts allowing them to preview and select a font.

Syntax

puter.ui.showFontPicker()
puter.ui.showFontPicker(defaultFont)
puter.ui.showFontPicker(options)

Parameters

defaultFont (String)

The default font to select when the font picker is opened.

options (Object)

An object with the following properties:

  • defaultFont (String): The font to select when the font picker is opened. The name is matched without regard to case. defaultValue and default are accepted as aliases. If more than one is given, defaultValue is used, then defaultFont, then default.

Return value

A Promise that resolves to an object with a fontFamily property holding the name of the selected font. If the user closes the picker without selecting a font, the promise resolves to false in a Puter app and to null on a website.

Examples

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <h1>A cool Font Picker demo!</h1>

    <script>
        puter.ui.showFontPicker().then((font)=>{
            if (font) {
                document.body.style.fontFamily = font.fontFamily;
            }
        })
    </script>
</body>
</html>