ColorSwatch
Displays color
Polymorphic
Source
Docs
Package
Usage
withShadow
By default, ColorSwatch has an inner box-shadow to make it more visible on light backgrounds,
you can disable it by setting withShadow={false} prop:
Polymorphic component
ColorSwatch is a polymorphic component – its default root element is div, but it can be changed to any other element or component with component prop:
Polymorphic components with TypeScript
Note that polymorphic components props types are different from regular components – they do not extend HTML element props of the default element. For example,
ColorSwatchPropsdoes not extendReact.ComponentPropsWithoutRef'<'div'>'althoughdivis the default element.If you want to create a wrapper for a polymorphic component that is not polymorphic (does not support
componentprop), then your component props interface should extend HTML element props, for example:If you want your component to remain polymorphic after wrapping, use
createPolymorphicComponentfunction described in this guide.