Skip to content

UI Mount Guide

When to use

Use this page when you want BerryPickr's default UI and need precise behavior around popovers, inline mode, focus, visibility, and runtime updates.

Quick example

ts
import { createBerryPickrController, mountBerryPickrUI } from '@appberry/berrypickr';
import '@appberry/berrypickr/styles/base.css';

const controller = createBerryPickrController({ defaultValue: '#486dff' });

const mount = mountBerryPickrUI(controller, {
  target: '#color-trigger',
  mode: 'popover',
  closeOnOutsideClick: true,
  closeOnEscape: true,
  autoReposition: true
});

mount.show();

Options/Methods

BerryPickrUIOptions

OptionTypeDefaultBehavior
targetstring | HTMLElementrequiredTrigger or inline anchor element
containerstring | HTMLElementdocument.bodyHost container for popover app node
mode'popover' | 'inline''popover'Rendering strategy
showAlwaysbooleanfalseForces open behavior (also true in inline mode)
closeOnEscapebooleantrueEscape key close for popover mode
closeOnOutsideClickbooleantrueOutside pointer close for popover mode
closeOnScrollbooleanfalseClose popover when scroll detected
autoRepositionbooleantrueRepositions open popover
adjustableInputNumbersbooleantrueEnables numeric keyboard/wheel adjustments in input controller
componentsPartial<BerryPickrComponents>all trueToggles preview/palette/hue/alpha/input/save/cancel/clear
i18nPartial<BerryPickrI18n>built-in labelsOverrides ARIA labels and button text

Mode matrix

ModePlacementOpen behaviorTypical use
popoverAppended to containerToggle via trigger; can auto-closeForm controls and settings panels
inlineInserted after targetAlways visible while not disabledEmbedded editors and side panes

showAlways in popover mode behaves similarly to inline visibility: if not disabled, the UI remains open.

BerryPickrUIMount methods

MethodReturnsNotes
show()booleanRequests controller open state
hide()booleanHidden only when not force-open (inline/showAlways)
isOpen()booleanReflects effective open state
getController()BerryPickrControllerAccess attached controller
update(next)voidLive updates options without remounting
focus(part?)booleanFocuses palette/hue/alpha/input if visible
destroy({ remove? })voidDestroys listeners/controllers and optionally removes app node

mount.update() constraints

mount.update() cannot change:

  • target
  • container

Attempting either throws an error. Remount instead:

ts
mount.destroy({ remove: true });
const nextMount = mountBerryPickrUI(controller, {
  target: '#new-trigger',
  container: '#new-overlay-host',
  mode: 'popover'
});

Component visibility and i18n

ts
mount.update({
  components: {
    clear: false,
    cancel: false
  },
  i18n: {
    toggle: 'Open color editor',
    dialog: 'Brand color picker dialog'
  }
});

Gotchas

  • Missing target selector throws during mount creation.
  • Popover close behaviors are ignored in inline mode.
  • hide() returns false when UI is force-open by mode/settings.