Magento 2 Checkout – Add Placeholder and Remove All Labels

checkoutformslayoutmagento2.2template

Searched a lot but didn't found anything removing the

Lables like "First Name, Last Name, City, Address, Email, Phone etc"

Add Placeholders in all "shipping fields" and "sign In" places.
After Login Placeholders in "new add address popup"

https://imgur.com/Wm3aQNj

Please help me struggling from so many days didn't found any exact thing.

Best Answer

I don't find any proper solution but give you quick and good solution.

Magento checkout's input fields are render by Magento_Ul module component's file

vendor/magento/module-ui/view/base/web/templates/form/element/input.html

On this files, you need to changes

placeholder: placeholder to placeholder: label

So, first copy this html to your frontend theme folder

app/design/frontend/{Vendor}/{Themename}/Magento_Ui/web/templates/form/element/

On this input.html add this code:

<input class="admin__control-text" type="text"
    data-bind="
        event: {change: userChanges},
        value: value,
        hasFocus: focused,
        valueUpdate: valueUpdate,
        attr: {
            name: inputName,
            placeholder: label,
            'aria-describedby': noticeId,
            id: uid,
            disabled: disabled
    }"/>

Then, you need to add _extend.less at your theme folder

app/design/frontend/{Vendor}/{Themename}/Magento_Theme/web/css/source/_extend.less

add this code for hidden the label css:

.checkout-index-index label{display:none}

Then You must flush cache by run

php bin/magento cache:flush

Or delete all files from view_procecced, cache,page_cache.

Then you should static content deploy

php bin/magento setup:static-content:deploy