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

Follow the Plate installation instructions to get started.

Add the basic editor:

pnpm dlx shadcx@latest add plate/editor-basic

This will add:

  • src/app/globals.css: The base styles.
  • src/app/editor/page.tsx: The page with the editor.

Configure styles

Add the following to your globals.css file:

@import 'tailwindcss';
 
@plugin 'tailwind-scrollbar-hide';
 
@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-hover: hsl(211 77% 46%);
  --brand-active: hsl(211 77% 41%);
  --highlight: hsl(48 100% 50%);
  --highlight-foreground: hsl(211 105% 43%);
  --success: hsl(144 38% 39%);
  --success-foreground: hsl(144 39% 30%);
  --warning: hsl(43 100% 38%);
  --warning-foreground: hsl(45 100% 30%);
  --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-hover: var(--brand-hover);
  --color-brand-active: var(--brand-active);
  --color-highlight: var(--highlight);
  --color-highlight-foreground: var(--highlight-foreground);
  --color-success: var(--success);
  --color-success-foreground: var(--success-foreground);
  --color-warning: var(--warning);
  --color-warning-foreground: var(--warning-foreground);
  --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;
 
  --ease-vaul: cubic-bezier(0.32, 0.72, 0, 1);
 
  --animate-accordion-down: accordion-down 0.2s ease-out;
  --animate-accordion-up: accordion-up 0.2s ease-out;
  --animate-ai-bounce: ai-bounce 0.4s infinite;
  --animate-fade-down: fade-down 0.5s;
  --animate-fade-in: fade-in 0.4s;
  --animate-fade-out: fade-out 0.4s;
  --animate-fade-up: fade-up 0.5s;
  --animate-popover: popover 100ms ease-in;
  --animate-pulse: pulse var(--duration) ease-out infinite;
  --animate-shimmer: shimmer 1s linear infinite;
  --animate-shine: shine 8s ease-in-out infinite;
  --animate-sunlight: sunlight 4s linear infinite;
  --animate-zoom: zoom 100ms ease-in;
 
  @keyframes accordion-down {
    from {
      height: 0;
    }
    to {
      height: var(--radix-accordion-content-height);
    }
  }
  @keyframes accordion-up {
    from {
      height: var(--radix-accordion-content-height);
    }
    to {
      height: 0;
    }
  }
 
  @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 fade-down {
    0% {
      opacity: 0;
      transform: translateY(-10px);
    }
    80% {
      opacity: 0.6;
    }
    100% {
      opacity: 1;
      transform: translateY(0px);
    }
  }
 
  @keyframes fade-up {
    0% {
      opacity: 0;
      transform: translateY(10px);
    }
    80% {
      opacity: 0.7;
    }
    100% {
      opacity: 1;
      transform: translateY(0px);
    }
  }
 
  @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 shine {
    from {
      background-position: 200% 0;
    }
    to {
      background-position: -200% 0;
    }
  }
 
  @keyframes sunlight {
    0% {
      transform: translateX(-50%) rotate(0deg);
    }
    100% {
      transform: translateX(0%) rotate(0deg);
    }
  }
 
  @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;
  }
 
  kbd {
    font-size: inherit;
  }
 
  @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;
}
 
@theme inline {
  --animation-delay-0: 0s;
  --animation-delay-75: 75ms;
  --animation-delay-100: 0.1s;
  --animation-delay-150: 0.15s;
  --animation-delay-200: 0.2s;
  --animation-delay-300: 0.3s;
  --animation-delay-500: 0.5s;
  --animation-delay-700: 0.7s;
  --animation-delay-1000: 1s;
 
  --animation-repeat-0: 0;
  --animation-repeat-1: 1;
  --animation-repeat-infinite: infinite;
 
  --animation-direction-normal: normal;
  --animation-direction-reverse: reverse;
  --animation-direction-alternate: alternate;
  --animation-direction-alternate-reverse: alternate-reverse;
 
  --animation-fill-mode-none: none;
  --animation-fill-mode-forwards: forwards;
  --animation-fill-mode-backwards: backwards;
  --animation-fill-mode-both: both;
 
  --animate-in: var(--tw-duration, 150ms) var(--tw-ease, ease) enter;
  --animate-out: var(--tw-duration, 150ms) var(--tw-ease, ease) exit;
 
  --percentage-0: 0;
  --percentage-5: 0.05;
  --percentage-10: 0.1;
  --percentage-15: 0.15;
  --percentage-20: 0.2;
  --percentage-25: 0.25;
  --percentage-30: 0.3;
  --percentage-35: 0.35;
  --percentage-40: 0.4;
  --percentage-45: 0.45;
  --percentage-50: 0.5;
  --percentage-55: 0.55;
  --percentage-60: 0.6;
  --percentage-65: 0.65;
  --percentage-70: 0.7;
  --percentage-75: 0.75;
  --percentage-80: 0.8;
  --percentage-85: 0.85;
  --percentage-90: 0.9;
  --percentage-95: 0.95;
  --percentage-100: 1;
 
  @keyframes enter {
    from {
      opacity: var(--tw-enter-opacity, 1);
      transform: translate3d(
          var(--tw-enter-translate-x, 0),
          var(--tw-enter-translate-y, 0),
          0
        )
        scale3d(
          var(--tw-enter-scale, 1),
          var(--tw-enter-scale, 1),
          var(--tw-enter-scale, 1)
        )
        rotate(var(--tw-enter-rotate, 0));
    }
  }
 
  @keyframes exit {
    to {
      opacity: var(--tw-exit-opacity, 1);
      transform: translate3d(
          var(--tw-exit-translate-x, 0),
          var(--tw-exit-translate-y, 0),
          0
        )
        scale3d(
          var(--tw-exit-scale, 1),
          var(--tw-exit-scale, 1),
          var(--tw-exit-scale, 1)
        )
        rotate(var(--tw-exit-rotate, 0));
    }
  }
}
 
