Drawer
A panel that slides in from the edge of the screen.
Derived from Shopify admin modal surface and shadow tokens. The admin has no drawer component. It reuses the modal surface and motion tokens.
import { Button, Drawer } from "@replicas/ui";
const properties = [
["Owner", "Alex Rivera"],
["Type", "PDF document"],
["Size", "2.4 MB"],
["Created", "12 November"],
["Shared with", "4 people"],
];
export default function DrawerDemo() {
return (
<Drawer.Root>
<Drawer.Trigger render={<Button>File details</Button>} />
<Drawer.Popup>
<Drawer.Content style={{ display: "flex", flexDirection: "column", gap: 18, padding: "18px 18.5px" }}>
<div style={{ display: "flex", flexDirection: "column", gap: 2 }}>
<span style={{ fontSize: "var(--font-size-mini)", color: "var(--text-tertiary)" }}>Documents</span>
<Drawer.Title>Quarterly report</Drawer.Title>
<Drawer.Description style={{ margin: 0, color: "var(--surface-text-muted)" }}>
Revenue, costs and headcount for October to December.
</Drawer.Description>
</div>
<dl style={{ display: "grid", gridTemplateColumns: "96px 1fr", rowGap: 10, margin: 0 }}>
{properties.map(([label, value]) => (
<div key={label} style={{ display: "contents" }}>
<dt style={{ color: "var(--text-tertiary)" }}>{label}</dt>
<dd style={{ margin: 0, color: "var(--surface-text-strong)" }}>{value}</dd>
</div>
))}
</dl>
<div style={{ display: "flex", justifyContent: "flex-end" }}>
<Drawer.Close render={<Button>Close</Button>} />
</div>
</Drawer.Content>
</Drawer.Popup>
</Drawer.Root>
);
}Prompt
Copy Prompt hands your agent everything it needs to build the Drawer in the Shopify style: the measured tokens, the CSS and the structure.
Show Prompt
# Shopify Drawer
A panel that slides in from the edge of the screen.
Build a Drawer in this project that looks and behaves like Shopify's. Measured from the running Shopify app (admin.shopify.com). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or [Base UI](https://base-ui.com/react/components/drawer) if it has none.
Fidelity: Derived from Shopify admin modal surface and shadow tokens. The admin has no drawer component. It reuses the modal surface and motion tokens.
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--p-border-radius-corner-shape` | `superellipse(1.333)` | `superellipse(1.333)` |
| `--p-border-radius-dialog` | `1.5rem` | `1.5rem` |
| `--p-color-bg-surface` | `#fff` | `#1a1a1a` |
| `--p-color-text` | `#101010` | `#eee` |
| `--p-font-family-sans` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` |
| `--p-font-letter-spacing-body-medium` | `-.01em` | `-.01em` |
| `--p-font-letter-spacing-densest` | `-.02em` | `-.02em` |
| `--p-font-line-height-body-medium` | `1.25rem` | `1.25rem` |
| `--p-font-line-height-heading-large` | `1.375rem` | `1.375rem` |
| `--p-font-size-body-medium` | `.8125rem` | `.8125rem` |
| `--p-font-size-heading-large` | `.9375rem` | `.9375rem` |
| `--p-font-weight-heading-large` | `500` | `500` |
| `--p-shadow-dialog` | `0rem .125rem .1875rem -.0625rem rgba(0,0,0,.06), 0rem .25rem .375rem -.125rem #0000000f, 0rem .5rem .75rem -.25rem #0000000f, 0rem 1rem 1.5rem -.375rem #0000000f, 0rem 2rem 3rem -.5rem #0000000f, 0rem 0rem 0rem .0625rem #00000014` | `0rem 0rem 0rem .0625rem #dcdcdc2e, 0rem .0625rem .125rem 0rem #00000026, 0rem .1875rem .375rem -.1875rem #0000003d, 0rem 1.25rem 2rem -.75rem #00000099` |
| `--p-space-100` | `.25rem` | `.25rem` |
| `--p-space-200` | `.5rem` | `.5rem` |
| `--p-space-400` | `1rem` | `1rem` |
| `--p-space-500` | `1.25rem` | `1.25rem` |
| `--overlay` | `rgb(0 0 0 / 0.5)` | `rgb(0 0 0 / 0.5)` |
| `--ease-out-emphasized` | `cubic-bezier(.2, .8, 0, 1)` | `cubic-bezier(.2, .8, 0, 1)` |
| `--duration-100` | `100ms` | `100ms` |
| `--duration-300` | `300ms` | `300ms` |
| `--duration-backdrop` | `200ms` | `200ms` |
## CSS
Scoped under `[data-style="shopify"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="shopify"] {
.ui-drawer-backdrop {
position: fixed;
inset: 0;
background-color: var(--overlay);
opacity: calc(1 - var(--drawer-swipe-progress, 0));
transition: opacity var(--duration-backdrop);
&[data-starting-style],
&[data-ending-style] {
opacity: 0;
}
&[data-ending-style] {
transition-duration: var(--duration-100);
}
&[data-swiping] {
transition-duration: 0s;
}
}
.ui-drawer-viewport {
box-sizing: border-box;
position: fixed;
inset: 0;
display: flex;
justify-content: flex-end;
padding: var(--p-space-200);
}
.ui-drawer-popup {
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: var(--p-space-100);
width: 380px;
max-width: 100%;
height: 100%;
padding: var(--p-space-400) var(--p-space-500);
overflow-y: auto;
overscroll-behavior: contain;
border-radius: var(--p-border-radius-dialog);
corner-shape: var(--p-border-radius-corner-shape);
background-color: var(--p-color-bg-surface);
box-shadow: var(--p-shadow-dialog);
color: var(--p-color-text);
font-family: var(--p-font-family-sans);
font-size: var(--p-font-size-body-medium);
line-height: var(--p-font-line-height-body-medium);
letter-spacing: var(--p-font-letter-spacing-body-medium);
outline: none;
transform: translateX(var(--drawer-swipe-movement-x, 0px));
transition: transform var(--duration-300) var(--ease-out-emphasized);
&[data-starting-style],
&[data-ending-style] {
transform: translateX(calc(100% + var(--p-space-200)));
}
&[data-swiping] {
transition-duration: 0s;
user-select: none;
}
}
.ui-drawer-title {
margin: 0;
color: var(--p-color-text);
font-size: var(--p-font-size-heading-large);
font-weight: var(--p-font-weight-heading-large);
line-height: var(--p-font-line-height-heading-large);
letter-spacing: var(--p-font-letter-spacing-densest);
}
}
```
## Structure
How Replicas assembles it on Base UI.
```tsx
import { Drawer as BaseDrawer } from "@base-ui/react/drawer";
import { usePortalContainer } from "./portal";
const join = (base: string, extra?: string) => (extra ? `${base} ${extra}` : base);
function Root({ swipeDirection = "right", ...props }: BaseDrawer.Root.Props) {
return <BaseDrawer.Root swipeDirection={swipeDirection} {...props} />;
}
function Popup({ className, ...props }: Omit<BaseDrawer.Popup.Props, "className"> & { className?: string }) {
return (
<BaseDrawer.Portal container={usePortalContainer()}>
<BaseDrawer.Backdrop className="ui-drawer-backdrop" />
<BaseDrawer.Viewport className="ui-drawer-viewport">
<BaseDrawer.Popup className={join("ui-drawer-popup", className)} {...props} />
</BaseDrawer.Viewport>
</BaseDrawer.Portal>
);
}
function Title({ className, ...props }: Omit<BaseDrawer.Title.Props, "className"> & { className?: string }) {
return <BaseDrawer.Title className={join("ui-drawer-title", className)} {...props} />;
}
export const Drawer = {
Root,
Trigger: BaseDrawer.Trigger,
Close: BaseDrawer.Close,
Content: BaseDrawer.Content,
Description: BaseDrawer.Description,
Popup,
Title,
};
```
## Example
```tsx
import { Button, Drawer } from "@replicas/ui";
const properties = [
["Owner", "Alex Rivera"],
["Type", "PDF document"],
["Size", "2.4 MB"],
["Created", "12 November"],
["Shared with", "4 people"],
];
export default function DrawerDemo() {
return (
<Drawer.Root>
<Drawer.Trigger render={<Button>File details</Button>} />
<Drawer.Popup>
<Drawer.Content style={{ display: "flex", flexDirection: "column", gap: 18, padding: "18px 18.5px" }}>
<div style={{ display: "flex", flexDirection: "column", gap: 2 }}>
<span style={{ fontSize: "var(--font-size-mini)", color: "var(--text-tertiary)" }}>Documents</span>
<Drawer.Title>Quarterly report</Drawer.Title>
<Drawer.Description style={{ margin: 0, color: "var(--surface-text-muted)" }}>
Revenue, costs and headcount for October to December.
</Drawer.Description>
</div>
<dl style={{ display: "grid", gridTemplateColumns: "96px 1fr", rowGap: 10, margin: 0 }}>
{properties.map(([label, value]) => (
<div key={label} style={{ display: "contents" }}>
<dt style={{ color: "var(--text-tertiary)" }}>{label}</dt>
<dd style={{ margin: 0, color: "var(--surface-text-strong)" }}>{value}</dd>
</div>
))}
</dl>
<div style={{ display: "flex", justifyContent: "flex-end" }}>
<Drawer.Close render={<Button>Close</Button>} />
</div>
</Drawer.Content>
</Drawer.Popup>
</Drawer.Root>
);
}
```
## Foundations
The rest of the Shopify style, as a skill: https://replicas.raphaelsalaja.com/skills/shopify/SKILL.md