--- title: ColorSwatch description: "`ColorSwatch` is a component that displays color samples." links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/color-swatch/color-swatch.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/color-swatch - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-colorswatch--basic --- ```tsx ``` ## Usage ```tsx import { ColorSwatch } from "@yamada-ui/react" ``` ```tsx import { ColorSwatch } from "@/components/ui" ``` ```tsx import { ColorSwatch } from "@workspaces/ui" ``` ```tsx ``` ### Change Variant ```tsx {(variant, index) => ( )} ``` ### Change Size ```tsx {(size, index) => } ``` ### Alpha Example of color swatch using alpha channels. ```tsx {Object.entries(theme.colors.whiteAlpha).map(([key, color]) => ( ))} {Object.entries(theme.colors.blackAlpha).map(([key, color]) => ( ))} ``` ### Disable Shadow By default, a shadow is included inline to make the color easier to see. To disable the shadow, set `withShadow` to `false`. ```tsx ``` ### Group To create color swatch containing multiple colors, use `ColorSwatchGroup`. ```tsx ``` ## Props ### ColorSwatch | Prop | Default | Type | Description | | ------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | `"xs"` | `"2xl" \| "2xs" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. | | `variant` | `"plain"` | `"circle" \| "plain" \| "square"` | The variant of the component. | | `color` | `"#ffffff00"` | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The color used for the swatch element. | | `layers` | - | `HTMLStyledProps[]` | The overlay used for the swatch element. | | `withShadow` | `true` | `boolean` | If `true`, the swatch element has an inner `box-shadow`. | ### ColorSwatchGroup | Prop | Default | Type | Description | | ------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | | `as` | - | `As` | The HTML element to render. | | `asChild` | - | `boolean` | Merges its props onto its immediate child. | | `css` | - | `CSSObject \| CSSObject[]` | The CSS object. | | `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. | | `size` | - | `"2xl" \| "2xs" \| "lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. | | `variant` | - | `"circle" \| "plain" \| "square"` | The variant of the component. | | `itemProps` | - | `ColorSwatchProps` | The props for the `ColorSwatch` component. | | `items` | `"#ffffff00"` | `CSSProps["color"][]` | The color used for the swatch element. | | `layers` | - | `HTMLStyledProps[]` | The overlay used for the swatch element. | | `withShadow` | `true` | `boolean` | If `true`, the swatch element has an inner `box-shadow`. | ## Accessibility Currently, this section is being updated due to the migration of v2.