Please fill out as many of the following questions as possible so we can help you promptly! If you don’t know how to answer or it does not apply, feel free to remove it or leave it blank.
Builder content link
Builder public api key
d1ad2e591d574847973883381445c892
What are you trying to accomplish
- I am attempted to register custom components based on what the documentation.
Screenshots or video link
Code stack you are integrating Builder with
- NextJs, ReactJs
Reproducible code example
Annoucement.tsx
interface AnnoucementProps {
enabled?: boolean;
text?: string;
buttonText?: string;
buttonLink?: string;
}
const Annoucement: React.FC<AnnoucementProps> = ({
enabled,
text,
buttonText,
buttonLink
}) => {
return (
enabled &&
<div className="bg-pb-yellow-100 rounded-lg p-4 flex flex-col gap-x-2 text-xs font-medium md:flex-row justify-center items-center text-center gap-y-2">
<p>{text}</p>
<a
href={buttonLink}
className="bg-pb-yellow-300 hover:bg-pb-yellow-200 text-white font-medium px-4 py-2 rounded-lg transition duration-300 ease-in-out text-xs"
>
{buttonText}
</a>
</div>
)
}
export default Annoucement;
builder-register.ts
"use client";
import { Builder } from "@builder.io/react";
import dynamic from "next/dynamic";
import Annoucement from "./components/Annoucement/Annoucement";
Builder.registerComponent(Annoucement, {
name: "Annoucement",
inputs: [
{
name: "buttonLink",
type: "string",
defaultValue: "https://google.com",
},
{
name: "buttonText",
type: "string",
defaultValue: "Button Text",
},
{
name: "enabled",
type: "boolean",
defaultValue: true,
},
{
name: "text",
type: "string",
defaultValue: "Hello World",
},
],
});