Skip to content

Floating labels don't work inside input groups (prepend/append) #642

@joeroe

Description

@joeroe

Floating labels don't display correctly if they're used with an input group, i.e. if prepend: or append: are set.

f.text_field :name, floating: true, prepend: "My name is"

Generates:

<div class="mb-3 form-floating">
    <div class="input-group">
        <span class="input-group-text">My name is</span>
        <input class="form-control" placeholder="Name" type="text" value="" name="person[name]" id="person_name">
    </div>
    <label class="form-label" for="person_name">Name</label>
</div>

To work, I think there should only be one wrapper element, and the label should be placed alongside the input, i.e.:

<div class="mb-3 form-floating input-group">
    <span class="input-group-text">My name is</span>
    <input class="form-control" placeholder="Name" type="text" value="" name="person[name]" id="person_name">
    <label class="form-label" for="person_name">Name</label>
</div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions