By default, Builder applies default styles to components that are added to a page or section within Builder. These default styles help keep things in order and looking tidy, and are usually low impact, but sometimes users want to have complete control over all styling on the page and as a result want to completely remove these defaults.
You can use the data model to create a theme with your own global default styles that can be utilized in all the builder content using data binding, for reference you can refer to the below link
Builder also allows you to add your own default styles to your custom components when registering them with Builder. This is done through the defaultStyles property in the registerComponent() method.
Here’s a quick overview of how to achieve this:
Register your component: You can specify default styles through the defaultStyles property when registering your component.
Set default styles: Provide a CSS-in-JS object to the defaultStyles property.
Below is an example of how you can register a component with default styles:
import React from 'react';
import { Builder } from '@builder.io/react';
// Define your custom component
const HelloWorldComponent = (props) => (
<div style={props.styles}>
<h1>{props.text}</h1>
</div>
);
// Register the component with Builder and include default styles
Builder.registerComponent(HelloWorldComponent, {
name: 'Hello World',
defaultStyles: {
textAlign: 'center',
fontSize: '20px',
color: 'blue',
},
// Define inputs if needed
inputs: [{ name: 'text', type: 'string', defaultValue: 'Hello, Builder!' }],
});