Skip to main content

Code

The Code component allows users to input multi-line code snippets with configurable options such as fullscreen, language, size, and showSuggestions. These properties enable flexible integration and enhanced usability for various use cases.

Examples

Simple code editor with basic configuration.

Enter your code here
A simple code editor with basic features

Form Data:
{}

Field Properties

Detailed descriptions of each field property are essential for understanding how to configure and utilize the Code component effectively.

NameDescriptionType
displayNameLabel shown above the code fieldstring
displayTypeType of the field to be displayedstring
placeholderHint shown in the code fieldstring
requiredIndicates if the field is mandatoryboolean
descriptionAdditional description below the code fieldstring
fullscreenToggle for enabling fullscreen modeboolean
languageProgramming language of the code snippetstring
sizeSize of the code field (xs, sm, md, lg)enum
showSuggestionsToggle to show or hide suggestionsboolean
showCopyToClipboardOption to enable copy to clipboard functionalityboolean
showInfoIconToggle to show or hide an informational iconboolean
allowDynamicEnable static and dynamic code snippets for custom suggestionsboolean
showHtmlPreviewToggle to display a preview of HTML rendering the code snippetboolean
heightSet the height of the code field (note: you need to pass size property along with height)string
readOnlyA readonly field is not editable and value cannot be changedboolean

Field Properties - Validation Details

The validation settings within the Code component are crucial for ensuring that user input meets specific requirements. Here’s a breakdown of the available validation properties:

PropertyDescription
requiredBoolean value that specifies whether entering data into the field is mandatory.
infoDetailProvides additional information related to the field. Can be used to display messages like hints or guidelines to users.
requiredDetailContains the specific properties related to required validation, such as custom error messages.
minLengthSpecifies the minimum number of characters allowed in the input.
maxLengthSpecifies the maximum number of characters allowed in the input.
minSpecifies the minimum value allowed for number inputs, with support for dynamic values.
maxSpecifies the maximum value allowed for number inputs, also supporting dynamic conditions.
patternA regex pattern that the input must match to be considered valid.
validateA function for custom validation logic, which can return a boolean or an error message.