ColorPickerField
Text field input that opens a ColorPicker in a dropdown menu. The selected colour is displayed as a swatch inside the field prefix.
Aperçu
Rendu de l’aperçu en cours…
defaultRendu de l’aperçu en cours…
outlinedRendu de l’aperçu en cours…
disabledStructure
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<origam-color-picker-field> — 4 visual parts.- 1.origam-color-picker-field
- Root element — extends OrigamTextField with a colour swatch prefix.
- 2.origam-color-picker-field__swatch
- Small coloured square inside the input prefix. Shows the current selected colour. Clicking opens the picker.
- 3.origam-text-field__input
- Editable text input showing the colour value (hex string). Clearing triggers openOnClear if enabled.
- 4.origam-color-picker-field__chevron
- Append icon indicating the dropdown can be opened.
API
Props
Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.
- menuboolean
- Controls whether the colour picker popover is open.
- menuPropsIMenuProps
- Props forwarded to the inner OrigamMenu component.
- openOnClearboolean
- Re-opens the picker dropdown when the field value is cleared.
- closeTextstring
- Accessible label for the close action inside the picker popover.
- openTextstring
- Accessible label for the open action inside the picker popover.
- closeOnSelectboolean
- Closes the picker popover automatically when a colour is selected.
- autofocusboolean
- counterboolean | number | string
- counterValuenumber | ((e: any) => number)
- placeholderstring
- Placeholder text shown when the field is empty.
- persistentPlaceholderboolean
- persistentCounterboolean
- rolestring
- typeTTextFieldType
- modelModifiersstring | boolean
- maskTMask
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- colorTColor
- Intent or custom colour applied to the active/focused field state.
- densityTDensity'default'
- Adjusts the vertical padding density of the field.
- centerAffixboolean
- dirtyboolean
- disabledbooleanfalse
- Disables the field and prevents opening the picker.
- errorstring | boolean
- inlineboolean
- labelstring
- Floating label displayed above the field.
- prefixstring
- suffixstring
- persistentClearboolean
- singleLineboolean
- requiredboolean
- loadingTControlLoadingValue
- tagstring
- loadingTextstring
- bgColorTColor
- appendInnerAvatarstring
- appendInnerIconTIcon
- prependInnerAvatarstring
- prependInnerIconTIcon
- clearIconTIcon
- clearablebooleanfalse
- Displays a clear icon to reset the selected colour.
- prependInnerAriaLabelstring
- appendInnerAriaLabelstring
- borderboolean | number | string | TDirectionBoth | Array<TDirectionBoth>false
- Applies an explicit border to the field.
- borderTopboolean | number | string
- borderLeftboolean | number | string
- borderBottomboolean | number | string
- borderRightboolean | number | string
- borderBlockboolean | number | string
- borderInlineboolean | number | string
- borderInlineStartboolean | number | string
- borderInlineEndboolean | number | string
- borderBlockStartboolean | number | string
- borderBlockEndboolean | number | string
- borderColorstring
- borderStylestring
- borderTopColorTColor
- borderRightColorTColor
- borderBottomColorTColor
- borderLeftColorTColor
- borderInlineStartColorTColor
- borderInlineEndColorTColor
- borderBlockStartColorTColor
- borderBlockEndColorTColor
- focusedboolean
- textstring
- floatingboolean
- namestring
- marginboolean | number | string
- marginTopboolean | number | string
- marginLeftboolean | number | string
- marginBottomboolean | number | string
- marginRightboolean | number | string
- marginBlockboolean | number | string
- marginInlineboolean | number | string
- marginInlineStartboolean | number | string
- marginInlineEndboolean | number | string
- marginBlockStartboolean | number | string
- marginBlockEndboolean | number | string
- paddingboolean | number | string
- paddingTopboolean | number | string
- paddingLeftboolean | number | string
- paddingBottomboolean | number | string
- paddingRightboolean | number | string
- paddingBlockboolean | number | string
- paddingInlineboolean | number | string
- paddingInlineStartboolean | number | string
- paddingInlineEndboolean | number | string
- paddingBlockStartboolean | number | string
- paddingBlockEndboolean | number | string
- roundedboolean | number | string | TRounded | null | undefined
- Border-radius token for the field wrapper.
- roundedTopRightboolean | number | string
- roundedTopLeftboolean | number | string
- roundedBottomLeftboolean | number | string
- roundedBottomRightboolean | number | string
- roundedStartStartboolean | number | string
- roundedStartEndboolean | number | string
- roundedEndStartboolean | number | string
- roundedEndEndboolean | number | string
- fontSizeTFontSize
- fontWeightTFontWeight
- lineHeightTLineHeight
- letterSpacingTLetterSpacing
- activeboolean | IStateEffectConfig
- activeClassstring
- variantTVariantInput'outlined'
- Visual style variant for the field wrapper.
- elevationTElevation
- sizeTSize | number
- hideDetailsboolean | string
- hideSpinButtonsboolean
- hintstring
- persistentHintboolean
- messagesArray<string> | string
- heightnumber | string
- maxHeightnumber | string
- maxWidthnumber | string
- minHeightnumber | string
- minWidthnumber | string
- widthnumber | string
- directionTDirection
- errorMessagesArray<string> | string
- maxErrorsnumber | string
- readonlybooleanfalse
- Makes the field non-interactive without visually disabling it.
- rulesArray<any>
- modelValueany
- Current colour value (v-model). CSS colour string, e.g. "#ff0080" or "hsl(320, 100%, 50%)".
- validateOnTValidateOn
- validationValueany
- appendAvatarstring
- appendIconTIcon
- prependAvatarstring
- prependIconTIcon
- prependAriaLabelstring
- appendAriaLabelstring
- transitionboolean | string | TTransitionProps
API
Slots
Emplacements de contenu exposés par ce composant.
- #colorSelection
- #label
- Custom label content. Overrides the label prop.
- #clear
- #prependInner
- Content placed inside the field before the input (swatch area).
- #appendInner
- Content placed inside the field after the input.
- #loader
- Custom loader shown inside the field when loading is true.
- #floatingLabel
- #prefix
- #suffix
- #prepend
- Content placed before the field (outside the field wrapper).
- #append
- Content placed after the field (outside the field wrapper).
API
Emits
Événements émis par ce composant.
- @update:modelValueTColor
- Fired when the selected colour changes. Payload is the new colour string.
- @update:menuboolean
- Fired when the picker popover opens or closes.
- @click:clearMouseEvent
- Fired when the user clicks the clear icon.
API
Membres exposés
Propriétés et méthodes accessibles via ref template (defineExpose). Utilisés pour le contrôle programmatique.
- <T extends object>(props: T, exclude?: string[]) => Partial<T>
- Utility to forward a filtered subset of props to OrigamTextField.
- Ref<boolean>
- True while the field is focused.
- Ref<boolean>
- Controls the picker popover open state programmatically.
- Ref<string>
- Reactive CSS string generated by useStyle.
- string
- Unique style-sheet ID for this instance.
- () => void
- Injects the computed style sheet into the document.
- () => void
- Removes the injected style sheet.
- Ref<boolean>
- True once the style sheet has been injected.
Personnalisation
Variables CSS
Propriétés CSS personnalisées exposées par ce composant. Surchargez-les pour personnaliser sans perdre la compatibilité avec le thème.
- Minimum width of the field.
- Width of the colour swatch inside the input.
- Height of the colour swatch.
- Border radius of the colour swatch.
- Colour of the dropdown chevron icon.
- Colour of the chevron icon on hover.
Inclusion
Accessibilité
Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.
Rôles ARIA
Interactions clavier
| Touche | Action |
|---|---|
| Enter / Space | Opens the colour picker popover. |
| Escape | Closes the colour picker popover without applying changes. |
| Tab | Moves focus into or out of the picker panel when open. |
Notes
- The field behaves as a combobox: aria-haspopup="dialog" and aria-expanded reflect the popover open state.
- The colour swatch is decorative (aria-hidden="true"). The accessible value is provided by the text input which holds the hex string.
Fondation
Design tokens
Extrait des tokens de ce composant — les variables --origam-<composant>---<propriété>, déclarées dans sa feuille de tokens tenue à la main, sans étape de build.
- dimension200px
- Minimum field width.
- dimension24px
- Swatch width.
- dimension24px
- Swatch height.
- dimensionvar(--origam-radius---sm)
- Swatch corner radius.
- colorvar(--origam-color__text---secondary)
- Chevron icon colour.
Interactif
Playground
Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.
Rendu de l’aperçu en cours…
Usage
Exemples
Extraits de code prêts à coller dans vos templates.
Basic usage
Close on select