Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently Puter UI API elements such as puter.ui.contextMenu doesn't work when env is web. Here we have fallback for that using web components.
Puter Web Components
A suite of web components bundled with the Puter SDK (
puter.js) so UI works in any environment — apps running standalone, as PWAs, on their own domain, or inside puter.com.How they work
Load
puter.js, and the components auto-register. You can then either:puter.ui.alert(...),puter.ui.contextMenu(...)etc. The SDK renders the right component automatically.All components use Shadow DOM so their styles won't leak into your page. Theming is via CSS custom properties (see Theming below).
Component Reference
<puter-alert>puter.ui.alert()<puter-prompt>puter.ui.prompt()<puter-notification>puter.ui.notify()<puter-context-menu>puter.ui.contextMenu()<puter-menubar>puter.ui.setMenubar()<puter-spinner>puter.ui.showSpinner()/hideSpinner()<puter-color-picker>puter.ui.showColorPicker()<puter-font-picker>puter.ui.showFontPicker()<puter-alert>Modal alert with customizable buttons and optional type icon. Uses native
<dialog>element (focus trap, Escape to close, backdrop).Attributes
messagetypeerror|warning|info|success|confirmProperties
buttons[{ label, value?, type? }].typecan beprimary,danger,success,warning,info,default. Last button is primary by defaultoptionsEvents
responseExample
<puter-prompt>Modal dialog with a text input. Enter submits, Escape cancels.
Attributes
messageplaceholderdefault-valueProperties
optionsEvents
responsefalseif cancelledExample
<puter-notification>Toast notification in the top-right corner with frosted-glass background. Auto-dismisses after
durationms. Multiple notifications stack vertically.Attributes
titletexticontypeis shown)round-icontypeinfo|success|warning|errorduration5000,0= never auto-dismiss)Events
click{}close{}Example
<puter-context-menu>Positioned menu with nested submenus, icons, keyboard shortcuts, and optional danger-styled items. On mobile (≤480px or coarse pointer), automatically switches to a bottom action sheet with backdrop.
Attributes
xydata-submenuProperties
itemsItem schema
labelicon<) or image URLactionitemsdisabledtypedangerdangertype: 'danger'shortcut'⌘C')checkedseparator'-'as the item)Events
selectclose{}Example
<puter-menubar>Fixed top-of-page application menubar. Clicking an item opens its dropdown (rendered via
<puter-context-menu>). Hover switches dropdowns while one is open.Properties
itemsEvents
selectExample
<puter-spinner>Full-page loading overlay with a spinner and optional message.
Attributes
textMethods
open()close()Example
<puter-color-picker>Modal color picker with 80 preset swatches, a hex input, and a native HTML5 color input for arbitrary colors.
Attributes
default-color#3b82f6)Events
responsenullif cancelledExample
<puter-font-picker>Modal font picker with curated web-safe fonts grouped by category (System, Sans Serif, Serif, Monospace, Cursive). Has search and live preview. Double-click a font to select and close.
Attributes
default-font'Georgia')Events
response{ fontFamily: string }| nullfont-familystack), ornullif cancelledExample
Styling
All components render inside Shadow DOM and match puter.com's native GUI appearance. Styles are encapsulated and cannot be overridden from outside the component.
Dark mode
Components with
@media (prefers-color-scheme: dark)rules auto-adapt when the OS is in dark mode:<puter-notification>,<puter-context-menu>,<puter-menubar>,<puter-color-picker>,<puter-font-picker>.Responsive / mobile
All components have mobile breakpoints at
@media (max-width: 480px). Notable behaviors: