@text
Add editable plain text areas to your components
The @text directive creates an editable plain text area within your component. This is ideal for headings, labels, button text, and any single-line or simple multi-line text content.
Syntax
@text("identifier")Or with additional parameters:
@text(name: "identifier", title: "Display Title", default: "Default text")Parameters
name
Yes
A unique identifier for the text area within the component
title
No
The label displayed in the editor interface
default
No
Default text to display when no content has been entered
Examples
Basic Text Area
Create a simple editable text area:
<h1>@text("heading")</h1>With Default Value
Provide default text that users can modify:
With Title for Editor
Add a descriptive title that appears in the editor interface:
Button with Conditional Text
Combine @text with conditionals to show text only when enabled:
Form Labels
Navigation Title
Using @text Inside an @each Loop
You can use the @text directive inside an @each loop to create unique editable text areas for each iteration. The loop index is automatically appended to the identifier, ensuring each text area remains distinct:
In this example, if the loop iterates three times, it will create three unique text areas, each independently editable.
Best Practices
Use descriptive identifiers - Choose names that clearly indicate the text's purpose (e.g.,
"heading","buttonLabel","siteTitle").Provide helpful defaults - Default text helps users understand the expected content and provides a starting point.
Add titles for clarity - The
titleparameter helps users identify the text area in the editor, especially when there are multiple text areas.
Related
Last updated
Was this helpful?

