Caption
plate/captionFreeComponent
A text field for adding captions to media elements.
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/caption.jsonSource
1'use client';23import * as React from 'react';45import type { VariantProps } from 'class-variance-authority';67import {8 Caption as CaptionPrimitive,9 CaptionTextarea as CaptionTextareaPrimitive,10 useCaptionButton,11 useCaptionButtonState,12} from '@platejs/caption/react';13import { createPrimitiveComponent } from '@udecode/cn';14import { cva } from 'class-variance-authority';1516import { Button } from '@/components/ui/button';17import { cn } from '@/lib/utils';1819const captionVariants = cva('max-w-full', {20 defaultVariants: {21 align: 'center',22 },23 variants: {24 align: {25 center: 'mx-auto',26 left: 'mr-auto',27 right: 'ml-auto',28 },29 },30});3132export function Caption({33 align,34 className,35 ...props36}: React.ComponentProps<typeof CaptionPrimitive> &37 VariantProps<typeof captionVariants>) {38 return (39 <CaptionPrimitive40 {...props}41 className={cn(captionVariants({ align }), className)}42 />43 );44}4546export function CaptionTextarea(47 props: React.ComponentProps<typeof CaptionTextareaPrimitive>48) {49 return (50 <CaptionTextareaPrimitive51 {...props}52 className={cn(53 'mt-2 w-full resize-none border-none bg-inherit p-0 font-[inherit] text-inherit',54 'focus:outline-none focus:[&::placeholder]:opacity-0',55 'text-center print:placeholder:text-transparent',56 props.className57 )}58 />59 );60}6162export const CaptionButton = createPrimitiveComponent(Button)({63 propsHook: useCaptionButton,64 stateHook: useCaptionButtonState,65});
What it pulls in
npm packages
Other registry items
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 |
