Read only text input
See original GitHub issueref: https://github.com/carbon-design-system/carbon/issues/2177 by @shixiedesign
A read only variant of Text input is suggested here: https://github.com/carbon-design-system/carbon-contribution/issues/13#issue-421692303
The “Disabled” option is not viable, as the label and entered data is not accessible. Proposal is to simply remove the line at the base of the “Filled” version of the component, so that it closely matches with the Disabled component, but passes accessibility.
Overview of component (updated May 13)
- Read-only variant will be keeping underline and dropping the background of the field. We need the underline for low-vision users to recognize this as a text field. Also loosing the underline makes the element a button-style, which would be confusing.
- Not moving the text position after all. Keeping text 16px away from left of border helps with preserving the form structure.
- Regular text cursor and allows text selecting
- Add
not-editable
icon, icon in PR https://github.com/carbon-design-system/carbon/pull/2710 - Optional tooltip when hovering
not-editable
icon, to provide reason for the field being read-only - Overflow text in the field will show in tooltip on hover
- Should be considered a state, possible
readonly
attribute - Follow the standard readonly attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-readonly
Design spec (updated May 13)
In context explorations:
Finalized design spec. Ready for dev 🤖 updated May 23
Light variant spec
Only difference from default is changing field background to $field-01
so it is the same as background color.
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (6 by maintainers)
Top Results From Across the Web
HTML input readonly Attribute - W3Schools
The readonly attribute is a boolean attribute. When present, it specifies that an input field is read-only. A read-only input field cannot be...
Read more >HTML attribute: readonly - HTML: HyperText Markup Language
The Boolean readonly attribute, when present, makes the element not mutable, meaning the user can not edit the control. Try it. HTML Demo: ......
Read more >HTML5 Forms: Readonly Type Attribute - Wufoo
The readonly attribute makes a form control non-editable (or “read only”). A read-only field can't be modified, but, unlike disabled , you can...
Read more >HTML | input readonly Attribute - GeeksforGeeks
The readonly attribute of <input> element in HTML is used to specify that the input field is read-only. If an input is readonly,...
Read more >Making a react-native TextInput readonly - Stack Overflow
I want to make a text input readonly in my RN application. I tried to set an editable prop but it did not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aagonzales Sorry I may not have been clear enough - It’s #4015. The latest spec for read-only text input requests for a tooltip (presumably for overflow text). Definition tooltip is the closest, but definition tooltip (technically) cannot be activated by focus on
<input>
. #4015 is for supporting such use case in definition tooltip.@shixiedesign @emyarod Another proposal to consider (I created this issue prior to seeing @shixiedesign 's, so just some food for thought). The design was created for a slightly use case as none of the fields would be editable.
https://github.com/carbon-design-system/carbon-contribution/issues/17