bootstrap 4 equivalent for form-control-feedback

Viewed 7190

form-control-feedback does not seem to be part of bootstrap 4. What's the best way to achieve the below result (icon inside the textbox) using bootstrap 4?

<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
    <div class="container">
        <form class="form-horizontal">
            <div class="form-group has-warning has-feedback">
                <div class="col-sm-10">
                    <input type="text" class="form-control">
                    <span class="form-control-feedback"><i class="fa fa-rotate-right"></i></span>
                </div>
            </div>
        </form>
    </div>
</body>

1 Answers

You could just jack the css class and apply it (notice the v4 cdn) the same but minus the fixed sizing conventions like;

.form-control-feedback {
    position: absolute;
    top: .5rem;
    right: 1.5rem;
    z-index: 2;
    display: block;   
    text-align: center;
    pointer-events: none;
}
<head>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
    <div class="container">
        <form class="form-horizontal">
            <div class="form-group has-warning has-feedback">
                <div class="col-sm-10">
                    <input type="text" class="form-control">
                    <span class="form-control-feedback"><i class="fa fa-rotate-right"></i></span>
                </div>
            </div>
        </form>
    </div>
</body>

However, note that if you go in and play with the sass settings for your input sizing etc, the top and right values will need tweaked accordingly along with possibly a font-size added.

Related