BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/snap-cn/input

UI Input

snap-cn/input
FreeComponent

A text input whose idle/hover/active/typing/invalid state is a pure function of the timeline; the focus ring, border, caret, and value reveal are keyframed presets.

Install it

npx shadcn@latest add https://snapcn.dev/r/input.json

Source

registry/snap-cn-ui/input/index.tsxsnapcn.dev/r/input.json · first 6 KB
1"use client";
2
3import { cva } from "class-variance-authority";
4import { Caret } from "@/components/snap-cn/caret";
5import {
6 mixOklch,
7 revealedText,
8 type SnapCnTheme,
9 useSnapCnTheme,
10} from "@/lib/snap-cn-ui";
11import { cn } from "@/lib/utils";
12
13export type InputState =
14 | "idle"
15 | "hover"
16 | "active"
17 | "typing"
18 | "blur"
19 | "invalid";
20
21type InputSize = "sm" | "default" | "lg";
22
23export interface InputProps {
24 state?: InputState;
25 style?: InputStyle;
26 placeholder?: string;
27 value?: string;
28 size?: InputSize;
29 theme?: Partial<SnapCnTheme>;
30 primary?: string;
31 fullWidth?: boolean;
32 className?: string;
33}
34
35/**
36 * The control, as classes.
37 *
38 * This is a shadcn field that happens to be driven by a frame clock, so it is
39 * built the way shadcn builds one: `cva` for the size scale, `cn` for merging,
40 * `data-slot` for targeting. What stays in `style` is *only* what is tweened —
41 * see the note on the render below.
42 */
43const inputVariants = cva(
44 "relative flex items-center border border-solid tracking-[-0.01em]",
45 {
46 variants: {
47 size: {
48 sm: "h-9 px-3 text-[13px]",
49 default: "h-10 px-3.5 text-[15px]",
50 lg: "h-12 px-4 text-[17px]",
51 },
52 fullWidth: { true: "w-full", false: "w-80" },
53 },
54 defaultVariants: { size: "default", fullWidth: false },
55 },
56);
57
58/** The placeholder overlays the value, so it needs the field's own inset. */
59const placeholderVariants = cva(
60 "pointer-events-none absolute whitespace-nowrap",
61 {
62 variants: { size: { sm: "left-3", default: "left-3.5", lg: "left-4" } },
63 defaultVariants: { size: "default" },
64 },
65);
66
67/** `Caret` takes a pixel height, not a class — so this one number stays a number. */
68const CARET_HEIGHT: Record<InputSize, number> = { sm: 14, default: 17, lg: 19 };
69
70export interface InputStyle {
71 borderColor: string;
72 ringColor: string;
73 ringWidth: number;
74 background: string;
75 caretOpacity: number;
76 valueReveal: number;
77 placeholderOpacity: number;
78}
79
80export interface InputStyleContext {
81 idleBorder: string;
82 hoverBorder: string;
83 activeBorder: string;
84 invalidBorder: string;
85 ring: string;
86 invalidRing: string;
87 background: string;
88 hoverBackground: string;
89 foreground: string;
90 mutedForeground: string;
91}
92
93export function inputStyleContext(theme: SnapCnTheme): InputStyleContext {
94 return {
95 idleBorder: theme.input,
96 hoverBorder: mixOklch(theme.input, theme.foreground, 0.18),
97 activeBorder: theme.ring,
98// … truncated

What it pulls in

npm packages

  • remotion
  • class-variance-authority

Other registry items

  • https://snapcn.dev/r/snap-cn-ui.json
  • https://snapcn.dev/r/caret.json
  • utils

Files it writes

  • registry/snap-cn-ui/input/index.tsx
  • registry/snap-cn-ui/input/use-input-transition.ts

Facts

Registry
snap-cn
Type
registry:component
Access
Free
Files written
2
Licence
the repository states none
First indexed
2026-08-12
Last confirmed
today

Go to the source

snapcn.dev Raw registry item This item as JSON

More from snap-cn

All 24 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Answer Streamanswer-streamsnap-cnComponentsFree2 deps
UI Caretcaretsnap-cnComponentsFree1 dep
Follower Rushfollower-rushsnap-cnComponentsFree2 deps
Product Herohero-launchsnap-cnComponentsFree2 deps
Karaoke Captionskaraoke-captionssnap-cnComponentsFree2 deps
Laptop Framelaptop-framesnap-cnComponentsFree1 dep
Logo Assemblelogo-assemblesnap-cnComponentsFree1 dep
Logo Flickerlogo-flickersnap-cnComponentsFree1 dep
BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex