Text input
Text input is used to set a value that is a single line of text.
On this page
TextField
component is part of the Primer forms framework. If you're building a form, please consider using the framework instead of this standalone component.Description
Text fields are single-line text inputs rendered as <input type="text">
in HTML.
Arguments
Name | Type | Default | Description |
---|---|---|---|
size | Symbol | N/A | The size of the field. One of |
full_width | Boolean | N/A | When set to |
name | String | N/A | Value for the HTML name attribute. |
id | String | N/A | Value for the HTML id attribute. |
class | String | N/A | CSS classes to include in the input's HTML |
classes | Array | N/A | CSS classes to include in the input's HTML |
caption | String | N/A | A string describing the field and what sorts of input it expects. Displayed below the input. |
label | String | N/A | Label text displayed above the input. |
visually_hide_label | Boolean | N/A | When set to |
disabled | Boolean | N/A | When set to |
hidden | Boolean | N/A | When set to |
invalid | Boolean | N/A | If set to |
validation_message | String | N/A | A string displayed between the caption and the input indicating the input's contents are invalid. This option is, by default, set to the first Rails validation message for the input (assuming the form is associated with a model object). Use |
label_arguments | Hash | N/A | Attributes that will be passed to Rails' |
scope_name_to_model | Boolean | N/A | Default |
scope_id_to_model | Boolean | N/A | Default |
required | Boolean | N/A | Default |
aria | Hash | N/A | Key/value pairs that represent Aria attributes and their values. Eg. |
data | Hash | N/A | Key/value pairs that represent data attributes and their values. Eg. |
system_arguments | Hash | N/A | A hash of attributes passed to the underlying Rails builder methods. These options may mean something special depending on the type of input, otherwise they are emitted as HTML attributes. See the Rails documentation for more information. In addition, the usual Primer utility arguments are accepted in system arguments. For example, passing |
placeholder | String | N/A | Placeholder text. |
inset | Boolean | N/A | If |
monospace | Boolean | N/A | If |
auto_check_src | String | N/A | When provided, makes a request to the given URL whenever the contents of the text field changes. If the server responds with a non-2xx status code, the response body is used as the validation message. |
leading_visual | Hash | N/A | Renders a leading visual icon before the text field's cursor. The hash will be passed to Primer's Octicon component. |
leading_spinner | Boolean | N/A | If |
show_clear_button | Boolean | N/A | Whether or not to include a clear button inside the input that clears the input's contents when clicked. |
clear_button_id | String | N/A | The HTML id attribute of the clear button. |