# Palette lab

Compare spot inks across five tints and copy the CSS for your pick.

[View Palette lab on CyberSpec](https://www.cyberspec.dev/sink/palette-lab)

## Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/palette-lab.json
```

## Usage

```tsx
import { Cyber } from "@/components/ui/cyber"
import Recipe from "@/components/recipes/palette-lab"

export default function App() {
  return (
    <Cyber>
      <Recipe />
    </Cyber>
  )
}
```

## Source

```tsx
"use client"

import "./recipe-layout.css"
import { useState } from "react"
import { CodeBlock } from "@/components/ui/code-block"
import { SegmentedControl } from "@/components/ui/segmented-control"

const inks = { Flare: "#FF594A", Ion: "#5EF6FF", Iris: "#BB9CFF" }
const tints = [100, 80, 60, 40, 20]
type Ink = keyof typeof inks

export default function PaletteLab() {
  const [ink, setInk] = useState<Ink>("Flare")
  const color = inks[ink]

  return (
    <div className="sink-stack">
      <div role="img" aria-label={`${ink} ink mixed with the panel color, from full strength to twenty percent`} style={{ display: "flex", minHeight: 84 }}>
        {tints.map((tint) => (
          <span key={tint} style={{ flex: tint === 100 ? 2 : 1, backgroundColor: `color-mix(in srgb, ${color} ${tint}%, var(--cy-panel))` }} />
        ))}
      </div>
      <SegmentedControl<Ink> label="Spot ink" options={["Flare", "Ion", "Iris"]} value={ink} onValueChange={(next) => next && setInk(next)} fill />
      <CodeBlock filename="ink.css" language="css" numbers={false} code={`:root { --spot-ink: ${color}; }`} />
    </div>
  )
}
```

## Components in this recipe

- [Segmented control](https://www.cyberspec.dev/components/sidebar/segmented-control.md) — A row of segments with an indicator that slides to the choice.
- [Code block](https://www.cyberspec.dev/components/sidebar/code-block.md) — Highlighted code with line numbers, a filename tab and a copy key. No highlighting dependency.

## Resources

- [All kitchen sink recipes](https://www.cyberspec.dev/sink.md)
- [Recipe source on GitHub](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/recipes/palette-lab.tsx)
- [Recipe layout stylesheet](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/recipes/recipe-layout.css)
- [Shadcn registry item](https://www.cyberspec.dev/r/palette-lab.json)
