editable() Function for Sass Metadata in SuiteCommerce
The editable() function exposes Sass variables for SuiteCommerce, allowing flexible metadata like type, label, and options.
The editable() function is essential for exposing Sass variables within SuiteCommerce, providing functionalities for customization and user interface enhancements. This function is called using a specific structure in comments following variable definitions in your Sass files.
How Does the editable() Function Work?
The editable() function takes a JSON object that includes several properties to define the behavior and appearance of Sass variables:
type: Required. Determines the variable's type. Accepted values are:color: Utilizes a color picker in the SuiteCommerce Management Tool (SMT).string: Represents a string value (e.g., font style or size).
Note: Only color and string are supported as type values. For numbers or fonts, use a string format.
-
label: Optional. Defines a user-friendly name for the variable displayed in the SMT. If omitted, the variable name is shown instead. -
description: Optional. Provides a detailed explanation of the variable. -
options: Optional. An array to limit possible values for dropdown selection in SMT. This is useful to provide predefined choices instead of manual input.
Code Examples
Here are examples of how to declare the editable() function for various variable types:
Exposing a Color Variable
To expose a color variable using inline notation:
$sc-primary-color: red; // editable({"type": "color", "label": "Primary Color"})Or using block notation:
$sc-primary-color: red; /* editable({ "type": "color", "label": "Primary Color", "description": "Used mainly for 'call to action' elements."})*/Limiting Selections with Options
You can enhance user experience by specifying options within the editable() function. Here’s how:
Font Weight Example
When declaring font weights:
1$base-font-weight: 200; /* editable({2 "type": "string",3 "label": "Font Weight",4 "options": [5 {"value": 200, "text": "light"},6 {"value": 400, "text": "normal"},7 {"value": 800, "text": "bold"}]8}) */Color Example
To display color options instead of allowing free text input:
1$feedback-color: white; /* editable({2 "type": "color",3 "label": "Feedback Color",4 "options": [5 {"value": "white", "text": "normal"},6 {"value": "black", "text": "contrast"},7 {"value": "#ededed", "text": "low contrast"}8 ]9}) */Important Notes
- Comments must immediately follow variable declarations to ensure proper association between the variable and its metadata. Use this structure to prevent processing errors.
Key Takeaways
- The
editable()function is crucial for enhancing the user interface in SuiteCommerce. - It supports specifying variable types, labels, descriptions, and dropdown options.
- Using proper formatting is essential to link variables and metadata correctly in Sass files.
Frequently Asked Questions (4)
How do I use the editable() function to expose a color variable in SuiteCommerce?
What types are supported by the editable() function for Sass variables in SuiteCommerce?
Can I specify a list of allowed values for a Sass variable in SuiteCommerce using editable()?
What happens if the editable() comments are not immediately following the variable declarations?
Was this article helpful?
More in SuiteCloud Development Framework
- SuiteCloud CLI Prerequisites for Development in NetSuite 2026.1
Updated for NetSuite 2026.1, adding links for SuiteCloud CLI and account setup. TL;DR: To use the SuiteCloud Developer Assistant effectively, ensure you meet
- Enhancements to Custom Tool Scripts in NetSuite 2026.1
NetSuite 2026.1 improves custom tool scripts with execution logs, management page, and binary file support. TL;DR Opening
- SuiteCloud CLI for Node.js: New Features in NetSuite 2026.1
Explore new features in SuiteCloud CLI for Node.js for streamlined development in NetSuite 2026.1.
- beforeUndeploy Installation Hook in NetSuite 2026.1
Introducing the beforeUndeploy installation hook in NetSuite 2026.1 for custom pre-uninstall logic in SuiteApps.
Advertising
Reach SuiteCloud Development Framework Professionals
Put your product in front of NetSuite experts who work with SuiteCloud Development Framework every day.
Sponsor This Category