/*
 * Tailwind's default `duration` utility sets the `--tw-duration` variable, so
 * can set `animation-duration` directly in the animation definition in the
 * `@theme` section above. Same goes for the `animation-timing-function`, set
 * with `--tw-ease`.
 */
 
@utility delay-* {
  animation-delay: --value([duration]);
  animation-delay: calc(--value(integer) * 1ms);
  animation-delay: --value(--animation-delay- *);
}
 
@utility repeat-* {
  animation-iteration-count: --value(--animation-repeat- *, integer);
}
 
@utility direction-* {
  animation-direction: --value(--animation-direction- *);
}
 
@utility fill-mode-* {
  animation-fill-mode: --value(--animation-fill-mode- *);
}
 
@utility running {
  animation-play-state: running;
}
@utility paused {
  animation-play-state: paused;
}
 
@utility fade-in-* {
  --tw-enter-opacity: --value(--percentage- *);
}
@utility fade-out-* {
  --tw-exit-opacity: --value(--percentage- *);
}
 
@utility zoom-in-* {
  --tw-enter-scale: --value(--percentage- *);
}
@utility zoom-out-* {
  --tw-exit-scale: --value(--percentage- *);
}
 
@utility spin-in-* {
  --tw-enter-rotate: calc(--value(integer) * 1deg);
  --tw-enter-rotate: --value(--rotate- *, [angle]);
}
@utility spin-out-* {
  --tw-exit-rotate: calc(--value(integer) * 1deg);
  --tw-exit-rotate: --value(--rotate- *, [angle]);
}
 
@utility slide-in-from-top-* {
  --tw-enter-translate-y: calc(--value([percentage], [length]) * -1);
}
@utility slide-in-from-bottom-* {
  --tw-enter-translate-y: --value([percentage], [length]);
}
@utility slide-in-from-left-* {
  --tw-enter-translate-x: calc(--value([percentage], [length]) * -1);
}
@utility slide-in-from-right-* {
  --tw-enter-translate-x: --value([percentage], [length]);
}
 
@utility slide-out-to-top-* {
  --tw-exit-translate-y: calc(--value([percentage], [length]) * -1);
}
@utility slide-out-to-bottom-* {
  --tw-exit-translate-y: --value([percentage], [length]);
}
@utility slide-out-to-left-* {
  --tw-exit-translate-x: calc(--value([percentage], [length]) * -1);
}
@utility slide-out-to-right-* {
  --tw-exit-translate-x: --value([percentage], [length]);
}

Editor

  1. Get GitHub access with Plate Plus
  2. Copy the registry directory into your project.
  3. Update the import in src/app/editor/page.tsx:
import { PlateEditor } from '@/registry/default/components/editor/plate-editor';
  1. Install the following dependencies:
npm install @udecode/plate-ai @udecode/plate-basic-marks @udecode/plate-block-quote @udecode/plate-callout @udecode/plate-code-block @udecode/plate-comments @udecode/plate-date @udecode/plate-emoji @udecode/plate-heading @udecode/plate-horizontal-rule @udecode/plate-layout @udecode/plate-link @udecode/plate-math @udecode/plate-media @udecode/plate-mention @udecode/plate-slash-command @udecode/plate-table @udecode/plate-toggle @udecode/plate-test-utils @udecode/plate-markdown @faker-js/faker react-markdown @radix-ui/react-hover-card @udecode/plate-docx @udecode/plate-font @udecode/plate-juice @udecode/plate-kbd @udecode/plate-trailing-block prismjs @udecode/plate-selection @udecode/plate-dnd @udecode/plate-indent @udecode/plate-indent-list @radix-ui/react-checkbox @udecode/plate-floating @radix-ui/react-slot @radix-ui/react-tooltip @radix-ui/react-popover @radix-ui/react-separator ai @ariakit/[email protected] @udecode/plate-caption @radix-ui/react-toolbar @radix-ui/react-dropdown-menu @radix-ui/react-dialog cmdk jotai-x vaul @udecode/plate-autoformat date-fns @radix-ui/react-avatar @udecode/plate-select @udecode/plate-node-id @udecode/plate-break @udecode/plate-reset-node @udecode/plate-resizable [email protected] react-dnd react-dnd-html5-backend @udecode/plate-combobox react-lazy-load-image-component react-tweet use-file-picker [email protected] @uploadthing/[email protected] sonner zod @radix-ui/react-tabs react-lite-youtube-embed react-player
  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.