For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
GuidesExamplesChangelog
GuidesExamplesChangelog
  • Code Components
    • Introduction
    • Component Architecture
    • Styling Components
  • Importing Code Components
    • Quick start: Importing code components
    • Installation
    • Define a code component
    • Bundling & Import
  • Generating AI Code Components
    • Quick start: Generating AI code components
  • FAQs
    • FAQs and troubleshooting
  • Reference
    • Webflow CLI
    • Prop Types
      • Text
      • Rich Text
      • Text Node
      • Link
      • Image
      • Number
      • Boolean
      • Variant
      • Visibility
      • Slot
      • ID
LogoLogo
Resources
Get started
On this page
  • Syntax
  • Prop definition
  • Properties
  • Example
  • Prop value
  • Properties
  • Webflow properties panel
  • Example
  • When to use
ReferenceProp Types

ID

Was this page helpful?
Previous
Built with

Add an ID property to your component so designers can set unique identifiers on HTML elements.

The ID prop creates a text input for element IDs, making it easy to target elements with CSS or JavaScript.

Syntax

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

Prop definition

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

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

Properties

  • name: The name for the property.
  • group: The group for this property (optional).
  • tooltip: The tooltip for this 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 an ID property",
8 props: {
9 id: props.Id({
10 name: "Element ID",
11 group: "Info"
12 })
13 }
14});

Prop value

The ID prop provides a string to your React component:

PropType.Id
1string

Properties

  • n/a

Webflow properties panel

ID property in the Webflow panel

Example

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

When to use

Use an ID prop when you want designers to:

  • Set unique identifiers for CSS targeting
  • Connect form labels to inputs
  • Enable JavaScript interactions