A unique string that identifies the component for Makeswift to
render. Don’t change the type once you use the component in
the Makeswift builder.
If this value changes after you use the component in the Makeswift builder, the component will appear as a “Component not found” block. To fix this, restore the type to the original value, or delete this component and re-add add it to the page.
A boolean that determines whether or not this component will be wrapped in a built-in <Suspense> boundary.
Defaults to true. Set this to false if your component already includes its own <Suspense> boundary.Added in v0.26.0.
This example shows how to register a Box component. 'box' is the value for type, which must
be unique, as Makeswift uses this value to identify the component. This value shouldn’t change once you use the
component in the Makeswift builder. 'Box' is the label, which appears in
the Makeswift builder. The example applies a Style control to the
className prop.
This example shows how to register a Cube and a Sphere component under a “Visuals” section. In each
components’ label, use slashes to separate the section name and component name. In the Makeswift
builder, both components appear under the same Visuals collapsible section:
By default, the Makeswift runtime wraps registered components in a built-in <Suspense> boundary to
transparently enable efficient server-side streaming and asynchronous data fetching. If your component
already includes its own <Suspense> boundary, you can disable the built-in one by setting the
builtinSuspense option to false:
This example shows how to register an ImageGallery component with a custom icon. We
import ComponentIcon from @makeswift/runtime and pass
ComponentIcon.Gallery as the icon for our component.
You can find all available icons in the icons list section.
In the builder
component tray, we can see our component with the selected icon.
This example shows how to add a Circle component with a rich description. We
can define a description string using markdown formatting, and pass it into the component description field.
Copy
Ask AI
const mdDescription = `# This is a larger headingThis is some text at the top of here[](https://www.youtube.com/watch?v=dQw4w9WgXcQ)## This is a smaller headingThis is a **description** about this component, click to [learn more](https://www.youtube.com/watch?v=dQw4w9WgXcQ).* First Item* Second itemThis is a line with some \`\`<code/>\`\``
As you register more components in makeswift/components.tsx, you may notice this file growing rather large. To keep your codebase organized, we recommend breaking out your Makeswift registration code into separate files and co-locating it with your component file.For example, if you have a Box component, you can create a Box.makeswift.ts file next to your Box.tsx file. This file will contain the registration code for the Box component.
Makeswift does not rely on this naming convention. Feel free to use
whatever naming convention you prefer.
Then update your makeswift/components.tsx file to import all of the component registrations, like so:
makeswift/components.ts
Copy
Ask AI
import "@/components/Box/Box.makeswift";import "@/components/Cube/Cube.makeswift";import "@/components/Sphere/Sphere.makeswift";import "@/components/Circle/Circle.makeswift";/* * Add all of your component registrations here */
The file makeswift/components.ts should be imported wherever you use <ReactRuntimeProvider> in your app.