UNPKG

simple-liquid-glass

Version:

A React component for creating liquid glass morphism effects with customizable distortion and blur

147 lines (124 loc) 3.1 kB
import { ReactNode, CSSProperties, HTMLAttributes } from 'react'; export interface LiquidGlassProps extends HTMLAttributes<HTMLDivElement> { /** * The content to be displayed inside the liquid glass effect */ children?: ReactNode; /** * Mode of the effect * @default "preset" */ mode?: 'preset' | 'custom'; /** * Scale of the displacement effect * @default 160 */ scale?: number; /** * Border radius of the glass effect * @default 50 */ radius?: number; /** * Border thickness (0-0.5) * @default 0.05 */ border?: number; /** * Lightness of the glass (0-100) * @default 53 */ lightness?: number; /** * Displacement blur amount * @default 0.38 */ displace?: number; /** * Alpha transparency of the glass (0-1) * @default 0.9 */ alpha?: number; /** * Blur amount for the glass effect * @default 5 */ blur?: number; /** * Chromatic dispersion amount * @default 50 */ dispersion?: number; /** * Color saturation multiplier (%). 100 = no change * @default 140 */ saturation?: number; /** * Chromatic aberration intensity multiplier * @default 2 */ aberrationIntensity?: number; /** * Frost effect intensity (0-1) * @default 0.1 */ frost?: number; /** * Border color in CSS format * @default "rgba(120, 120, 120, 0.7)" */ borderColor?: string; /** * Semi-transparent color for the glass background (must include alpha) * Examples: rgba(255,255,255,0.4), hsla(0,0%,100%,0.4), #FFFFFFFF with alpha */ glassColor?: string; /** * Automatically adapt text color based on surrounding background * @default false */ autoTextColor?: boolean; /** * Strategy for automatic text color. * - 'global': detect luminance once and apply to the container * - 'perPixel': adapt text per-pixel using CSS blend and filters (no JS sampling) * @default 'global' */ autoTextColorMode?: 'global' | 'perPixel'; /** * When using 'perPixel' mode, apply the adaptive style only to elements matching this selector. * Default: '[data-lg-autotext]' */ perPixelTargetSelector?: string; /** * Text color when detected background is dark * @default '#ffffff' */ textOnDark?: string; /** * Text color when detected background is light * @default '#111111' */ textOnLight?: string; /** * Force the computed text color on all descendants using !important * Useful when children set their own color styles * @default false */ forceTextColor?: boolean; /** Minimum blur (px) to apply on iOS even when blur is 0. Default: 2 */ iosMinBlur?: number; /** iOS blur fallback mode. 'auto' forces a minimal blur; 'off' disables it. Default: 'auto' */ iosBlurMode?: 'auto' | 'off'; /** * Additional CSS class names */ className?: string; /** * Additional inline styles */ style?: CSSProperties; } export declare function LiquidGlass(props: LiquidGlassProps): JSX.Element; export default LiquidGlass;