Pass data from Builder or from your application directly to your custom component to customize styles or behaviors.
- Inputs to custom components in Builder are accessible to the component code through the component's props.
- Access dynamic values in Builder state within a custom component through the
builderStateproperty. - Pass data from your application directly into Builder state with the
dataattribute.
When a custom component is provided an input option, that value can be accessed directly within the component through props. This value is defined in code, but can be manipulated in Builder's Visual Editor.
For example, the custom component below, CustomTip, accepts a single input called text.
import { Builder } from "@builder.io/react";
Builder.registerComponent(CustomTip, {
name: "CustomTip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
});Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
For example, the custom component below, CustomTip, accepts a single input called text.
import { Builder } from "@builder.io/react";
Builder.registerComponent(CustomTip, {
name: "CustomTip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
});Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
For example, the custom component below, CustomTip, accepts a single input called text.
import { Builder } from "@builder.io/react";
Builder.registerComponent(CustomTip, {
name: "CustomTip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
});Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
For example, the custom component below, CustomTip, accepts a single input called text.
import { Builder } from "@builder.io/react";
Builder.registerComponent(CustomTip, {
name: "CustomTip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
});Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
For example, the custom component below, CustomTip, accepts a single input called text.
import { Builder } from "@builder.io/react";
Builder.registerComponent(CustomTip, {
name: "CustomTip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
});Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-svelte";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-vue";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-vue";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-qwik";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
For example, the custom component below, CustomTip, accepts a single input called text.
import { Builder } from "@builder.io/react";
Builder.registerComponent(CustomTip, {
name: "CustomTip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
});Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
In the code snippet below, a CustomTip component is imported. That component is then passed to an object where custom components and their associated options are defined.
When using custom components, you must pass an array of components, which is demonstrated by the customComponents variable.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your content entry, pass in the custom components with the customComponents prop.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
/>
);
}Access the value within the custom component by referencing the value directly within props.
// CustomTip.tsx
interface CustomTipProps {
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className="custom-tip">
<h2>Tip</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
Within the Visual Editor, you can set the value by clicking on the component and then going to the Options panel. There, change the input's value.
In the video below, the Options panel contains the text state value. When updated, the text within the CustomTip component is updated on the page.
By creating a custom input, you add user-defined state to a custom component within the Visual Editor. Your custom component will have access to that value as well.
In the video below, a new custom input is created within the Content Inputs panel called calloutText. This input is given a default value of "Tip".
Within your custom component, access the calloutText value by accessing builderState.
interface CustomTipProps {
builderState: { state: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderState.state.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
Within your custom component, access the calloutText value by accessing builderState.
interface CustomTipProps {
builderState: { state: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderState.state.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
Within your custom component, access the calloutText value by accessing builderState.
interface CustomTipProps {
builderState: { state: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderState.state.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
Within your custom component, access the calloutText value by accessing builderState.
interface CustomTipProps {
builderState: { state: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderState.state.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
Within your custom component, access the calloutText value by accessing builderState.
interface CustomTipProps {
builderState: { state: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderState.state.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
Within your custom component, access the calloutText value by accessing builderState.
interface CustomTipProps {
builderState: { state: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderState.state.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
To access custom inputs, update your custom component's options object to include the shouldReceiveBuilderProps key. The value should be an object with builderContext set to the value true.
import CustomTip from "./custom-components/CustomTip";
const customTipComponent = {
component: CustomTip,
name: "Custom Tip",
shouldReceiveBuilderProps: {
builderContext: true,
},
inputs: [
{
name: "text",
type: "text",
defaultValue: "Hello, Builder!",
required: true,
},
],
};
const customComponents = [
customTipComponent,
// Other custom components...
];Within your custom component, access the calloutText value by accessing builderContext. This object contains another object called rootState, which contains your custom values.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
const callout = props.builderContext.rootState.calloutText || "Tip";
return (
<div className="custom-tip">
<h2>{callout}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;This value can be changed within the Data tab under Content State.
In the video below, the calloutText value is changed from "Tip" to "Helpful hint." This changes the display of the custom component.
You may also access application state within your custom components. This can be useful, for example, when you want to be able to influence the presentation of a component based on internal values within your application.
When the BuilderComponent below is rendered, the data attribute is set to an object which contains a key called theme and points towards a value that is set by state.
import { Builder, BuilderComponent } from "@builder.io/react";
import { useState } from "react";
import CustomTip from "../components/CustomTip";
// Register your custom component
Builder.registerComponent(CustomTip, {
name: "CustomTip",
// ...
});
// Pass data into the component
function CustomComponent() {
const [content, setContent] = useState<any>(null);
const [theme, setTheme] = useState("dark");
// ... Request data and set the content and theme.
return (
<BuilderComponent
content={content}
model={BUILDER_MODEL}
data={{
theme: theme,
}}
/>
);
}
export default CustomComponent;A special property is added to your props, called builderState. This will include state values provided by you in the application and other state values provided to Builder.
interface CustomTipProps {
builderState: { state: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className={`custom-tip ${props.builderState.state.theme}`}>
<h2>{props.builderState.state.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the BuilderComponent below is rendered, the data attribute is set to an object which contains a key called theme and points towards a value that is set by state.
import { Builder, BuilderComponent } from "@builder.io/react";
import { useState } from "react";
import CustomTip from "../components/CustomTip";
// Register your custom component
Builder.registerComponent(CustomTip, {
name: "CustomTip",
// ...
});
// Pass data into the component
function CustomComponent() {
const [content, setContent] = useState<any>(null);
const [theme, setTheme] = useState("dark");
// ... Request data and set the content and theme.
return (
<BuilderComponent
content={content}
model={BUILDER_MODEL}
data={{
theme: theme,
}}
/>
);
}
export default CustomComponent;A special property is added to your props, called builderState. This will include state values provided by you in the application and other state values provided to Builder.
interface CustomTipProps {
builderState: { state: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className={`custom-tip ${props.builderState.state.theme}`}>
<h2>{props.builderState.state.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the BuilderComponent below is rendered, the data attribute is set to an object which contains a key called theme and points towards a value that is set by state.
import { Builder, BuilderComponent } from "@builder.io/react";
import { useState } from "react";
import CustomTip from "../components/CustomTip";
// Register your custom component
Builder.registerComponent(CustomTip, {
name: "CustomTip",
// ...
});
// Pass data into the component
function CustomComponent() {
const [content, setContent] = useState<any>(null);
const [theme, setTheme] = useState("dark");
// ... Request data and set the content and theme.
return (
<BuilderComponent
content={content}
model={BUILDER_MODEL}
data={{
theme: theme,
}}
/>
);
}
export default CustomComponent;A special property is added to your props, called builderState. This will include state values provided by you in the application and other state values provided to Builder.
interface CustomTipProps {
builderState: { state: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className={`custom-tip ${props.builderState.state.theme}`}>
<h2>{props.builderState.state.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the BuilderComponent below is rendered, the data attribute is set to an object which contains a key called theme and points towards a value that is set by state.
import { Builder, BuilderComponent } from "@builder.io/react";
import { useState } from "react";
import CustomTip from "../components/CustomTip";
// Register your custom component
Builder.registerComponent(CustomTip, {
name: "CustomTip",
// ...
});
// Pass data into the component
function CustomComponent() {
const [content, setContent] = useState<any>(null);
const [theme, setTheme] = useState("dark");
// ... Request data and set the content and theme.
return (
<BuilderComponent
content={content}
model={BUILDER_MODEL}
data={{
theme: theme,
}}
/>
);
}
export default CustomComponent;A special property is added to your props, called builderState. This will include state values provided by you in the application and other state values provided to Builder.
interface CustomTipProps {
builderState: { state: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className={`custom-tip ${props.builderState.state.theme}`}>
<h2>{props.builderState.state.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the BuilderComponent below is rendered, the data attribute is set to an object which contains a key called theme and points towards a value that is set by state.
import { Builder, BuilderComponent } from "@builder.io/react";
import { useState } from "react";
import CustomTip from "../components/CustomTip";
// Register your custom component
Builder.registerComponent(CustomTip, {
name: "CustomTip",
// ...
});
// Pass data into the component
function CustomComponent() {
const [content, setContent] = useState<any>(null);
const [theme, setTheme] = useState("dark");
// ... Request data and set the content and theme.
return (
<BuilderComponent
content={content}
model={BUILDER_MODEL}
data={{
theme: theme,
}}
/>
);
}
export default CustomComponent;A special property is added to your props, called builderState. This will include state values provided by you in the application and other state values provided to Builder.
interface CustomTipProps {
builderState: { state: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className={`custom-tip ${props.builderState.state.theme}`}>
<h2>{props.builderState.state.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-svelte";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-vue";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-vue";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-qwik";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
When the BuilderComponent below is rendered, the data attribute is set to an object which contains a key called theme and points towards a value that is set by state.
import { Builder, BuilderComponent } from "@builder.io/react";
import { useState } from "react";
import CustomTip from "../components/CustomTip";
// Register your custom component
Builder.registerComponent(CustomTip, {
name: "CustomTip",
// ...
});
// Pass data into the component
function CustomComponent() {
const [content, setContent] = useState<any>(null);
const [theme, setTheme] = useState("dark");
// ... Request data and set the content and theme.
return (
<BuilderComponent
content={content}
model={BUILDER_MODEL}
data={{
theme: theme,
}}
/>
);
}
export default CustomComponent;A special property is added to your props, called builderState. This will include state values provided by you in the application and other state values provided to Builder.
interface CustomTipProps {
builderState: { state: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
return (
<div className={`custom-tip ${props.builderState.state.theme}`}>
<h2>{props.builderState.state.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;When the Content component below is rendered, the data attribute is set to an object which contains a key called theme.
import { Content } from "@builder.io/sdk-react";
function MyContentEntry() {
const [theme, setTheme] = useState("dark");
const [content, setContent] = useState<BuilderContent | null>(null);
// Your component details...
return (
<Content
apiKey={BUILDER_API_KEY}
content={content}
model={BUILDER_MODEL}
customComponents={customComponents}
data={{ theme: theme }}
/>
);
}This value is also be accessible withinbuilderContext.rootState.
interface CustomTipProps {
builderContext: { rootState: { calloutText: string; theme: string } };
text: string;
}
const CustomTip = (props: CustomTipProps) => {
console.log("CustomTip props:", props);
return (
<div className={`custom-tip ${props.builderContext.rootState.theme}`}>
<h2>{props.builderContext.rootState.calloutText || "Tip"}</h2>
<p>{props.text}</p>
</div>
);
};
export default CustomTip;
Read more about binding data within the Data binding overview. To learn how to add more values to state directly from Builder, visit Content inputs.