Noise Texture
Noise Texture é um componente de efeito para React e Tailwind CSS, da biblioteca Magic UI, com licença MIT. Copia e cola no teu projeto.
Magic UI
MIT
effects
O que é
Noise Texture é um componente de efeito para React e Tailwind CSS, da biblioteca Magic UI, com licença MIT. Copia e cola no teu projeto.
Como usar
Abre o componente no catálogo, carrega em copiar, e cola no teu projeto. O prompt copiado leva o código e as regras para o teu agente o reproduzir sem alterar nada.
Cinco cópias grátis por mês. Sem cartão.
Não precisa de pacotes além do que o projeto já tem
Licença
Este componente vem de Magic UI e é redistribuído sob a licença MIT, que permite uso comercial. O aviso de copyright viaja com o código.
Noise Texture
"use client"
import { useId, type ComponentProps } from "react"
import { cn } from "@/lib/utils"
export interface NoiseTextureProps extends ComponentProps<"svg"> {
/** Extra classes merged onto the root `svg` element. */
className?: string
/**
* `baseFrequency` for `feTurbulence`; higher values yield finer-grained noise.
* @default 0.4
*/
frequency?: number
/**
* `numOctaves` for `feTurbulence`; more octaves add detail at smaller scales.
* @default 6
*/
octaves?: number
/**
* Linear slope on each channel after desaturation; adjusts contrast of the noise.
* @default 0.15
*/
slope?: number
/**
* Opacity of the filled noise layer (`rect`).
* @default 0.6
*/
noiseOpacity?: number
}
export const NoiseTexture = ({
className,
frequency = 0.4,
octaves = 6,
slope = 0.15,
noiseOpacity = 0.6,
...props
}: NoiseTextureProps) => {
const filterId = useId()
return (
<svg
className={cn(
"pointer-events-none absolute inset-0 z-0 size-full opacity-50 select-none dark:opacity-[0.75]",
className
)}
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<filter id={filterId}>
<feTurbulence
type="fractalNoise"
baseFrequency={frequency}
numOctaves={octaves}
stitchTiles="stitch"
/>
<feColorMatrix type="saturate" values="0" />
<feComponentTransfer>
<feFuncR type="linear" slope={slope} />
<feFuncG type="linear" slope={slope} />
<feFuncB type="linear" slope={slope} />
</feComponentTransfer>
</filter>
<rect
width="100%"
height="100%"
filter={`url(#${filterId})`}
opacity={noiseOpacity}
/>
</svg>
)
}