Skip to content
BlinkpageBlinkpageDocs

Custom components

Build React components in Component Studio, preview them with your project theme, and upload them to use on any page.

On this page

A custom component is a React component that you write and add to a project. After you upload it, it appears in the Custom category of the block library and works like any built-in block.

#Before you begin

You need a Blinkpage project and a folder on your computer for your components. Node.js 18 or later and basic React knowledge help.

Install the Blinkpage component package in that folder:

bash
npm install @blinkpage/composer-tools react react-dom

#Write a component

Each component is a React class that extends Component, declares its editable props in the constructor, and is the default export. Each prop you declare becomes a field in the Content tab. See Component props reference for every prop type.

my-hero/index.tsx
import * as React from "react";import { Component } from "@blinkpage/composer-tools";import styles from "./styles.module.css";class MyHero extends Component {  constructor(props?: any) {    super(props, styles);    this.addProp({      type: "string",      key: "title",      displayer: "Title",      value: "Welcome to your site",    });    this.addProp({      type: "string",      key: "description",      displayer: "Description",      value: "Edit this text in the Content tab.",    });  }  static getName(): string {    return "My Hero";  }  render() {    return (      <section className={this.decorateCSS("hero")}>        <h2 className={this.decorateCSS("title")}>{this.getPropValue("title")}</h2>        <p className={this.decorateCSS("description")}>{this.getPropValue("description")}</p>      </section>    );  }}export default MyHero;

#Style the component

Wrap every class name in this.decorateCSS("name"), as the sample does, so the editor can scope your styles and let you change them in the Design tab. Use the theme variables so the component follows the project theme.

my-hero/styles.module.css
.hero {  padding: 80px 24px;  text-align: center;  font-family: var(--composer-font-family);  background: var(--composer-html-background);  border-bottom: 4px solid var(--composer-primary-color);}.title {  margin: 0 0 16px;  color: var(--composer-font-color-primary);}.description {  max-width: 600px;  margin: 0 auto;  color: var(--composer-font-color-primary);  opacity: 0.8;}

#Install Component Studio

Component Studio is the desktop app for building, previewing, and uploading custom components.

Coming soon

Component Studio does not have a public download yet. The next sections describe how it works for when it is available. Until then, upload components with the Blinkpage MCP server and its upload_component tool.

  1. Sign in

    Open Component Studio and click Sign in with your Blinkpage account. Your browser opens so you can finish signing in.

  2. Open your project

    On the Projects page, click the project you want to upload to.

  3. Click Link Folder and choose the folder that holds your components. The file list on the left shows every file and updates as you edit.

  4. Check the component list

    Studio lists each component it finds. Use Change Folder to link a different folder later.

Studio detects a component when a .tsx or .jsx file imports from the Blinkpage package, extends Component or a Base class, and default-exports the class.

Tip

If a component is missing from the list, check its import line, its extends clause, and that the class is the default export.

#Preview with your theme

  1. Open a preview

    Click a component in the list. Studio starts a preview that updates each time you save your code.

  2. Change the screen size

    Click Mobile, Tablet, or Desktop to check each layout.

  3. Open the theme panel

    Click Theme to open Theme Configuration. Change colors, fonts, and environment settings to see how the component reacts.

  4. Save or reset the theme

    Click Reset to discard your changes, or click Save to Project to keep them.

Warning: Warning

Save to Project writes the theme values to your project and changes every page. Use Reset if you only want to test.

#Upload a component

  1. Go back to the list

    Click Components in the preview header to return to the component list.

  2. Open the upload panel

    Click Upload. The Upload Components panel opens.

  3. Set the version and category

    Enter a whole number in Version, starting at 1. Leave Category as custom to find the component under Custom.

  4. Select components

    Click each component to upload, or click Select all.

  5. Upload

    Click Upload at the bottom of the panel. The button shows how many components you selected. Each component shows building, uploading, and then a success mark or an error message.

Warning: Warning

Your component CSS applies only to your own content. Selectors that target html, body, :root, or a bare * are rejected, and so is a custom property declared outside a selector.

Uploading a name at a version that already exists fails. Raise Version and upload again.

#Use a custom component on a page

  1. Open the editor

    Open your project and the page that needs the component.

  2. Open the block library

    In the left sidebar, open the Blocks tab.

  3. Open the Custom category

    Click Custom. Each uploaded version is listed with its number, for example "My Hero v1".

  4. Add the component

    Click the component to add it to the page.

  5. Edit its content

    Select the component and change its fields in the Content tab. See Content tab.

Uploaded components and their versions appear in the Custom category.

#Update or delete a component

To update a component, change your code and upload it again with a higher version. Both versions stay available. A page keeps the version it was placed with, so add the new version from the block library and remove the old block to switch.

To delete a component, remove it from your project:

  1. Open the Custom Components tab

    Open your project and click the Custom Components tab. The Uploaded Components list shows each component with its version and upload date.

  2. Find the component

    Type a name in Search components… to narrow the list.

  3. Delete it

    Click Delete in the row of the version, then confirm in the dialog.

The Custom Components tab lists every uploaded version.

Blinkpage blocks the deletion while a page uses the component, and the message names those pages. To delete several components at once, select their checkboxes and use the bulk delete action. Components that are still on a page are skipped.

#Next steps

Edit this page(opens in a new tab)