Skip to content

FillSwatch ​

FillSwatch exposes a semantic preview for a fill without imposing application styling. Its slot provides the fill, preview background, category, and transparency state. The root also publishes data-fill-type, data-fill-category, and data-transparent for styling and tests.

With a label, the swatch is an image with that name. Without one it is decorative and hidden from assistive technology, for a swatch inside a labelled button or beside text that names the color.

A swatch shows the fill it is given, also inside BindableValueRoot, so a variable picker's rows keep their own colors. To preview a bound value, pass the root's resolvedValue as the fill's color and bind its stateAttrs on the swatch. Consumers can place a checkerboard below the slot's background value for transparent paints.

vue
<script setup lang="ts">
import type { Fill } from '@open-pencil/scene-graph'
import { 
FillSwatch
} from '@open-pencil/vue/primitives/Fill'
const
fill
: Fill = {
type
: 'SOLID',
color
: {
r
: 0.2,
g
: 0.5,
b
: 0.9,
a
: 0.5 },
opacity
: 1,
visible
: true
} </script> <template> <
FillSwatch
:
fill
="
fill
"
label
="Brand fill" v-slot="
swatch
">
<
span
:style
="{
background
:
swatch
.background }" />
</FillSwatch> </template>

Generated API reference ​

FillSwatch

Generated from packages/vue/src/primitives/Fill/FillSwatch.vue

Props

PropDefaultType
fill*
Fill represented by the swatch.
—Fill
label
Accessible name for the preview. Without one the swatch is decorative and hidden from assistive technology, as when a button or row around it already names the color.
—string | undefined
asChild
Change the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details.
falseboolean | undefined
as
The element or component this component should render as. Can be overwritten by `asChild`.
"span"AsTag | Component | undefined

Slots

SlotPropsDescription
defaultFillSwatchSlotProps