Cards
FocusTile
Put FocusTiles in a FocusGroup. Hover or focus one tile and the others fade and blur, so the eye goes to one choice.
Download
- React
- Tailwind CSS v4
components/ui/focus-tile.tsx
import type { ReactNode } from "react";
type FocusGroupProps = {
children: ReactNode;
/** Layout of the group, a grid by default. */
className?: string;
};
type FocusTileProps = {
children: ReactNode;
className?: string;
};
/* FocusGroup: holds FocusTiles. When one tile is hovered or focused, the rest fade and blur. CSS only. */
export function FocusGroup({ children, className = "grid grid-cols-2 gap-3" }: FocusGroupProps) {
return <div className={`group/focus ${className}`}>{children}</div>;
}
/* FocusTile: one tile inside a FocusGroup. It stays sharp while it has the focus. */
export function FocusTile({
children,
className = "rounded-xl border border-white/10 bg-[#16132a] p-5 text-white",
}: FocusTileProps) {
return (
<div
tabIndex={0}
className={`outline-none transition-[opacity,filter,scale] duration-300 ease-out focus-visible:ring-2 focus-visible:ring-[#a78bfa] motion-reduce:transition-none group-hover/focus:scale-[0.98] group-hover/focus:opacity-40 group-hover/focus:blur-[2px] group-focus-within/focus:scale-[0.98] group-focus-within/focus:opacity-40 group-focus-within/focus:blur-[2px] hover:scale-100! hover:opacity-100! hover:blur-none! focus-within:scale-100! focus-within:opacity-100! focus-within:blur-none! ${className}`}
>
{children}
</div>
);
}
1. Paste the Code tab into
components/ui/focus-tile.tsx. The styles are Tailwind CSS v4 classes.2. Use it. This is the preview above:
app/focus-tile-demo.tsx
import { FocusGroup, FocusTile } from "@/components/ui/focus-tile"; const PLANS = [ ["Starter", "₹0"], ["Studio", "₹499"], ["Team", "₹1,499"], ["Agency", "₹3,999"], ]; export default function FocusTileExample() { return ( <div className="grid h-full place-items-center bg-[#0b0a14] p-6"> <FocusGroup className="grid w-full max-w-[340px] grid-cols-2 gap-3"> {PLANS.map(([name, price]) => ( <FocusTile key={name}> <p className="font-mono text-[11px] uppercase tracking-[0.2em] text-[#a78bfa]">{name}</p> <p className="mt-2 text-xl font-semibold">{price}</p> </FocusTile> ))} </FocusGroup> </div> ); }
Props
| Name | Type | Default | What it does |
|---|---|---|---|
| children | ReactNode | — | Tile content. |
| className | string | dark tile | Look of the tile. |
| FocusGroup className | string | "grid grid-cols-2 gap-3" | Layout of the group. |