Bootstrap: readonly-plain-text with button addon

Created on 16 Mar 2018  路  9Comments  路  Source: twbs/bootstrap

The readonly plain text doesnt work with button addon.

Live example: https://codepen.io/caiquecastro/pen/eMdmYo

image

<div class="input-group mb-3">
  <div class="input-group-prepend">
    <button class="btn btn-outline-secondary" type="button">Button</button>
  </div>
  <input type="text" readonly class="form-control-plaintext" id="staticEmail" value="[email protected]">
</div>
css has-pr v4

Most helpful comment

Why not use only the readonly attribute then? If the idea is that at some point a user could interact with that field, I would think it should be a field from the beginning.

All 9 comments

why would you use it this way? simply dropping the .input-group-prepend solves this of course. it's not really possible, to my knowledge, to rewrite styles so that the button takes account of an element that comes after it.

ah, i thought you meant the right-hand border of the button not being rounded, and missed the email showing on a new line...doh

On the PR, maybe it's better if a padding is added to the .form-control-plaintext, but I didn't known the variable name responsible for this spacing.

I understand the desired affect here, but why would you do this? An input group is intended to visually connect button/text and form control.

i'd imagine for consistency if the form is read/write at one point/for certain users, but some of the fields are read-only after submission/for other users, so you can keep the scaffolding the same

I have it readonly, but if I click it. I should remove its readonly state, and enable change the value.

Why not use only the readonly attribute then? If the idea is that at some point a user could interact with that field, I would think it should be a field from the beginning.

regardless of the specific use case here, though, i'd say the fix (or something similar to it) seems legit to me.

Line 3316
append -> .input-group > .form-control-plaintext,

Line 3353
append -> .input-group > .form-control-plaintext:not(:last-child),

Line 3361
.input-group > .form-control-plaintext:not(:first-child),

Line 3441
.input-group-lg > .form-control-plaintext,

Line 3460
.input-group-sm > .form-control-plaintext,

Was this page helpful?
0 / 5 - 0 ratings