Skip to content

🎥 Make videos programmatically with React

Docs: Editor Starter Cropping Docs

JonnyBurgerc543cbf840de
diff --git a/packages/docs/docs/editor-starter/TableOfContents.tsx b/packages/docs/docs/editor-starter/TableOfContents.tsx
index e4ab6c2ae2..8539c8d98e 100644
--- a/packages/docs/docs/editor-starter/TableOfContents.tsx
+++ b/packages/docs/docs/editor-starter/TableOfContents.tsx
@@ -46,6 +46,10 @@ export const TableOfContents: React.FC = () => {
<strong>Copy and Paste</strong>
<div>How it is implemented in the Editor Starter</div>
</TOCItem>
+ <TOCItem link="/docs/editor-starter/cropping">
+ <strong>Cropping</strong>
+ <div>Mechanics, UI, state management</div>
+ </TOCItem>
<TOCItem link="/docs/editor-starter/fonts">
<strong>Fonts</strong>
<div>How fonts work and which ones are included</div>
diff --git a/packages/docs/docs/editor-starter/cropping.mdx b/packages/docs/docs/editor-starter/cropping.mdx
new file mode 100644
index 0000000000..d70213718b
--- /dev/null
+++ b/packages/docs/docs/editor-starter/cropping.mdx
@@ -0,0 +1,64 @@
+---
+image: /generated/articles-docs-editor-starter-cropping.png
+title: Cropping in the Editor Starter
+sidebar_label: Cropping
+id: cropping
+crumb: Editor Starter
+---
+
+With cropping, users can choose to cut off edges of an item in all 4 directions (left, right, top, bottom).
+
+## State
+
+Cropping was implemented in PR [#415](https://github.com/remotion-dev/editor-starter/pull/415), merged on November 27th, 2025.
+
+It introduces new fields for items:
+
+- [Croppable items](/docs/editor-starter/tracks-items-assets#items) have `cropLeft`, `cropRight`, `cropTop` and `cropBottom` fields.
+- The [global state](/docs/editor-starter/state-management) has a new field `itemSelectedForCrop` which stores whether an item is in Crop Mode.
+
+If you have existing state without these fields, the Editor Starter should handle it gracefully. If you write code that touches this logic, consider that your old persisted state may not have these fields.
+
+## Feature Flag
+
+Cropping can be globally disabled by setting the feature flag [`FEATURE_CROPPING`](https://github.com/search?q=repo%3Aremotion-dev%2Feditor-starter%20FEATURE_CROPPING&type=code) to `false`.
+
+## Items supporting cropping
+
+Out of the [default item types](/docs/editor-starter/tracks-items-assets#items), images, GIFs and videos support cropping.
+
+## Mechanic
+
+The `cropLeft`, `cropRight`, `cropTop` and `cropBottom` fields are ratios, where as `0` means no crop and `1` means cropping the entire axis.
+
+By using ratios instead of pixels, we can ensure that we don't lose precision when combining resizing and cropping.
+
+Throughout the code, we ensure that at least 1 pixel remains in the cropped item for each axis.
+
+We also ensure that the 2 crop values of each axis are less than 1.
+For example, it should not be possible to have `cropLeft` set to `0.5` and `cropRight` set to `0.5`, because nothing would remain.
+
+## Ways of cropping
+
+Crop can be controlled in the inspector using sliders (feature flag: [`FEATURE_CROP_CONTROL`](https://github.com/search?q=repo%3Aremotion-dev%2Feditor-starter%20FEATURE_CROP_CONTROL&type=code)).
+Alternatively, cropping can be done on the canvas by activating [Crop Mode](#crop-mode).
+
+## Crop Mode
+
+By double-clicking an item that is croppable on the canvas, "Crop Mode" is activated, replacing resize handles with crop handles.
+
+On any of the 8 handles, the user can drag to control the crop values.
+
+Feature flag: [`FEATURE_CROP_BACKGROUNDS`](https://github.com/search?q=repo%3Aremotion-dev%2Feditor-starter%20FEATURE_CROP_BACKGROUNDS&type=code)
+
+## Crop Backgrounds
+
+When crop mode is activated, the full uncropped item is shown in the background with reduced opacity, to help the user visualize the cutout area. The actual opacity of the item is overridden to be `1` temporarily to ensure contrast.
+
+## Negative crop values
+
+In Crop Mode, the user can also reposition the item on the canvas, affecting the cutout area and therefore the crop values.
+
+It is more intuitive to also allow for negative crops while dragging the item, which is why we do so. This is aligned with Figma's behavior.
+
+Once crop mode is being exited by clicking anywhere outside of the item, the crop values are being clamped to be non-negative.
diff --git a/packages/docs/docs/editor-starter/features-not-included.mdx b/packages/docs/docs/editor-starter/features-not-included.mdx
index 985428a7ad..e2c4ba5565 100644
--- a/packages/docs/docs/editor-starter/features-not-included.mdx
+++ b/packages/docs/docs/editor-starter/features-not-included.mdx
@@ -93,9 +93,9 @@ See: [Captioning - Limits](/docs/editor-starter/captioning#limits)
There is only one theme, a dark one.
-## Snapping
+## Snapping on the canvas
-There is no magnetic "snapping" feature out of the box that aligns items based on the position of other items or the canvas bounds.
+Magnetic "snapping" that aligns items based on the position of other items is only implemented for the timeline, but not for the canvas.
## See also
diff --git a/packages/docs/docs/editor-starter/features.mdx b/packages/docs/docs/editor-starter/features.mdx
index c9714792f3..f16cf7b352 100644
--- a/packages/docs/docs/editor-starter/features.mdx
+++ b/packages/docs/docs/editor-starter/features.mdx
@@ -240,6 +240,12 @@ Feature flag: [`FEATURE_DIMENSIONS_CONTROL`](https://github.com/search?q=repo%3A
Allows setting the width and height of the item.
+### Cropping controls
+
+Feature flag: [`FEATURE_CROP_CONTROL`](https://github.com/search?q=repo%3Aremotion-dev%2Feditor-starter%20FEATURE_CROP_CONTROL&type=code)
+
+Allows setting the [crop values](/docs/editor-starter/cropping) of the item.
+
### Keep Aspect ratio control
Feature flag: [`FEATURE_KEEP_ASPECT_RATIO_CONTROL`](https://github.com/search?q=repo%3Aremotion-dev%2Feditor-starter%20FEATURE_KEEP_ASPECT_RATIO_CONTROL&type=code)
@@ -509,6 +515,24 @@ Feature flags: [`FEATURE_BRING_TO_FRONT`](https://github.com/search?q=repo%3Arem
Right-clicking on an item shows a menu with options to bring the item to front or send it to back.
+## Cropping
+
+Feature flag: [`FEATURE_CROPPING`](https://github.com/search?q=repo%3Aremotion-dev%2Feditor-starter%20FEATURE_CROPPING&type=code)
+
+Enables [cropping](/docs/editor-starter/cropping) functionality.
+
+### Double-click to crop
+
+Feature flag: [`FEATURE_DOUBLE_CLICK_TO_CROP`](https://github.com/search?q=repo%3Aremotion-dev%2Feditor-starter%20FEATURE_DOUBLE_CLICK_TO_CROP&type=code)
+
+By double-clicking an item that is croppable on the canvas, [Crop Mode](/docs/editor-starter/cropping#crop-mode) is activated, replacing resize handles with crop handles.
+
+### Crop backgrounds
+
+Feature flag: [`FEATURE_CROP_BACKGROUNDS`](https://github.com/search?q=repo%3Aremotion-dev%2Feditor-starter%20FEATURE_CROP_BACKGROUNDS&type=code)
+
+When in [Crop Mode](/docs/editor-starter/cropping#crop-mode), the full uncropped item is shown in the background with reduced opacity, to help the user visualize the cutout area.
+
## Behaviors
### Cut, copy, paste, duplicate items
diff --git a/packages/docs/docs/editor-starter/state-management.mdx b/packages/docs/docs/editor-starter/state-management.mdx
index 2f2bea9b4f..6b576f272c 100644
--- a/packages/docs/docs/editor-starter/state-management.mdx
+++ b/packages/docs/docs/editor-starter/state-management.mdx
@@ -44,6 +44,7 @@ export type EditorState = {
selectedItems: string[];
textItemEditing: string | null;
textItemHoverPreview: TextItemHoverPreview | null;
+ itemSelectedForCrop: string | null;
renderingTasks: RenderingTask[];
captioningTasks: CaptioningTask[];
initialized: boolean;
@@ -64,6 +65,7 @@ export type EditorState = {
- `selectedItems`: An array of item IDs that are currently selected.
- `textItemEditing`: The ID of the text item that is currently being edited, if there is one.
- `textItemHoverPreview`: Preview updates of a text item (for example if a font is hovered in the font picker, the text will render temporarily with the font hovered).
+- `itemSelectedForCrop`: The ID of the item that is currently in [Crop Mode](/docs/editor-starter/cropping#crop-mode), if there is one.
- `renderingTasks`: The state of the rendering process.
- `captioningTasks`: The state of captioning process.
- `initialized`: Whether the editor has been initialized, if not initialized, canvas will not be visible.
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index 1fc64d5be4..7d2886210d 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -1430,6 +1430,7 @@ const sidebars: SidebarsConfig = {
'editor-starter/tracks-items-assets',
'editor-starter/undo-redo',
'editor-starter/copy-paste',
+ 'editor-starter/cropping',
'editor-starter/fonts',
'editor-starter/asset-uploads',
'editor-starter/asset-cleanup',
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 166390262e..974baba9b2 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -1385,6 +1385,15 @@ export const articles = [
noAi: false,
slug: 'editor-starter/copy-paste',
},
+ {
+ id: 'cropping',
+ title: 'Cropping in the Editor Starter',
+ relativePath: 'docs/editor-starter/cropping.mdx',
+ compId: 'articles-docs-editor-starter-cropping',
+ crumb: 'Editor Starter',
+ noAi: false,
+ slug: 'editor-starter/cropping',
+ },
{
id: 'editor-starter/demo',
title: 'Editor Starter Demo',
diff --git a/packages/docs/static/generated/articles-docs-editor-starter-cropping.png b/packages/docs/static/generated/articles-docs-editor-starter-cropping.png
new file mode 100644
index 0000000000..df17f8c8da
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-editor-starter-cropping.png differ