Componentsdata-text + ::before con attr(data-text), background-image repeating-linear-gradient(-45deg) clip-path text. Zero JS.
TextShadowCSS
Esempio01
line-shadow-text.tsx 001Default · h1002Hero · paired displayIssue · 001Catalogo
L'ombra è una trama di striscioline diagonali, non un blur. Vive sotto al titolo come una stampa offset.
003Subtle · accent shadow tsxsrc/components/line-shadow-text.tsx
import type { CSSProperties, ReactNode } from "react";
import { cn } from "@/lib/utils";
export type LineShadowTextProps = {
children: string;
/** Tag the headline renders as. Default `"h1"`. */
as?: "h1" | "h2" | "h3" | "span";
/** Color of the diagonal-stripe shadow. Default `var(--fg-muted)`. */
shadowColor?: string;
className?: string;
};
/**
* <LineShadowText/> — headline with a diagonal-stripe-pattern offset shadow
* (editorial "letterpress with hatch fill" treatment). The shadow is a
* `::before` rendered via `data-text` and clipped to text using
* `background-clip: text` over a repeating-linear-gradient.
*/
export function LineShadowText({
children,
as: Tag = "h1",
shadowColor = "var(--fg-muted)",
className,
}: LineShadowTextProps) {
const cssVars = { "--lst-shadow": shadowColor } as CSSProperties;
return (
<>
<style>{`
.line-shadow-text { position: relative; isolation: isolate; }
.line-shadow-text::before {
content: attr(data-text);
position: absolute;
inset: 0;
transform: translate(2px, 4px);
background-image: repeating-linear-gradient(
-45deg,
var(--lst-shadow, currentColor) 0,
var(--lst-shadow, currentColor) 1px,
transparent 1px,
transparent 4px
);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
z-index: -1;
pointer-events: none;
}
`}</style>
<Tag
data-text={children}
className={cn("line-shadow-text", className)}
style={cssVars}
>
{children}
</Tag>
</>
);
}
Note — Lo shadow è translate(2px, 4px) e usa background-clip: text + WebkitTextFillColor transparent per vedere solo la trama tra le lettere.
Prompt LLM02
Incolla in Claude o ChatGPT per generare la tua variante. Include il contesto del brand, i token e i vincoli del progetto.
Prompt · line-shadow-text Sei un senior frontend engineer. Stai lavorando su un sito Next.js 16 + React 19 + Tailwind v4 in italiano, look chanhdai-inspired: colonna stretta 672px, Geist Sans + Geist Mono, hairline 1px, divisori a stripe diagonale, palette zinc.
Token CSS disponibili: --bg, --bg-alt, --fg, --fg-muted, --fg-soft, --border, --border-strong, --accent. Usa SEMPRE queste variabili tramite le utility tailwind generate (bg-bg, text-fg-muted, border-border, ecc.). Helper "cn" da "@/lib/utils". Niente librerie UI extra: solo lucide-react e tailwind-merge.
Genera un componente <LineShadowText> headline con ombra a strisce diagonali.
Props:
- children: string.
- as?: "h1"|"h2"|"h3"|"span" (default "h1").
- shadowColor?: string (default "var(--fg-muted)").
- className?: string.
Implementazione:
- Server component. Tag con data-text={children}, classe line-shadow-text + className utente.
- <style> inline: .line-shadow-text { position: relative; isolation: isolate; }, ::before { content: attr(data-text); inset: 0; transform: translate(2px, 4px); background-image: repeating-linear-gradient(-45deg, var(--lst-shadow) 0 1px, transparent 1px 4px); background-clip: text; color: transparent; z-index: -1; }
- CSS var --lst-shadow impostata via inline style.
Output: file completo src/components/line-shadow-text.tsx.Uso tipico03
<LineShadowText shadowColor="var(--fg-muted)">Hello</LineShadowText>
Dipendenze04
Ti è servito? Dimmelo, oppure proponi il prossimo componente.