FigmaComponent.text
The FigmaComponent.text
component renders text elements from your Figma design, preserving all typography styles including font family, size, weight, color, and alignment.
Basic Usage
FigmaComponent.text(
"my_text_component",
text: "Custom text content", // Override the text content
)
Parameters
Parameter | Type | Description |
---|---|---|
componentName | String | The name of the text component in your Figma file |
text | String | The text content to display (overrides the original text from Figma) |
How It Works
- The component looks for a text node with the specified name in your Figma file
- It preserves all text styling from Figma (font, size, weight, color, etc.)
- It renders the specified text content, replacing the original text from Figma
- The result is a Flutter
Text
widget with all the styling from your Figma design
Localized Text
FigmaComponent.text(
"login_button_label",
text: AppLocalizations.of(context).loginButtonText,
)
Formatted Text
// Price with currency formatting
FigmaComponent.text(
"product_price",
text: "\$${product.price.toStringAsFixed(2)}",
)
// Date formatting
FigmaComponent.text(
"event_date",
text: DateFormat('MMM d, yyyy').format(event.date),
)
Handling Text Overflow
The FigmaComponent.text
component will respect the text styles and constraints from your Figma design. If your text content is too long for the container:
- Text will wrap according to the text wrapping settings in your Figma design
- If the text still doesn't fit, it will be truncated with an ellipsis
Best Practices
- Design with dynamic content in mind: Create text components in Figma that can accommodate varying content lengths
- Use text styles in Figma: Create and use text styles in Figma for consistent typography across your design
- Keep placeholders in Figma: Use descriptive placeholder text in Figma (e.g., "User Name" instead of "John Doe")
- Consider localization: Design text components with enough space for translations
This component is perfect for labels, titles, paragraphs, and any text content in your app.