Skip to Content

Metal

Brushed metal texture in silver, gold or graphite: a grained gradient, a pool of light from the top right and a lit top edge. Apply it to a surface you already have for buttons and cards.

Installation

pnpm dlx shadcn@latest add @01orbital/metal

Usage

import { Metal, metalInk } from "@/components/texture/metal"

// Fifteen metal finishes to copy: each is the gradient's two stops, the
// light's color and the ink that reads on it.
const FINISHES = [
  {
    name: "Silver",
    metal: {
      from: "oklch(0.62 0.012 265)",
      to: "oklch(0.36 0.008 265)",
      light: "0.95 0.01 265",
      ink: "light",
    },
  },
  {
    name: "Gold",
    metal: {
      from: "oklch(0.66 0.07 85)",
      to: "oklch(0.4 0.07 60)",
      light: "0.93 0.09 95",
      ink: "light",
    },
  },
  {
    name: "Graphite",
    metal: {
      from: "oklch(0.26 0.008 270)",
      to: "oklch(0.16 0.006 270)",
      light: "0.6 0.012 270",
      ink: "light",
    },
  },
  {
    name: "Platinum",
    metal: {
      from: "oklch(0.86 0 0)",
      to: "oklch(0.66 0 0)",
      light: "1 0 0",
      ink: "dark",
    },
  },
  {
    name: "Rose Gold",
    metal: {
      from: "oklch(0.72 0.06 30)",
      to: "oklch(0.45 0.07 20)",
      light: "0.95 0.04 40",
      ink: "dark",
    },
  },
  {
    name: "Gunmetal",
    metal: {
      from: "oklch(0.3 0 0)",
      to: "oklch(0.17 0 0)",
      light: "0.7 0 0",
      ink: "light",
    },
  },
  {
    name: "Steel",
    metal: {
      from: "oklch(0.4 0 0)",
      to: "oklch(0.24 0 0)",
      light: "0.85 0 0",
      ink: "light",
    },
  },
  {
    name: "Nickel",
    metal: {
      from: "oklch(0.55 0 0)",
      to: "oklch(0.33 0 0)",
      light: "0.95 0 0",
      ink: "light",
    },
  },
  {
    name: "Black",
    metal: {
      from: "oklch(0.2 0 0)",
      to: "oklch(0.1 0 0)",
      light: "0.55 0 0",
      ink: "light",
    },
  },
  {
    name: "Bronze",
    metal: {
      from: "oklch(0.52 0.07 70)",
      to: "oklch(0.3 0.05 55)",
      light: "0.93 0.09 95",
      ink: "light",
    },
  },
  {
    name: "Brass",
    metal: {
      from: "oklch(0.7 0.1 95)",
      to: "oklch(0.44 0.08 80)",
      light: "0.97 0.08 100",
      ink: "light",
    },
  },
  {
    name: "Copper",
    metal: {
      from: "oklch(0.6 0.11 45)",
      to: "oklch(0.36 0.09 35)",
      light: "0.92 0.08 60",
      ink: "light",
    },
  },
  {
    name: "Oxblood",
    metal: {
      from: "oklch(0.38 0.1 20)",
      to: "oklch(0.2 0.06 15)",
      light: "0.8 0.08 30",
      ink: "light",
    },
  },
  {
    name: "Blue Titanium",
    metal: {
      from: "oklch(0.5 0.08 250)",
      to: "oklch(0.28 0.06 260)",
      light: "0.9 0.06 250",
      ink: "light",
    },
  },
  {
    name: "Verdigris",
    metal: {
      from: "oklch(0.55 0.07 180)",
      to: "oklch(0.32 0.05 190)",
      light: "0.92 0.05 170",
      ink: "light",
    },
  },
] as const

// Each finish under its name on a rounded panel, in the ink it carries.
export default function MetalDemo() {
  return (
    <div className="flex min-h-full w-full flex-1 items-center justify-center p-6">
      <div className="grid w-full max-w-4xl grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-5">
        {FINISHES.map(({ name, metal }) => (
          <div
            key={name}
            data-ink={metalInk(metal)}
            className="group relative grid aspect-4/3 content-end rounded-xl p-4 text-scene-foreground shadow-md data-[ink=dark]:text-[oklch(0.2_0.01_60)]"
          >
            <Metal metal={metal} />
            <span className="relative text-sm font-medium group-data-[ink=light]:text-shadow-legible">
              {name}
            </span>
          </div>
        ))}
      </div>
    </div>
  )
}

This example installs with everything it uses:

pnpm dlx shadcn@latest add @01orbital/metal-demo

Examples

Champagnemetal-champagne

Metal Champagne: an example of metal.

pnpm dlx shadcn@latest add @01orbital/metal-champagne

Midnightmetal-midnight

Metal Midnight: an example of metal.

pnpm dlx shadcn@latest add @01orbital/metal-midnight

API reference

Brushed metal for a surface you already have: a grained gradient, a pool of light from the top right and a lit top edge. Place it inside a relative parent, before the content; it fills the parent, follows its corner radius and is hidden from assistive tech. The finish carries its ink: text on a light finish reads best in text-scene-foreground, on a dark one in a dark ink.

Prop

Type

It also accepts the HTML attributes of the element it renders.

Dependencies

npm: cn. The CLI installs it for you.

Last updated on