Skip to content

Add customizable cursor style for TextField#53

Open
arcticleo wants to merge 1 commit intorensbreur:mainfrom
arcticleo:customizable-textfield-cursor
Open

Add customizable cursor style for TextField#53
arcticleo wants to merge 1 commit intorensbreur:mainfrom
arcticleo:customizable-textfield-cursor

Conversation

@arcticleo
Copy link

With this proposed change, TextField gains the ability to customize its cursor appearance through a new environment value. The cursor can now be displayed as either an underline (default) or as an inverted block (similar to many terminal editors).

This enhancement is fully backwards compatible - the default cursor style remains as an underline, preserving existing behavior. Projects that want a block cursor can opt in using the new .textFieldCursorStyle(_:) view modifier.

Changes include:

  • New TextFieldCursorStyle enum with .underline and .block cases
  • New textFieldCursorStyle environment value (defaults to .underline)
  • New .textFieldCursorStyle(_:) view modifier for easy customization
  • Updated TextField rendering to respect the cursor style setting

Example usage:

TextField(placeholder: "Search...") { query in
  // handle input
}
.textFieldCursorStyle(.block)

With this proposed change, TextField gains the ability to customize its cursor appearance through a new environment value. The cursor can now be displayed as either an underline (the traditional style) or as an inverted block (similar to many terminal editors).

This enhancement is fully backwards compatible - the default cursor style remains as an underline, preserving existing behavior for all applications. Projects that want a block cursor can opt in using the new .textFieldCursorStyle(_:) view modifier.

Changes include:

- New TextFieldCursorStyle enum with .underline and .block cases
- New textFieldCursorStyle environment value (defaults to .underline)
- New .textFieldCursorStyle(_:) view modifier for easy customization
- Updated TextField rendering to respect the cursor style setting

Example usage:

    TextField(placeholder: "Search...") { query in
      // handle input
    }
    .textFieldCursorStyle(.block)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant