Installation

Get started with Plate Plus components in your project.

This guide will help you set up the frontend editor of Potion in your project:

Core Setup

Installation

You can start from this template, or using the following command:

pnpm dlx shadcn@latest add https://platejs.org/r/editor-basic

You should get something like:

 Updating CSS variables in app/globals.css
 Created 5 files:
  - app/editor/page.tsx
  - components/editor/plate-editor.tsx
  - components/editor/use-create-editor.ts
  - components/ui/editor.tsx
  - components/ui/editor-static.tsx

Configure styles

Add the following to your globals.css file:

@import 'tailwindcss';
@import 'tw-animate-css';
 
@custom-variant dark (&:is(.dark *));
 
:root {
  --background: hsl(0 0% 100%);
  --foreground: hsl(0 0% 3.9%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(0 0% 3.9%);
  --popover: hsl(0 0% 100%);
  --popover-foreground: hsl(0 0% 3.9%);
  --primary: hsl(240 5.9% 10%);
  --primary-foreground: hsl(0 0% 98%);
  --secondary: hsl(0 0% 96.1%);
  --secondary-foreground: hsl(0 0% 9%);
  --muted: hsl(0 0% 96.1%);
  --muted-foreground: hsl(0 0% 45.1%);
  --accent: hsl(0 0% 96.1%);
  --accent-foreground: hsl(0 0% 9%);
  --destructive: hsl(0 79% 63%);
  --destructive-foreground: hsl(0 0% 98%);
  --border: hsl(0 0% 89.8%);
  --input: hsl(0 0% 89.8%);
  --ring: hsl(240 5.9% 10%);
  --radius: 0.5rem;
  --sidebar-background: hsl(0 0% 98%);
  --sidebar-foreground: hsl(240 5.3% 26.1%);
  --sidebar-primary: hsl(240 5.9% 10%);
  --sidebar-primary-foreground: hsl(0 0% 98%);
  --sidebar-accent: hsl(240 4.8% 95.9%);
  --sidebar-accent-foreground: hsl(240 5.9% 10%);
  --sidebar-border: hsl(220 13% 91%);
  --sidebar-ring: hsl(217.2 91.2% 59.8%);
 
  --brand: hsl(211 77% 51%);
  --brand-foreground: hsl(0 0% 100%);
  --brand-active: hsl(211 77% 41%);
  --highlight: hsl(48 100% 50%);
  --subtle-foreground: hsl(240 5% 34%);
 
  :focus-visible {
    @apply outline-none;
  }
}
 
@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-brand: var(--brand);
  --color-brand-foreground: var(--brand-foreground);
  --color-brand-active: var(--brand-active);
  --color-highlight: var(--highlight);
  --color-subtle-foreground: var(--subtle-foreground);
  --radius-xs: calc(var(--radius) - 6px);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --color-sidebar-ring: var(--sidebar-ring);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar: var(--sidebar-background);
 
  --font-heading: 'var(--font-heading)', 'ui-sans-serif', '-apple-system',
    'BlinkMacSystemFont', 'Segoe UI Variable Display', 'Segoe UI', 'Helvetica',
    'Apple Color Emoji', 'Arial', 'sans-serif', 'Segoe UI Emoji',
    'Segoe UI Symbol', 'Noto Color Emoji';
  --font-mono: 'var(--font-mono)', ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, 'Liberation Mono', 'Courier New', monospace;
  --font-sans: 'var(--font-sans)', 'ui-sans-serif', '-apple-system',
    'BlinkMacSystemFont', 'Segoe UI Variable Display', 'Segoe UI', 'Helvetica',
    'Apple Color Emoji', 'Arial', 'sans-serif', 'Segoe UI Emoji',
    'Segoe UI Symbol', 'Noto Color Emoji';
 
  --shadow-floating: rgba(16, 16, 16, 0.06) 0px 0px 0px 1px,
    rgba(16, 16, 16, 0.11) 0px 3px 7px, rgba(16, 16, 16, 0.21) 0px 9px 25px;
  --shadow-toolbar: rgba(0, 0, 0, 0.08) 0px 16px 24px 0px,
    rgba(0, 0, 0, 0.1) 0px 2px 6px 0px, rgba(0, 0, 0, 0.1) 0px 0px 1px 0px;
 
  --animate-ai-bounce: ai-bounce 0.4s infinite;
  --animate-popover: popover 100ms ease-in;
  --animate-pulse: pulse var(--duration) ease-out infinite;
  --animate-shimmer: shimmer 1s linear infinite;
  --animate-zoom: zoom 100ms ease-in;
 
  @keyframes ai-bounce {
    0%,
    100% {
      animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
      transform: translateY(20%);
    }
    50% {
      animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
      transform: translateY(-20%);
    }
  }
 
  @keyframes popover {
    0% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }
 
  @keyframes pulse {
    0%,
    100% {
      box-shadow: 0 0 0 0 var(--pulse-color);
    }
    50% {
      box-shadow: 0 0 0 8px var(--pulse-color);
    }
  }
 
  @keyframes shimmer {
    0% {
      transform: translateX(-150%);
    }
    100% {
      transform: translateX(150%);
    }
  }
 
  @keyframes zoom {
    0% {
      opacity: 0;
      transform: scale(0.95);
    }
    100% {
      opacity: 1;
      transform: scale(1);
    }
  }
}
 
@layer base {
  * {
    @apply border-border;
    min-width: 0;
    print-color-adjust: exact;
  }
 
  html {
    text-rendering: optimizelegibility;
  }
 
  body {
    @apply bg-background text-foreground;
    font-feature-settings:
      'rlig' 1,
      'calt' 1;
    overflow-wrap: break-word;
    word-break: break-word;
  }
 
  @media print {
    body {
      overflow: visible !important;
    }
  }
 
  ::selection {
    @apply bg-brand/25;
  }
}
 
@utility focus-ring {
  &:focus-visible {
    @apply ring-2 ring-ring ring-offset-2;
  }
}
 
@utility no-focus-ring {
  &:focus-visible {
    @apply ring-0;
  }
}
 
@utility blur-white {
  @apply bg-white/95 backdrop-blur-xs supports-backdrop-filter:bg-white/60;
}
 
@utility transition-bg-ease {
  transition-duration: 20ms;
  transition-property: background-color;
  transition-timing-function: ease-in;
}

Editor

  1. Get GitHub access with Plate Plus
  2. Copy the registry directory into your project.
  3. Update the import in your app/editor/page.tsx (or anywhere else you want to use the editor):
import { PlateEditor } from '@/registry/components/editor/plate-editor';
  1. Install the following dependencies:
npm install @platejs/basic-nodes @platejs/callout @platejs/emoji @radix-ui/react-slot @radix-ui/react-tooltip @radix-ui/react-popover @platejs/code-block lowlight @platejs/selection @platejs/ai @platejs/caption @platejs/comment @platejs/basic-styles @platejs/media @radix-ui/react-toolbar @radix-ui/react-separator @radix-ui/react-dropdown-menu @platejs/list @platejs/toggle @platejs/date @platejs/toc @platejs/layout @platejs/link @platejs/math @platejs/table @ariakit/[email protected] @radix-ui/react-dialog cmdk jotai-x vaul @platejs/resizable [email protected] @platejs/indent react-lazy-load-image-component react-lite-youtube-embed react-player @platejs/mention @platejs/suggestion @platejs/markdown remark-gfm remark-math @platejs/dnd @ai-sdk/react @faker-js/faker @platejs/autoformat date-fns @radix-ui/react-avatar react-markdown @radix-ui/react-hover-card react-dnd react-dnd-html5-backend @platejs/docx @platejs/juice @emoji-mart/[email protected] @platejs/combobox @platejs/floating react-tweet use-file-picker [email protected] @uploadthing/[email protected] sonner zod @radix-ui/react-tabs @platejs/slash-command
  1. Run the development server:
pnpm dev
  1. See the editor in action at localhost:3000/editor

That's it!

You've now set up the Potion frontend editor without any backend features (database, authentication, etc). For a full-stack reference implementation including these features, check out the Potion template.