question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Read only form controls

See original GitHub issue

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)

image

In context explorations:

image image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:57 (36 by maintainers)

github_iconTop GitHub Comments

2reactions
tomlroachcommented, Apr 1, 2020

I suppose conceptually there doesn’t have to be any visual difference between an editable input and a read only input. They could be the same but editing is unavailable in a read only version.

For example this URL field in Typeform is not disabled, I can click into it, select the text etc. But I cannot edit it - it simply does nothing if I try to interact… image That’s potentially an approach.

Luke shows another where he converts input fields into a similarly sized/shaped text component, although it’s limited to text inputs/dropdown, and I don’t quite see how it would be applied to radio buttons, checkboxes or other forms of input.

I would summarise the request as:

A point of view on how to represent settings which are not currently editable because they are in a read only state, in an easily legible format - i.e. without using disabled fields - which are extremely hard to read due to their styling.

2reactions
tomlroachcommented, Mar 26, 2020

+1 to this issue.

We have all sorts of user permissions in our product now, and would like to be able to show those users with viewer permissions the values of various fields without having to use disabled styling (and thereby making them hard to read).

One option would be we just design a read only version of every page which uses text elements instead of input fields, but replacing input fields with read-only versions would be much less work and would allow us to have the read only and editable versions of the pages match up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make a formControl readonly - Stack Overflow
We use READONLY attribute to prevent user from type/select the form control but we get value from the input. We use DISABLED attribute...
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 >
Disable or set a control as read-only by using conditional ...
On the form template, click the control that you want to disable or set as read-only. · On the Format menu, click Conditional...
Read more >
Rendering Read-only Data with Angular | Pluralsight
Use Angular's readonly property. HTML label control is read-only by default, but it doesn't look compelling in form and grid controls.
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.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found