SwiftUI.js
Components

PhotosPicker

PhotosPicker opens an image-only asset chooser and forwards selected files, keeping SwiftUI's media selection intent while relying on the browser's native file picker.

PhotosPicker opens an image-only asset chooser and forwards selected files, keeping SwiftUI's media selection intent while relying on the browser's native file picker.

Examples

Examples

Preview unavailable for this example in the static docs build.

Examples

Preview unavailable for this example in the static docs build.

Show code
<PhotosPicker maxSelectionCount={4}>Choose gallery items</PhotosPicker>

Examples

Preview unavailable for this example in the static docs build.

Show code
<PhotosPicker matching="videos" maxSelectionCount={2}>Choose clips</PhotosPicker>

API

PropTypeRequiredDescription
selectionLimitnumberNoMaximum number of selected items. Values above 1 enable multi-select.
maxSelectionCountnumberNoSwiftUI-aligned alias for the maximum number of selected items.
matching'images' | 'videos' | 'any'NoPreferred media type filter. Default: 'images'
onSelect(files: Array<globalThis.File>) => voidYesCalled with the selected image files.

Inherits additional props from Omit<IBaseElementComponent<'button'>, 'type' | 'onSelect'>.

PhotosPicker opens an image-only asset chooser and forwards selected files, keeping SwiftUI's media selection intent while relying on the browser's native file picker.

Status: adapted

SwiftUI Correspondence: Adapted from SwiftUI's PhotosPicker.

Notes

  • The current web implementation selects image files via a hidden input[type="file"].
  • maxSelectionCount and matching are the preferred SwiftUI-aligned props.
  • selectionLimit trims the forwarded files to the requested maximum when the SwiftUI alias is not provided.
  • The hidden input resets after each selection so the same asset can be chosen again.
  • The browser controls the actual picker UI.

On this page