Slot

Add a Slot property to your component so designers can insert any child component

Syntax

// Prop definition
props.Slot({
name: string,
group?: string,
tooltip?: string,
})
// Prop value
ReactNode

Prop definition

Define the Slot prop in your Webflow code component with a name. Optionally, you can add a group and tooltip text.

props.Slot({
name: string,
group?: string,
tooltip?: string,
})

You can use props.Children as an alias for the props.Slot prop type.

Properties

  • name: The name for the property.
  • group: The group for this property. (optional)
  • tooltip: The tooltip for the property. (optional)

Example

MyComponent.webflow.tsx
import { declareComponent } from '@webflow/react';
import { props } from '@webflow/data-types';
import { MyComponent } from "./MyComponent";
export default declareComponent(MyComponent, {
name: "MyComponent",
description: "A component with a Slot property",
props: {
children: props.Slot({
name: "Content",
group: "Content"
})
}
});

Prop value

The Slot prop provides child components to your React component as a single ReactNode object.

PropType.Slot
ReactNode

Properties

  • n/a

Webflow properties panel

Slot property in the Webflow panel

Example

MyComponent.tsx
import React from "react";
interface MyComponentProps {
children?: React.ReactNode;
}
export const MyComponent = ({ children }: MyComponentProps) => {
return (
<div className="container">
{children}
</div>
);
}

When to use

Use a Slot prop when you want designers to:

  • Insert child components
  • Create flexible layout containers
  • Build wrapper components

Best practices

  • Handle missing children gracefully
  • Consider layout and spacing for child content
  • Test with various component types