Attribute settings
InlayComponent is deliberately an empty marker interface - a component's settings can be declared two different ways, and neither is forced on the other. This page covers declaring a setting directly on the constructor parameter it maps to. See Fluent settings for the alternative (and for repeaters and groups, which attributes can't express).
Field types
| Attribute | Field type |
| --- | --- |
| Text | Single-line text |
| Textarea | Multi-line text |
| Richtext | Multi-line text (currently unsanitized HTML if you render it raw - see Current limitations) |
| Number | Integer or float |
| Toggle | Boolean |
| Select | One value from a labeled set (a backed enum, or a literal options array) |
| Image | A single uploaded file path |
| Link | Hydrates to LinkValue (label, url, openInNewTab) - see Links |
There's no Repeater or Group attribute - a repeatable or grouped item schema has no single constructor parameter to attach to, so those two are fluent-only.
Declaring a setting
use WearePixel\Inlay\Attributes\Number;
use WearePixel\Inlay\Attributes\Select;
use WearePixel\Inlay\Attributes\Text;
use WearePixel\Inlay\Attributes\Toggle;
final class Hero extends Component implements InlayComponent
{
public function __construct(
#[Text(label: 'Heading', maxLength: 80, required: true)]
public string $heading = 'Welcome',
#[Toggle(label: 'Show call to action')]
public bool $showCta = false,
#[Number(label: 'Columns')]
public int $columns = 2,
#[Select(label: 'Image size')]
public ImageSize $imageSize = ImageSize::Large,
) {}
// ...
}
Every attribute accepts label, help, required, and visibleWhen (an array pair: [fieldName, value] - see Organizing the inspector). Text additionally accepts maxLength; Select additionally accepts options (only needed when the constructor type isn't a backed enum - see Enums).
Constructor defaults are authoritative
For every top-level setting, the constructor parameter's own default value and nullability are the exclusive source of truth:
- A parameter with a default (
public string $heading = 'Welcome') uses that as the setting's default. - A nullable parameter with no default (
public ?string $subheading = null) is fine too -nullis a valid default. - A required, non-nullable parameter with no default (
public string $heading) fails registration immediately with a clear exception naming the component and the setting.
There's deliberately no schema-level .default() for a top-level setting - it would create two sources of truth for the same thing. See Fluent settings for the one place .default() is meaningful.