Skip to content

🎥 Make videos programmatically with React

Merge pull request #11340 from remotion-dev/elements/add-to-studio

Igor Samokhovetsef4862db0480
diff --git a/packages/docs/elements/libraries.mdx b/packages/docs/elements/libraries.mdx
index be9451c025..71912e93d2 100644
--- a/packages/docs/elements/libraries.mdx
+++ b/packages/docs/elements/libraries.mdx
@@ -4,6 +4,8 @@ sidebar_label: Third-party Elements
description: Third-party Element libraries that integrate with Remotion Studio.
---
+import {ThirdPartyElementLibraries} from '@site/src/components/Elements/ThirdPartyElementLibraries';
+
# Third-party Elements
This is a list of third-party websites providing Remotion [Elements](/elements). They are not affiliated with Remotion.
@@ -14,4 +16,4 @@ Anybody can create Element libraries. Click [here](/docs/studio-protocol/compone
Contact [[email protected]](mailto:[email protected]) to propose inclusion of your Element library on this page.
-- [Remocn](https://remocn.dev/docs/components) - A shadcn-style library of production-ready Remotion components for building product demo videos with AI agents.
+<ThirdPartyElementLibraries />
diff --git a/packages/docs/src/components/Elements/ThirdPartyElementLibraries.module.css b/packages/docs/src/components/Elements/ThirdPartyElementLibraries.module.css
new file mode 100644
index 0000000000..03a2e667e3
--- /dev/null
+++ b/packages/docs/src/components/Elements/ThirdPartyElementLibraries.module.css
@@ -0,0 +1,197 @@
+.library {
+ container: third-party-libraries / inline-size;
+}
+
+.list {
+ margin: 0 0 var(--ifm-leading);
+ padding: 0;
+ column-count: 1;
+ column-gap: 16px;
+ list-style: none;
+}
+
+.card {
+ position: relative;
+ width: 100%;
+ min-width: 0;
+ margin: 0 0 16px;
+ break-inside: avoid;
+ overflow: hidden;
+ border: 1px solid var(--border-color);
+ border-radius: 14px;
+ background: var(--ifm-color-emphasis-0);
+ color: var(--text-color);
+}
+
+.preview {
+ display: flex;
+ aspect-ratio: 1200 / 630;
+ align-items: center;
+ justify-content: center;
+ overflow: hidden;
+ background: var(--ifm-color-emphasis-100);
+}
+
+.previewImage {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+
+.content {
+ padding: 14px;
+}
+
+.preview + .content {
+ border-top: 1px solid var(--border-color);
+}
+
+.libraryRow {
+ display: flex;
+ gap: 12px;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.libraryTitle {
+ min-width: 0;
+ margin: 0;
+ overflow-wrap: anywhere;
+ font-size: 1rem;
+ font-weight: 500;
+ letter-spacing: -0.01em;
+}
+
+.card .libraryLink,
+.card .libraryLink:hover,
+.card .libraryLink:visited {
+ color: var(--ifm-font-color-base);
+ text-decoration: none;
+}
+
+.libraryLink::after {
+ position: absolute;
+ inset: 0;
+ border-radius: 13px;
+ content: '';
+}
+
+.libraryLink:hover {
+ color: var(--ifm-font-color-base);
+ text-decoration: none;
+}
+
+.libraryLink:focus-visible {
+ outline: none;
+}
+
+.libraryLink:focus-visible::after {
+ outline: 2px solid var(--ifm-color-primary);
+ outline-offset: -2px;
+}
+
+.addAction {
+ position: relative;
+ z-index: 1;
+ display: inline-flex;
+ flex: 0 0 auto;
+ gap: 4px;
+ align-items: center;
+ justify-content: center;
+ min-width: 54px;
+ height: 30px;
+ margin: 0;
+ padding: 0 9px 0 7px;
+ border: 0;
+ border-radius: 7px;
+ background: var(--ifm-color-emphasis-100);
+ color: var(--ifm-color-emphasis-800);
+ cursor: pointer;
+ font: inherit;
+ font-size: 0.8125rem;
+ font-weight: 600;
+ line-height: 1;
+}
+
+.addAction:hover:not(:disabled) {
+ background: var(--ifm-color-emphasis-200);
+ color: var(--ifm-color-primary);
+}
+
+.addActionIcon {
+ display: inline-grid;
+ width: 12px;
+ height: 16px;
+ flex: 0 0 auto;
+ place-items: center;
+ font-size: 1rem;
+ font-weight: 400;
+ line-height: 1rem;
+}
+
+.touchTarget {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ width: max(100%, 48px);
+ height: max(100%, 48px);
+ transform: translate(-50%, -50%);
+}
+
+.addAction:disabled {
+ cursor: default;
+ opacity: 0.65;
+}
+
+.addAction:focus-visible {
+ outline: 2px solid var(--ifm-color-primary);
+ outline-offset: 2px;
+}
+
+.loadingStatus,
+.successStatus,
+.errorStatus {
+ position: relative;
+ z-index: 1;
+ margin: 10px 0 0;
+ font-size: 0.875rem;
+ line-height: 1.45;
+}
+
+.loadingStatus {
+ color: var(--ifm-color-emphasis-700);
+}
+
+.successStatus {
+ color: var(--ifm-color-success-dark);
+}
+
+.errorStatus {
+ color: var(--ifm-color-danger-dark);
+}
+
+@media (pointer: fine) {
+ .touchTarget {
+ display: none;
+ }
+}
+
+@container third-party-libraries (min-width: 640px) {
+ .list {
+ column-count: 2;
+ }
+}
+
+@container third-party-libraries (max-width: 639px) {
+ .content {
+ padding: 16px;
+ }
+
+ .addAction {
+ height: 36px;
+ padding-right: 11px;
+ padding-left: 9px;
+ font-size: 1rem;
+ }
+}
diff --git a/packages/docs/src/components/Elements/ThirdPartyElementLibraries.tsx b/packages/docs/src/components/Elements/ThirdPartyElementLibraries.tsx
new file mode 100644
index 0000000000..c7af00ac01
--- /dev/null
+++ b/packages/docs/src/components/Elements/ThirdPartyElementLibraries.tsx
@@ -0,0 +1,172 @@
+import {
+ addElementLibraryToStudio,
+ type AddElementLibraryToStudioErrorCode,
+} from '@remotion/studio-protocol';
+import React, {useCallback, useId, useState} from 'react';
+import {
+ thirdPartyElementLibraries,
+ type ThirdPartyElementLibrary,
+} from './third-party-element-library-data';
+import styles from './ThirdPartyElementLibraries.module.css';
+
+type AddState =
+ | {readonly type: 'idle'}
+ | {readonly type: 'loading'}
+ | {readonly message: string; readonly type: 'awaiting-confirmation'}
+ | {
+ readonly code: AddElementLibraryToStudioErrorCode | null;
+ readonly message: string;
+ readonly type: 'error';
+ };
+
+const ThirdPartyElementLibraryItem: React.FC<{
+ readonly library: ThirdPartyElementLibrary;
+ readonly requestLibraryAddition: typeof addElementLibraryToStudio;
+}> = ({library, requestLibraryAddition}) => {
+ const [addState, setAddState] = useState<AddState>({type: 'idle'});
+ const statusId = useId();
+ const isLoading = addState.type === 'loading';
+
+ const addToStudio = useCallback(async () => {
+ setAddState({type: 'loading'});
+
+ try {
+ const result = await requestLibraryAddition({
+ displayName: library.displayName,
+ url: library.catalogUrl,
+ });
+ if (!result.success) {
+ setAddState({
+ code: result.code,
+ message: result.message,
+ type: 'error',
+ });
+ return;
+ }
+
+ setAddState({
+ message: `Request sent to ${result.target.projectName ?? 'Remotion Studio'}. Confirm adding ${library.displayName} inside Studio.`,
+ type: 'awaiting-confirmation',
+ });
+ } catch {
+ setAddState({
+ code: null,
+ message:
+ 'Could not send the request to Remotion Studio. Check that Studio is running, then try again.',
+ type: 'error',
+ });
+ }
+ }, [library.catalogUrl, library.displayName, requestLibraryAddition]);
+
+ let status: React.ReactNode = null;
+ if (addState.type === 'awaiting-confirmation') {
+ status = (
+ <p
+ aria-live="polite"
+ className={styles.successStatus}
+ id={statusId}
+ role="status"
+ >
+ {addState.message}
+ </p>
+ );
+ } else if (addState.type === 'error') {
+ status = (
+ <p className={styles.errorStatus} id={statusId} role="alert">
+ {addState.message}{' '}
+ {addState.code === 'no-compatible-studio' ? (
+ <a href="/docs/studio">How to start Studio.</a>
+ ) : addState.code === 'studio-upgrade-required' ? (
+ <a href="/docs/upgrading">How to upgrade Remotion.</a>
+ ) : null}
+ </p>
+ );
+ } else if (isLoading) {
+ status = (
+ <p aria-live="polite" className={styles.loadingStatus} id={statusId}>
+ Finding a compatible Remotion Studio…
+ </p>
+ );
+ }
+
+ return (
+ <li className={styles.card}>
+ {library.bannerUrl === null ? null : (
+ <div className={styles.preview}>
+ <img alt="" className={styles.previewImage} src={library.bannerUrl} />
+ </div>
+ )}
+ <div className={styles.content}>
+ <div className={styles.libraryRow}>
+ <h3 className={styles.libraryTitle}>
+ <a
+ className={styles.libraryLink}
+ href={library.browseUrl}
+ rel="noreferrer"
+ target="_blank"
+ >
+ {library.displayName}
+ </a>
+ </h3>
+ <button
+ aria-describedby={addState.type === 'idle' ? undefined : statusId}
+ aria-label={
+ isLoading
+ ? `Adding ${library.displayName} to Studio`
+ : `Add ${library.displayName} to Studio`
+ }
+ aria-busy={isLoading}
+ className={styles.addAction}
+ disabled={isLoading}
+ onClick={addToStudio}
+ title={
+ isLoading
+ ? `Adding ${library.displayName} to Studio`
+ : `Add ${library.displayName} to Studio`
+ }
+ type="button"
+ >
+ {isLoading ? (
+ '…'
+ ) : (
+ <>
+ <span aria-hidden="true" className={styles.addActionIcon}>
+ +
+ </span>
+ Add to Studio
+ </>
+ )}
+ <span aria-hidden="true" className={styles.touchTarget} />
+ </button>
+ </div>
+ {status}
+ </div>
+ </li>
+ );
+};
+
+export const ThirdPartyElementLibraryList: React.FC<{
+ readonly requestLibraryAddition: typeof addElementLibraryToStudio;
+}> = ({requestLibraryAddition}) => {
+ return (
+ <div className={styles.library}>
+ <ul className={styles.list} role="list">
+ {thirdPartyElementLibraries.map((library) => (
+ <ThirdPartyElementLibraryItem
+ key={library.catalogUrl}
+ library={library}
+ requestLibraryAddition={requestLibraryAddition}
+ />
+ ))}
+ </ul>
+ </div>
+ );
+};
+
+export const ThirdPartyElementLibraries: React.FC = () => {
+ return (
+ <ThirdPartyElementLibraryList
+ requestLibraryAddition={addElementLibraryToStudio}
+ />
+ );
+};
diff --git a/packages/docs/src/components/Elements/third-party-element-library-data.ts b/packages/docs/src/components/Elements/third-party-element-library-data.ts
new file mode 100644
index 0000000000..0dea7e2efd
--- /dev/null
+++ b/packages/docs/src/components/Elements/third-party-element-library-data.ts
@@ -0,0 +1,16 @@
+export type ThirdPartyElementLibrary = {
+ readonly bannerUrl: string | null;
+ readonly browseUrl: string;
+ readonly catalogUrl: string;
+ readonly displayName: string;
+};
+
+export const thirdPartyElementLibraries = [
+ {
+ bannerUrl:
+ 'https://remotion.media/elements/third-party-libraries/remocn.png',
+ browseUrl: 'https://remocn.dev/docs/components',
+ catalogUrl: 'https://remocn.dev/docs/typography',
+ displayName: 'Remocn',
+ },
+] as const satisfies readonly ThirdPartyElementLibrary[];
diff --git a/packages/docs/src/raw-markdown/replace-components.ts b/packages/docs/src/raw-markdown/replace-components.ts
index 522b9a3b66..476f04dd6c 100644
--- a/packages/docs/src/raw-markdown/replace-components.ts
+++ b/packages/docs/src/raw-markdown/replace-components.ts
@@ -7,6 +7,7 @@ import {
isElementCategory,
type ElementCategory,
} from '../components/Elements/element-library-data';
+import {thirdPartyElementLibraries} from '../components/Elements/third-party-element-library-data';
export type RawMarkdownComponentReplacement = {
readonly componentName: string;
@@ -137,6 +138,7 @@ const getInstallationMarkdown = (pkg: string) => {
};
const studioApiPath = path.join('docs', 'studio', 'api.mdx');
+const thirdPartyElementsPath = path.join('elements', 'libraries.mdx');
const renderElementLibraryMarkdown = (attributes: string) => {
const categoryAttribute = getStringAttribute({
@@ -181,6 +183,21 @@ const rawMarkdownComponentReplacements: readonly RawMarkdownComponentReplacement
removeImport:
/^import\s+\{\s*ElementLibrary\s*\}\s+from\s+['"]@site\/src\/components\/Elements\/ElementLibrary['"];?\s*\n/m,
},
+ {
+ componentName: 'ThirdPartyElementLibraries',
+ appliesTo: (sourcePath) =>
+ path.normalize(sourcePath).endsWith(thirdPartyElementsPath),
+ render: () =>
+ thirdPartyElementLibraries
+ .map(
+ (library) =>
+ `- [${library.displayName}](${library.browseUrl})\n - Element catalog: \`${library.catalogUrl}\``,
+ )
+ .join('\n'),
+ removeImport:
+ /^import\s+\{\s*ThirdPartyElementLibraries\s*\}\s+from\s+['"]@site\/src\/components\/Elements\/ThirdPartyElementLibraries['"];?\s*\n/m,
+ required: true,
+ },
{
componentName: 'Installation',
render: ({attributes}) => {