Skip to Content

Metal Face

Metal surface for any card or panel in silver, gold, graphite, platinum, rose gold, copper, brass, steel and more, with a top-right light pool, a lit edge and a frosted glass icon chip; render it onto a Headline Card for a linked metal feature card.

Installation

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

Usage

import { BankIcon, CoinsIcon } from "@phosphor-icons/react/ssr"

import {
  HeadlineCard,
  HeadlineCardDescription,
  HeadlineCardHeader,
  HeadlineCardLink,
  HeadlineCardMeta,
  HeadlineCardTitle,
} from "@/components/card/headline-card"
import {
  GlassChip,
  MetalFace,
} from "@/components/card/metal-card"

// The metal finishes this file uses: each is the gradient's two stops, the
// light's color and the ink that reads on it.
const SILVER = {
  from: "oklch(0.62 0.012 265)",
  to: "oklch(0.36 0.008 265)",
  light: "0.95 0.01 265",
  ink: "light",
} as const

const GRAPHITE = {
  from: "oklch(0.26 0.008 270)",
  to: "oklch(0.16 0.006 270)",
  light: "0.6 0.012 270",
  ink: "light",
} as const
const COPY = {
  treasury: {
    title: "Treasury",
    description: "Keep reserves where they earn, with a same-day path to cash.",
  },
  payouts: {
    title: "Payouts",
    description: "Pay suppliers in forty currencies from one balance.",
  },
}

// A metal card is a HeadlineCard rendered on a MetalFace, with a GlassChip
// for its icon and the card's own link part.
export default function MetalCardDemo() {
  return (
    <div className="grid w-full max-w-3xl gap-6 sm:grid-cols-2">
      <MetalFace metal={SILVER} render={<HeadlineCard />}>
        <HeadlineCardHeader>
          <HeadlineCardMeta>
            <GlassChip aria-hidden="true">
              <BankIcon />
            </GlassChip>
          </HeadlineCardMeta>
          <HeadlineCardTitle>{COPY.treasury.title}</HeadlineCardTitle>
          <HeadlineCardDescription>
            {COPY.treasury.description}
          </HeadlineCardDescription>
          <HeadlineCardLink
            href="#"
            aria-label={`Open ${COPY.treasury.title}`}
          />
        </HeadlineCardHeader>
      </MetalFace>
      <MetalFace metal={GRAPHITE} render={<HeadlineCard />}>
        <HeadlineCardHeader>
          <HeadlineCardMeta>
            <GlassChip aria-hidden="true">
              <CoinsIcon />
            </GlassChip>
          </HeadlineCardMeta>
          <HeadlineCardTitle>{COPY.payouts.title}</HeadlineCardTitle>
          <HeadlineCardDescription>
            {COPY.payouts.description}
          </HeadlineCardDescription>
          <HeadlineCardLink
            href="#"
            aria-label={`Open ${COPY.payouts.title}`}
          />
        </HeadlineCardHeader>
      </MetalFace>
    </div>
  )
}

This example installs with everything it uses:

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

Anatomy

Metal Face is built from 2 parts. In the example they nest like this:

MetalFace
└─ GlassChip
  • MetalFace: A surface with a metal finish, for anything you already have: pass that surface as render, for example render={<PricingCard />} or render={<HeadlineCard />}, and it gets the metal gradient, the light and the lit top edge, with your content laid on top. A metal card is a HeadlineCard rendered this way, with a GlassChip for its icon.
  • GlassChip: A round frosted-glass chip, 44px across, for an icon. It blurs what is behind it and carries a white rim and highlight. An svg inside is centered and sized to 24px unless it has its own size- class.

API reference

MetalFace

A surface with a metal finish, for anything you already have: pass that surface as render, for example render={<PricingCard />} or render={<HeadlineCard />}, and it gets the metal gradient, the light and the lit top edge, with your content laid on top. A metal card is a HeadlineCard rendered this way, with a GlassChip for its icon.

metal is the finish, as { from, to, light, ink }; ink overrides the finish's ink and shows as data-ink. Muted text inside takes 80% of the text color so it stays readable on the metal. Without render it is a plain div; with render, the rendered part keeps its own data-slot.

Prop

Type

It also accepts the props of the Base UI part it wraps, and the HTML attributes of the element it renders.

GlassChip

A round frosted-glass chip, 44px across, for an icon. It blurs what is behind it and carries a white rim and highlight. An svg inside is centered and sized to 24px unless it has its own size- class.

It accepts the HTML attributes of the element it renders.

Dependencies

npm: @base-ui/react, cn. The CLI installs them for you.

Requires these pieces. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:

Used in blocks

3 blocks are built with Metal Face:

Last updated on