Glass Input
lore-glass/glass-inputFreeComponent
An iOS-style search field in a liquid-glass capsule: a frosted tinted surface with a leading icon slot and a focus ring that glows in with a soft tint lift.
Live preview
live · rendered by the registry
Rendered by lore-glass on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://loreglasses.com/r/glass-input.jsonSource
1"use client";23import { Input as InputPrimitive } from "@base-ui/react/input";4import {5 GlassSurface,6 type GlassSurfaceHandle,7} from "@/components/ui/glass-surface";8import {9 glassEase,10 MotionValue,11 PRESS_DURATION,12 prefersReducedMotion,13 RELEASE_DURATION,14 tween,15} from "@/components/ui/glass-motion";16import { cn } from "@/lib/utils";17import { type ReactNode, useCallback, useEffect, useRef } from "react";1819const FOCUS_LIFT = 0.1;2021interface GlassInputProps extends InputPrimitive.Props {22 height?: number;23 icon?: ReactNode;24 inputClassName?: string;25 tint?: number;26 tintColor?: string;27}2829function GlassInput({30 height = 44,31 icon,32 inputClassName,33 tint = 0.5,34 tintColor,35 className,36 style,37 onFocus,38 onBlur,39 ...props40}: GlassInputProps) {41 const surfaceHandle = useRef<GlassSurfaceHandle | null>(null);42 const ringRef = useRef<HTMLDivElement | null>(null);43 const focusGlow = useRef(new MotionValue(0));44 const frame = useRef(0);4546 const apply = useCallback(() => {47 frame.current = 0;48 const v = focusGlow.current.get();49 if (ringRef.current) {50 ringRef.current.style.opacity = String(v);51 }52 surfaceHandle.current?.setTintLift(FOCUS_LIFT * v);53 }, []);5455 const schedule = useCallback(() => {56 if (frame.current === 0) {57 frame.current = requestAnimationFrame(apply);58 }59 }, [apply]);6061 useEffect(() => {62 const off = focusGlow.current.on(schedule);63 return () => {64 off();65 cancelAnimationFrame(frame.current);66 };67 }, [schedule]);6869 return (70 <label71 className={cn("relative inline-flex w-64 items-center", className)}72 style={{ height, borderRadius: height / 2, ...style }}73 >74 <GlassSurface75 aria-hidden="true"76 blur={10}77 className="absolute inset-0"78 handleRef={surfaceHandle}79 radius={height / 2}80 tint={tint}81 tintColor={tintColor}82 />83 <div84 aria-hidden="true"85 className="pointer-events-none absolute inset-0 rounded-[inherit]"86 ref={ringRef}87 style={{88 opacity: 0,89 boxShadow:90 "0 0 0 2px rgba(152,150,255,0.7), inset 0 1px 0 0 rgba(255,255,255,0.5)",91 }}92 />93 {icon ? (94 <span className="relative z-10 ml-4 inline-flex shrink-0 items-center justify-center text-[#1d1d1f]/55 dark:text-[#f5f5f7]/55 [&_svg]:size-[18px]">95 {icon}96 </span>97 ) : null}98 <InputPrimitive99 className={cn(100// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from lore-glass
All 10 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Glassglass | lore-glass | Components | Free | no deps · 4 files | |
| Glass Buttonglass-button | lore-glass | Components | Free | no deps | |
| Glass Dialogglass-dialog | lore-glass | Components | Free | 1 dep | |
| Glass Dockglass-dock | lore-glass | Components | Free | 1 dep | |
| Glass Popoverglass-popover | lore-glass | Components | Free | 1 dep | |
| Glass Sliderglass-slider | lore-glass | Components | Free | no deps | |
| Glass Switchglass-switch | lore-glass | Components | Free | no deps | |
| Glass Tabsglass-tabs | lore-glass | Components | Free | 1 dep |
