BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/Azemmur/primitives-slot

Animate Slot

azemmur/primitives-slot
FreeComponent

A slot component that allows you to use motion components with any element.

Install it

npx shadcn@latest add https://azemmur.raouf.codes/r/primitives-slot.json

Source

registry/components/primitives/slot/index.tsxazemmur.raouf.codes/r/primitives-slot.json
1//Copyright (c) 2025 Elliot Sutton
2
3'use client';
4
5import { cn } from '@/lib/utils';
6import { motion, isMotionComponent, type HTMLMotionProps } from 'motion/react';
7import * as React from 'react';
8
9type AnyProps = Record<string, unknown>;
10
11type DOMMotionProps<T extends HTMLElement = HTMLElement> = Omit<
12 HTMLMotionProps<keyof HTMLElementTagNameMap>,
13 'ref'
14> & { ref?: React.Ref<T> };
15
16type WithAsChild<Base extends object> =
17 | (Base & { asChild: true; children: React.ReactElement })
18 | (Base & { asChild?: false | undefined });
19
20type SlotProps<T extends HTMLElement = HTMLElement> = {
21 // eslint-disable-next-line @typescript-eslint/no-explicit-any
22 children?: any;
23} & DOMMotionProps<T>;
24
25function mergeRefs<T>(
26 ...refs: (React.Ref<T> | undefined)[]
27): React.RefCallback<T> {
28 return (node) => {
29 refs.forEach((ref) => {
30 if (!ref) return;
31 if (typeof ref === 'function') {
32 ref(node);
33 } else {
34 (ref as React.RefObject<T | null>).current = node;
35 }
36 });
37 };
38}
39
40function mergeProps<T extends HTMLElement>(
41 childProps: AnyProps,
42 slotProps: DOMMotionProps<T>,
43): AnyProps {
44 const merged: AnyProps = { ...childProps, ...slotProps };
45
46 if (childProps.className || slotProps.className) {
47 merged.className = cn(
48 childProps.className as string,
49 slotProps.className as string,
50 );
51 }
52
53 if (childProps.style || slotProps.style) {
54 merged.style = {
55 ...(childProps.style as React.CSSProperties),
56 ...(slotProps.style as React.CSSProperties),
57 };
58 }
59
60 return merged;
61}
62
63function Slot<T extends HTMLElement = HTMLElement>({
64 children,
65 ref,
66 ...props
67}: SlotProps<T>) {
68 const isAlreadyMotion =
69 typeof children.type === 'object' &&
70 children.type !== null &&
71 isMotionComponent(children.type);
72
73 const Base = React.useMemo(
74 () =>
75 isAlreadyMotion
76 ? (children.type as React.ElementType)
77 : motion.create(children.type as React.ElementType),
78 [isAlreadyMotion, children.type],
79 );
80
81 if (!React.isValidElement(children)) return null;
82
83 const { ref: childRef, ...childProps } = children.props as AnyProps;
84
85 const mergedProps = mergeProps(childProps, props);
86
87 return (
88 <Base {...mergedProps} ref={mergeRefs(childRef as React.Ref<T>, ref)} />
89 );
90}
91
92export {
93 Slot,
94 type SlotProps,
95 type WithAsChild,
96 type DOMMotionProps,
97 type AnyProps,
98};

What it pulls in

npm packages

  • motion

Files it writes

  • registry/components/primitives/slot/index.tsx

Facts

Registry
Azemmur
Type
registry:ui
Access
Free
Files written
1
Licence
NOASSERTION
In the index
at or before 2026-08-12
Last confirmed
today

Go to the source

azemmur.raouf.codes Gattalraouf/azemmur-ui on GitHub Raw registry item This item as JSON

More from Azemmur

All 27 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Blur Imagecomponents-blur-imageAzemmurComponentsFree1 dep
Buttoncomponents-buttonAzemmurComponentsFree1 dep
Floating Dockcomponents-floating-dockAzemmurComponentsFree2 deps · 6 files
Speed Dialcomponents-speed-dialAzemmurComponentsFree2 deps · 7 files
Tabscomponents-tabsAzemmurComponentsFree2 deps · 9 files
Theme Switchcomponents-theme-switchAzemmurComponentsFree4 deps
Timelinecomponents-timelineAzemmurComponentsFree2 deps · 8 files
Blur Image Demodemo-components-blur-imageAzemmurComponentsFreeno deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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. Changelog

BlockDex