Skip to content
caliper ui docs

Components

Focus dim

A group whose other children step back while one is hovered or has keyboard focus, so the one in use stands out. It is only a stylesheet rule: no script and no wrapper per item.

Free
pnpm dlx shadcn@latest add @caliper/focus-dim

Team

Hover a name, or Tab through them.

Installs components/ui/focus-dim.tsxDepends on none beyond ReactMotion none in component source

When to use

Use it for

  • Rows of links, team members, logos or plans.
  • Any list where the item under the pointer matters most.

Skip it when

  • Touch-only products; with no hover nothing dims.
  • Groups where every item must stay equally prominent.

Decisions

Why it is built this way, so you know what to keep when you change your copy.

Behaviour

Hover and focus, not touch
Hover dimming sits under a hover media query; keyboard focus dims the others on every device.

Usage

Dimmed is still readable
Even the strongest setting leaves items at 28% opacity, and nothing is hidden or disabled.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/focus-dim

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

This is the code behind the preview above.

example.tsx
import { type ReactNode } from "react"
import { FocusDim } from "@/components/ui/focus-dim"

function Panel({ title, context, className = "max-w-md", children }: { title: string; context: string; className?: string; children: ReactNode }) {
  return (
    <section className={`grid w-full gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting max-sm:p-4 ${className}`}>
      <div className="grid gap-1">
        <p className="font-medium">{title}</p>
        <p className="text-sm text-muted-foreground">{context}</p>
      </div>
      {children}
    </section>
  );
}

export function FocusDimDemo() {
  const people = ["Maya Chen", "Dev Patel", "Sara Lind", "Tom Okafor", "Aiko Mori", "Leo Park"];
  return (
    <Panel title="Team" context="Hover a name, or Tab through them.">
      <FocusDim as="ul" className="grid grid-cols-2 gap-2 sm:grid-cols-3">
        {people.map((name) => (
          <li key={name}>
            <a href="#team" onClick={(event) => event.preventDefault()} className="block rounded-control border border-border px-3 py-2.5 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring">
              {name}
            </a>
          </li>
        ))}
      </FocusDim>
    </Panel>
  );
}

API reference

FocusDim

component

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
asElementType"div"The element to render, e.g. "ul" or "nav". Its children are the items that dim.
strength"strong" | "medium" | "soft""medium"How far the others fall back.

Accessibility

It is built on native elements, so roles and focus come from the browser.

No custom key handling; Tab and the native activation keys do the work.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Compare & browse examples