Skip to content

FormGroup: allow setting label-cols=auto #4217

@hackel

Description

@hackel

Currently, the labelCols prop only accepts a boolean or a number to explicitly define the percentage of the container the label will fill.

I would like the label to auto-size based on its contents by using the col-auto class on the label instead of col. Specifying label-cols="auto" seems like a reasonable way to do this, or perhaps another boolean prop like label-col-auto.

I can currently achieve what I want like this:

<BFormGroup
    label="Label"
    label-for="input"
    label-cols
    label-class="col-auto"
>
    <BInput />
</BFormGroup>

In this case, the label gets both classes applied, but it works because col-auto overrides the col properties. I just don't feel like it conveys the intent well.

The desired output would be:

<div class="form-row form-group" role="group">
    <label class="col-auto col-form-label" for="input">Label</label>
    <div class="col">
        <input class="form-control" id="input" type="text">
    </div>
</div>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions