BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/basecn/drawer-base

Drawer (Base UI)

basecn/drawer-base
FreeComponent

A panel that slides in from the edge of the screen.

Live preview

live · rendered by the registry
Rendered by basecn on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://basecn.dev/r/drawer-base.json

Source

src/registry/components/ui/drawer-base.tsxbasecn.dev/r/drawer-base.json · first 6 KB
1"use client";
2
3import { cn } from "@/lib/utils";
4import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer";
5import { ComponentProps, createContext, use } from "react";
6
7function resolveClassName<S>(
8 className: string | ((state: S) => string | undefined) | undefined,
9 state: S,
10): string | undefined {
11 return typeof className === "function" ? className(state) : className;
12}
13
14const DrawerContext =
15 createContext<DrawerPrimitive.Root.Props["swipeDirection"]>("down");
16
17function DrawerProvider({ ...props }: DrawerPrimitive.Provider.Props) {
18 return <DrawerPrimitive.Provider {...props} />;
19}
20
21function Drawer({
22 swipeDirection = "down",
23 ...props
24}: DrawerPrimitive.Root.Props) {
25 return (
26 <DrawerContext value={swipeDirection}>
27 <DrawerPrimitive.Root
28 data-slot="drawer"
29 swipeDirection={swipeDirection}
30 {...props}
31 />
32 </DrawerContext>
33 );
34}
35
36function DrawerTrigger({ ...props }: DrawerPrimitive.Trigger.Props) {
37 return <DrawerPrimitive.Trigger {...props} data-slot="drawer-trigger" />;
38}
39
40function DrawerPortal({ className, ...props }: DrawerPrimitive.Portal.Props) {
41 return (
42 <DrawerPrimitive.Portal
43 data-slot="drawer-portal"
44 className={(state) => cn("z-50", resolveClassName(className, state))}
45 {...props}
46 />
47 );
48}
49
50function DrawerClose({ ...props }: DrawerPrimitive.Close.Props) {
51 return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />;
52}
53
54function DrawerContent({ className, ...props }: DrawerPrimitive.Content.Props) {
55 return (
56 <DrawerPrimitive.Content
57 data-slot="drawer-content"
58 className={(state) =>
59 cn(
60 "transition-opacity duration-300 ease-[cubic-bezier(0.45,1.005,0,1.005)] group-data-nested-drawer-open/popup:opacity-0 group-data-nested-drawer-swiping/popup:opacity-100",
61 resolveClassName(className, state),
62 )
63 }
64 {...props}
65 />
66 );
67}
68
69export const drawerPopupClassName = ({
70 swipeDirection,
71}: DrawerPrimitive.Popup.State) => {
72 return cn(
73 "group/popup relative",
74 "[--bleed:3rem] outline-1 outline-foreground/5 bg-background text-foreground dark:outline-border overflow-y-auto overscroll-contain touch-auto data-swiping:select-none",
75 "data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)]",
76 // Nested drawer stacking variables (no-ops when not nested)
77// … truncated

What it pulls in

npm packages

  • @base-ui/react

Files it writes

  • src/registry/components/ui/drawer-base.tsx

Facts

Registry
basecn
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

Docs on basecn basecn.dev akash3444/basecn on GitHub Raw registry item This item as JSON

More from basecn

All 56 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionbasecnComponentsFree2 deps
AlertalertbasecnComponentsFree1 dep
Alert Dialogalert-dialogbasecnComponentsFree1 dep
Aspect Ratioaspect-ratiobasecnComponentsFreeno deps
AutocompleteautocompletebasecnComponentsFree2 deps
AvataravatarbasecnComponentsFree1 dep
BadgebadgebasecnComponentsFree2 deps
BreadcrumbbreadcrumbbasecnComponentsFree2 deps
BlockDex

Built by

Kynth Studio

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

BlockDex

BlockDex

Built by

Kynth Studio

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

BlockDex

BlockDex

Built by

Kynth Studio

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

BlockDex