Block Selection
plate/block-selectionFreeComponent
A visual overlay for selected blocks.
Live preview
live · rendered by the registry
Rendered by plate on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://platejs.org/r/block-selection.jsonSource
1'use client';23import * as React from 'react';45import { DndPlugin } from '@platejs/dnd';6import { useBlockSelected } from '@platejs/selection/react';7import { cva } from 'class-variance-authority';8import { type PlateElementProps, usePluginOption } from 'platejs/react';910export const blockSelectionVariants = cva(11 'pointer-events-none absolute inset-0 z-1 bg-brand/[.13] transition-opacity',12 {13 defaultVariants: {14 active: true,15 },16 variants: {17 active: {18 false: 'opacity-0',19 true: 'opacity-100',20 },21 },22 }23);2425export function BlockSelection(props: PlateElementProps) {26 const isBlockSelected = useBlockSelected();27 const isDragging = usePluginOption(DndPlugin, 'isDragging');2829 if (30 !isBlockSelected ||31 props.plugin.key === 'tr' ||32 props.plugin.key === 'table'33 )34 return null;3536 return (37 <div38 className={blockSelectionVariants({39 active: isBlockSelected && !isDragging,40 })}41 data-slot="block-selection"42 />43 );44}
What it pulls in
npm packages
Files it writes
More from plate
All 324 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-kitai-kit | plate | Components | Free | 1 dep | |
| AI Menuai-menu | plate | Components | Free | 5 deps · 2 files | |
| AI Leafai-node | plate | Components | Free | no deps | |
| AI Toolbar Buttonai-toolbar-button | plate | Components | Free | 1 dep | |
| align-base-kitalign-base-kit | plate | Components | Free | 1 dep | |
| align-kitalign-kit | plate | Components | Free | 1 dep | |
| Align Toolbar Buttonalign-toolbar-button | plate | Components | Free | 1 dep | |
| autoformat-classic-kitautoformat-classic-kit | plate | Components | Free | 2 deps |
