Try 'magnetic button'
View code

Specification

Catalogue
No. 2 of 110
Interaction
Hover, Press
Preview
Live component
Imports
react 19.3.1, @number-flow/react 0.6.2
Added

Notes

A row of different logos that reads as one even size.

Equal heights make wide logos huge and square ones tiny. Sizing each by its shape and its ink makes the row look even. Toggle to compare.

width = k * aspect^0.6 * (ink / 0.3)^-0.25. Grey until hover, real marks only.

The names, figures and pictures in the demo are sample content; a real build uses the client's own.

Code

React and plain CSS
"use client";

import { useId, useState, type CSSProperties, type ReactNode } from "react";
import { logoWidth } from "@/components/pieces/kit/logo-size";
import { tabKey } from "@/components/pieces/shared";
import type { LivePreviewProps } from "@/components/live/types";
import { PieceStage } from "@/components/pieces/stage/PieceStage";
import type { Tour } from "@/components/pieces/stage/tour";
import "@/components/pieces/kit/tabs.css";
import "./logo-wall.css";

// Sample marks of very different shapes, to show the sizing. Not real brands.
const MARKS: { id: string; w: number; h: number; ink: number; body: ReactNode }[] = [
  {
    id: "ring-word",
    w: 120,
    h: 28,
    ink: 0.3,
    body: (
      <>
        <circle cx="14" cy="14" r="10" fill="none" stroke="currentColor" strokeWidth="5" />
        <text x="32" y="20.5" fontSize="19" fontWeight="650" fill="currentColor">
          ardent
        </text>
      </>
    ),
  },
  {
    id: "badge",
    w: 32,
    h: 32,
    ink: 0.8,
    body: (
      <>
        <rect width="32" height="32" rx="8" fill="currentColor" />
        <path d="M10 8v16M10 16l9-8M13 14l8 10" stroke="var(--s-bg)" strokeWidth="3.2" fill="none" strokeLinecap="round" />
      </>
    ),
  },
  {
    id: "thin-word",
    w: 150,
    h: 24,
    ink: 0.18,
    body: (
      <text x="0" y="18" fontSize="21" fontWeight="300" letterSpacing="1.5" fill="currentColor">
        northline
      </text>
    ),
  },
  {
    id: "heavy-word",
    w: 84,
    h: 30,
    ink: 0.45,
    body: (
      <text x="0" y="25" fontSize="29" fontWeight="850" letterSpacing="-1" fill="currentColor">
        KOTO
      </text>
    ),
  },
  {
    id: "hex-word",
    w: 96,
    h: 32,
    ink: 0.33,
    body: (
      <>
        <path d="M14 2l12 7v14l-12 7-12-7V9z" fill="currentColor" />
        <text x="33" y="22.5" fontSize="20" fontWeight="600" fill="currentColor">
          hexa
        </text>
      </>
    ),
  },
  {
    id: "ring",
    w: 30,
    h: 30,
    ink: 0.38,
    body: <circle cx="15" cy="15" r="11.5" fill="none" stroke="currentColor" strokeWidth="5" />,
  },
];

function LogoWallDemo() {
  const [mode, setMode] = useState(1);
  const uid = useId();
  const opts = ["Same height", "Balanced"];
  const pick = (k: number) => {
    setMode(k);
    document.getElementById(`${uid}-${k}`)?.focus();
  };
  return (
    <div className="dm">
      <div className="dm-logos">
        <div className="dm-logos-head">
          <div className="tabs" role="tablist" aria-label="Sizing" style={{ "--n": 2, "--i": mode } as CSSProperties}>
            <span data-light aria-hidden="true" />
            {opts.map((o, k) => (
              <button
                key={o}
                id={`${uid}-${k}`}
                type="button"
                role="tab"
                aria-selected={mode === k}
                tabIndex={mode === k ? 0 : -1}
                onClick={() => setMode(k)}
                onKeyDown={(e) => {
                  const n = tabKey(e.key, k, opts.length);
                  if (n !== null) {
                    e.preventDefault();
                    pick(n);
                  }
                }}
              >
                {o}
              </button>
            ))}
          </div>
        </div>
        <div className="dm-logo-row" aria-label="Sample logos">
          {MARKS.map((m) => (
            <span
              key={m.id}
              className="dm-logo"
              style={{ width: mode === 1 ? logoWidth({ width: m.w, height: m.h, ink: m.ink }) : `calc(34px * ${(m.w / m.h).toFixed(3)})` }}
            >
              <svg viewBox={`0 0 ${m.w} ${m.h}`} aria-hidden="true">
                {m.body}
              </svg>
            </span>
          ))}
        </div>
      </div>
    </div>
  );
}

// What a hovered card shows: the piece used the way a visitor would.
const TOUR: Tour = [
  { click: '[role="tab"]', nth: 0, wait: 1600 },
  { click: '[role="tab"]', nth: 1, wait: 1600 },
];

export default function LogoWallEntry(props: LivePreviewProps) {
  return (
    <PieceStage {...props} label="Balanced logo wall" sample tour={TOUR}>
      <LogoWallDemo />
    </PieceStage>
  );
}

More like this

Sphere of dots that parts for the pointer

Hover, PressPage sections

Slope chart for before and after

Hover, PressCharts and numbers

Liquid metal ring

Hover, PressButtons and toggles

Context window meter

Hover, PressCharts and numbers

Donut that changes period

Hover, PressCharts and numbers

How the tools connect

HoverCharts and numbers