Docs
API Reference
<FieldLabel>

<FieldLabel>

Render a styled label when creating custom fields.

Interactive Demo
Example
import { FieldLabel } from "@measured/puck";
 
const CustomField = () => (
  <FieldLabel label="Title">
    <input />
  </FieldLabel>
);
 
const config = {
  components: {
    Example: {
      fields: {
        title: {
          type: "custom",
          render: MyCustomField,
        },
      },
    },
  },
};

Props

ParamExampleTypeStatus
labellabel: "Title"StringRequired
childrenchildren: <div />ReactNode-
classNameclassName: "MyLabel"String-
elel: false"label" | "div"-
iconicon: <svg />ReactNode-
readOnlyreadOnly: falseBoolean-

Required props

label

The label string for the fields.

import { FieldLabel } from "@measured/puck";
 
const CustomField = () => (
  <FieldLabel label="Title">
    <input />
  </FieldLabel>
);
 
// ...

Optional props

children

A node to render inside the FieldLabel's internal <label> element. You can also define your input element as a sibling.

import { FieldLabel } from "@measured/puck";
 
const CustomField = () => (
  <FieldLabel label="Title">
    <input />
  </FieldLabel>
);
 
// ...

className

Define a custom class for the field label.

import { FieldLabel } from "@measured/puck";
 
const CustomField = () => (
  <FieldLabel className="MyClass" label="Title">
    <input />
  </FieldLabel>
);
 
// ...

el

Specify whether to render a label or div. Defaults to "label".

import { FieldLabel } from "@measured/puck";
 
const CustomField = () => (
  <FieldLabel el="div" label="Title">
    <input />
  </FieldLabel>
);
 
// ...

icon

Render an icon before the label text. Puck uses lucide-react (opens in a new tab) internally.

import { FieldLabel } from "@measured/puck";
import { Globe } from "lucide-react";
 
const CustomField = () => (
  <FieldLabel icon={<Globe size="16" />} label="Title">
    <input />
  </FieldLabel>
);
 
// ...
Interactive Demo
Example

readOnly

Indicate to the user that this field is in a read-only state by showing a padlock icon to the right of the text.

import { FieldLabel } from "@measured/puck";
 
const CustomField = () => (
  <FieldLabel label="Title" readOnly>
    <input readOnly />
  </FieldLabel>
);
 
// ...
Interactive Demo
Example