Slot

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

Syntax

1// Prop definition
2props.Slot({
3 name: string,
4 group?: string,
5 tooltip?: string,
6})
7
8// Prop value
9ReactNode

Prop definition

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

1props.Slot({
2 name: string,
3 group?: string,
4 tooltip?: string,
5})

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
1import { declareComponent } from '@webflow/react';
2import { props } from '@webflow/data-types';
3import { MyComponent } from "./MyComponent";
4
5export default declareComponent(MyComponent, {
6 name: "MyComponent",
7 description: "A component with a Slot property",
8 props: {
9 children: props.Slot({
10 name: "Content",
11 group: "Content"
12 })
13 }
14});

Prop value

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

PropType.Slot
1ReactNode

Properties

  • n/a

Webflow properties panel

Slot property in the Webflow panel

Example

MyComponent.tsx
1import React from "react";
2
3interface MyComponentProps {
4children?: React.ReactNode;
5}
6
7export const MyComponent = ({ children }: MyComponentProps) => {
8return (
9 <div className="container">
10 {children}
11 </div>
12);
13}

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