Fragiola

API: components

ColorPickerPopover

A ColorPicker's opt-in popup, a trigger and a non-modal dialog on Popover's overlay lifecycle, in each framework.

Open a ColorPicker in a popover: a Trigger (showing a ColorSwatch of the color) and a non-modal dialog (Popover's) holding the controls, placed inside the picker's Root, so the form keeps the color while the popup is closed. It is its own entry: an inline picker never bundles it.

Theme color picker
Gallery

Behaviour

  • Focus: on open, the popup's first tabbable control; not trapped; Tab from its last control moves past the trigger and closes it, Shift+Tab from its first returns to the trigger.
  • Dismissal: Escape (focus back on the trigger), a press outside (focus back on the trigger unless the press focused something), focus leaving.
  • Placement: below the trigger, aligned to its start, flipping and shifting to stay in view.
  • Disabled with its picker: the Trigger opens nothing.

Anatomy

partelementdata-primitives-partrole
Rootnoneholds the open state
Triggerbuttoncolor-picker-popover-triggertoggles the popup
Portalnonemoves the Positioner to the body
Positionerdivcolor-picker-popover-positionerplaces the popup
Popupdivcolor-picker-popover-popupthe non-modal dialog

Usage

import { ColorPicker } from "@fragiola/primitives-react/color-picker";
import { ColorPickerPopover } from "@fragiola/primitives-react/color-picker-popover";
import { ColorSwatch } from "@fragiola/primitives-react/color-swatch";

<ColorPicker.Root name="accent" defaultValue="#336699">
    <ColorPickerPopover.Root>
        <ColorPickerPopover.Trigger aria-label="Accent color">
            <ColorSwatch />
        </ColorPickerPopover.Trigger>
        <ColorPickerPopover.Portal>
            <ColorPickerPopover.Positioner sideOffset={8}>
                <ColorPickerPopover.Popup aria-label="Accent color picker">
                    {/* ColorArea, ColorSlider, ColorField... */}
                </ColorPickerPopover.Popup>
            </ColorPickerPopover.Positioner>
        </ColorPickerPopover.Portal>
    </ColorPickerPopover.Root>
</ColorPicker.Root>;

Props

Every part also takes what the primitive contract gives. The names below are React's; Vue binds them the same way (v-model:open), and Angular as inputs and outputs ([(open)], (openChangeDetails)).

Root

proptypedefaultdescription
openbooleanopen, controlled
defaultOpenbooleanfalseopen at first, uncontrolled
onOpenChange(open, details: OpenChangeDetails) => voidbefore it opens or closes (trigger-press, escape-key, outside-press, focus-out)
onOpenChangeComplete(open) => voidits transition finished
actionsRef (react){ current: OverlayActions | null }close(), unmount()

Trigger

No props of its own.

Portal

proptypedefaultdescription
container (react, vue)Elementthe bodywhere the Positioner moves
keepMounted (react, vue)booleanfalsestays mounted while closed
options (angular)Element | { container?, keepMounted? }{}the same two options: *colorPickerPopoverPortal="{ keepMounted: true }"

Positioner

proptypedefaultdescription
sideSide"bottom"the side of the trigger
alignAlign"start"the alignment on that side
sideOffsetnumber0px from the trigger
alignOffsetnumber0px along the side
collisionPaddingnumber8px kept from the viewport's edges
anchorHTMLElementthe Triggerwhat it is placed against

No props of its own; name it with aria-label or aria-labelledby.

State and part attributes

partattributes
Triggeraria-haspopup="dialog", aria-expanded, aria-controls, data-popup-open, data-disabled
Positionerrole="presentation", data-side, data-align, data-open, data-closed, its CSS variables
Popuprole="dialog", tabindex="-1", data-side, data-align, data-open, data-closed, data-starting-style, data-ending-style

Keyboard

keyaction
Enter, Space on the Triggertoggles the popup
Tabmoves through the popup; from its last control, to the element after the trigger, closing it
Shift+Tabfrom its first control, back to the trigger, closing it
Escapecloses it and focuses the trigger

Exports

entryexports
@fragiola/primitives-react/color-picker-popoverAlign, ChangeDetails, ChangeReason, ColorPickerPopover, ColorPickerPopoverPopupProps, ColorPickerPopoverPopupState, ColorPickerPopoverPortalProps, ColorPickerPopoverPositionerProps, ColorPickerPopoverPositionerState, ColorPickerPopoverRootProps, ColorPickerPopoverTriggerProps, ColorPickerPopoverTriggerState, OpenChangeDetails, OverlayActions, OverlayPortalProps, OverlayRootProps, PositionerProps, RenderProp, Side
@fragiola/primitives-vue/color-picker-popoverAlign, ChangeDetails, ChangeReason, ColorPickerPopover, ColorPickerPopoverPopupProps, ColorPickerPopoverPopupState, ColorPickerPopoverPortalProps, ColorPickerPopoverPositionerState, ColorPickerPopoverRootEmits, ColorPickerPopoverRootProps, ColorPickerPopoverTriggerProps, ColorPickerPopoverTriggerState, OpenChangeDetails, OverlayActions, OverlayPortalProps, OverlayRootEmits, OverlayRootProps, PositionerProps, RenderSlotProps, Side
@fragiola/primitives-angular/color-picker-popoverAlign, ChangeDetails, ChangeReason, ColorPickerPopoverPopup, ColorPickerPopoverPopupState, ColorPickerPopoverPortal, ColorPickerPopoverPositioner, ColorPickerPopoverPositionerState, ColorPickerPopoverRoot, ColorPickerPopoverState, ColorPickerPopoverTrigger, OpenChangeDetails, OpenChangeEvent, OverlayActions, OverlayPortalOptions, Side