生态产品多个设计器现已发布候选版本

查看生态总览
Skip to content

ColorSwatch ​

Data display component. This page is the API reference, generated from the source code. Usage guidance and live examples are on the Chinese page.

Anatomy ​

Parts in bold are required.

data-scope="color-swatch": root

API reference ​

Descriptions of individual props, events and slots are written in Chinese and appear on the Chinese page.

Artifacts ​

LayerValue
Custom element<xh-color-swatch>
Vue componentsXhColorSwatch
State machineNone: connect computes attributes from props directly
Skin@xihan-ui/styles/color-swatch.css

Props ​

PropTypeRequired
labelstring
sizeSize
valuestring

connect API ​

getXxxProps() returns the host attributes of the matching part.

MemberType
valuestring
validboolean
rgbaColorRgba
cssstring
getRootProps() => T['element']

Accessibility ​

Keyboard ​

Specification: W3C APG. Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

No keyboard interaction: the component takes no focus, or focus behavior comes entirely from native elements.

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-hiddenundefined | 'true'
rootaria-labelprops.label
rootrole'img' | undefined

Style reference ​

Skin ​

@xihan-ui/styles/color-swatch.css is written against [data-scope="color-swatch"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-color-swatch in place of data-scope (same specificity) and sits in the xihan.components layer. Put overrides in xihan.overrides; the part selectors work as usual.

Data attributes ​

Produced by connect; valueless attributes are omitted while their condition does not hold.

PartAttributeValue
rootdata-invalid'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-valuevalue || undefined
rootdata-xh-swatch''
rootdata-xh-swatch-sizeprops.size

CSS variables ​

The public override slots, generated from what the standalone skin actually consumes.

VariablePartCSS propertyStateDefault from
--xh-color-swatch-borderroot--xh-swatch-borderdefault--xh-border-default
--xh-color-swatch-border-invalidroot--xh-swatch-borderinvalid--xh-border-invalid
--xh-color-swatch-radiusroot--xh-swatch-radiusdefault--xh-shape-inset
--xh-color-swatch-sizeroot--xh-swatch-sizedefault--xh-_swatch-size

Released under The MIT License