# Code area directive

The `sf-code-area` directive marks a text area as a code section and sets its attributes. You use the directive on top of your widget or designer view, so that custom widget code is displayed and styled in a specific way, for example, in the widget designer.

The `sf-code-area` directive is based on the CodeMirror text editor for code, version 2.18. For more information, see the official website of [CodeMirror](http://codemirror.net/).

> important **IMPORTANT**: When using this directive, make sure you add the the following on top of your view:
>
> * `@using Telerik.Sitefinity.Frontend.Mvc.Helpers;`
> * `@Html.CodeMirrorScriptReferences()`

## Attributes

You use the `sf-area-code` directive on top of the `<textarea>` element. The sf-area-code directive exposes the following attributes:

<table>
<tbody>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
<tr>
<td>

`sf-model`

</td>
<td>

Specific property, to which to bind the code section contents. It is a property of the widget model, which is serialized in the widget designer JavaScript code.\
For example:

* Widget model property when using the attribute in a frontend view
* Widget designer controller scope property when using the attribute in a widget designer

</td>
</tr>
<tr>
<td>

`placeholder`

</td>
<td>

The text placeholder displayed before you start typing text inside the code area, for example, <em>Enter code…</em> 

</td>
</tr>
<tr>
<td>

`sf-type`

</td>
<td>

The programming language, for example, JavaScript.

</td>
</tr>
<tr>
<td>

`sf-tab-mode`

</td>
<td>

Configures the behavior of the tabulation.

</td>
</tr>
<tr>
<td>

`sf-line-numbers`

</td>
<td>

Configures whether to display line numbers on the left.

</td>
</tr>
<tr>
<td>

`sf-match-brackets`

</td>
<td>

Configures whether to autocomplete closing bracket when typing an opening bracket.

</td>
</tr>
</tbody>
</table>

## Add a code area directive

Following is an example how to add the `sf-area-code` directive in the JavaScript code of the widget designer view of an *Embed code* widget. For more information, see [Embed code widget](https://www.progress.com/documentation/sitefinity-cms/embed-code-widget-mvc).

Add the directive and its attributes in the widget designer view of the *Embed code* widget:

```Razor
<textarea

 sf-code-area
      sf-type="javascript"
      sf-tab-mode="classic"
      sf-line-numbers="true"
      sf-match-brackets="true"
      sf-model="properties.InlineCode.PropertyValue"
      placeholder="@Html.Resource("Place code here")">

</textarea>
```
