

<InteractiveDemo
  name="color-swatch"
  controls="[
  {
    type: &#x22;string&#x22;,
    name: &#x22;color&#x22;,
    defaultValue: &#x22;#ff0000&#x22;,
  },
]"
/>

## Installation [#installation]

<InstallPrerequisite>
  Before adding components, init your project with your design system from the [Studio](/studio).
</InstallPrerequisite>

<CodeBlockTabs defaultValue="npm" groupId="package-manager">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npx shadcn@latest add @dotui/color-swatch
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm dlx shadcn@latest add @dotui/color-swatch
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn dlx shadcn@latest add @dotui/color-swatch
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bunx shadcn@latest add @dotui/color-swatch
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## Usage [#usage]

```tsx
import { ColorSwatch } from "@/components/ui/color-swatch"
```

```tsx
<ColorSwatch color="#ff0000" />
```

## Value [#value]

The `color` prop accepts a hex or CSS color string, or a `Color` object from `parseColor`. Translucent colors render over a checkerboard so their transparency shows through.

```tsx
import { parseColor } from "react-aria-components"
```

```tsx
<ColorSwatch color={parseColor("#7f0000aa")} />
```

## Examples [#examples]

<Examples className="sm:grid-cols-2 lg:grid-cols-3">
  <Example name="color-swatch/demos/default" title="Default" />

  <Example name="color-swatch/demos/color-palette" title="Color Palette" />

  <Example name="color-swatch/demos/in-button" title="In Button" />
</Examples>

## API Reference [#api-reference]

<Reference name="color-swatch" />
