<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextFieldCell",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextFieldCell"
  },
  "title" : "NSTextFieldCell"
}
-->

# NSTextFieldCell

An object that enhances the text display capabilities of a cell.

```
class NSTextFieldCell
```

## Overview

The [`NSTextFieldCell`](/documentation/AppKit/NSTextFieldCell) class adds to the text display capabilities of the [`NSCell`](/documentation/AppKit/NSCell) class by allowing you to set the color of both the text and its background. You can also specify whether the cell draws its background at all.

All of the methods declared by this class are also declared by the [`NSTextField`](/documentation/AppKit/NSTextField) class, which uses [`NSTextFieldCell`](/documentation/AppKit/NSTextFieldCell) objects to draw and edit text. The [`NSTextField`](/documentation/AppKit/NSTextField) cover methods call the corresponding [`NSTextFieldCell`](/documentation/AppKit/NSTextFieldCell) methods.

Placeholder strings, set using the [`placeholderString`](/documentation/AppKit/NSTextFieldCell/placeholderString) or [`placeholderAttributedString`](/documentation/AppKit/NSTextFieldCell/placeholderAttributedString) property, appear in the text field cell if the actual string is `nil` or an empty string. They’re drawn in gray on the cell and aren’t archived in the “pre-10.2” nib format.

### Designated Initializers

When subclassing `NSTextFieldCell` you must implement the designated initializers [`init(coder:)`](/documentation/AppKit/NSCell/init(coder:)) and [`init(textCell:)`](/documentation/AppKit/NSCell/init(textCell:)).

## Topics

### Creating a Text Field Cell

[`init(textCell:)`](/documentation/AppKit/NSTextFieldCell/init(textCell:))

Initializes a text field cell that displays the specified string.

[`init(coder:)`](/documentation/AppKit/NSTextFieldCell/init(coder:))

Initializes a text field cell from data in the provided unarchiver.

### Setting the Text Color

[`textColor`](/documentation/AppKit/NSTextFieldCell/textColor)

The color to use to draw the cell’s text.

### Setting the Bezel Style

[`bezelStyle`](/documentation/AppKit/NSTextFieldCell/bezelStyle)

The bezel style to use when drawing the text field.

[`NSTextField.BezelStyle`](/documentation/AppKit/NSTextField/BezelStyle-swift.enum)

The style of bezel the text field displays.

### Controlling the Background

[`backgroundColor`](/documentation/AppKit/NSTextFieldCell/backgroundColor)

The color of the cell’s background.

[`drawsBackground`](/documentation/AppKit/NSTextFieldCell/drawsBackground)

A Boolean value that indicates whether the cell draws its background color.

### Managing the Field Editor

[`setUpFieldEditorAttributes(_:)`](/documentation/AppKit/NSTextFieldCell/setUpFieldEditorAttributes(_:))

Allows the cell to set up the field editor’s attributes before editing begins.

[`setWantsNotificationForMarkedText(_:)`](/documentation/AppKit/NSTextFieldCell/setWantsNotificationForMarkedText(_:))

Directs the cell’s associated field editor to post text change notifications.

### Managing Placeholder Strings

[`placeholderString`](/documentation/AppKit/NSTextFieldCell/placeholderString)

The placeholder text for the cell, specified as a plain text string.

[`placeholderAttributedString`](/documentation/AppKit/NSTextFieldCell/placeholderAttributedString)

The placeholder text for the cell, specified as an attributed string.

### Accessing Input Source Locales

[`allowedInputSourceLocales`](/documentation/AppKit/NSTextFieldCell/allowedInputSourceLocales)

An array of locale identifiers that represent the allowed input sources when the text field has the keyboard focus.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)