am trying to make evenly spread three input text w...
# kmdc
r
am trying to make evenly spread three input text with 
MDCTextField
But is not getting evenly spread But with core 
TextInput
  got evenly spread
Copy code
Div(
            attrs = {
                style {
                    display(DisplayStyle.Flex)
                    width(100.percent)
                    justifyContent(JustifyContent.SpaceBetween)
                    flexFlow(FlexDirection.Row, FlexWrap.Nowrap)
                }
            }
        ) {

            val annualCtcState = remember { mutableStateOf("") }
            MDCTextField(
                annualCtcState.value,
                {
                    type = MDCTextFieldCommonOpts.Type.Outlined
                    label = "Annual CTC"
                },
                {
                    style {
                        margin(8.px)
                        width(33.percent)
                        title("Annual CTC")

                    }
                    onInput {
                        annualCtcState.value = it.value
                    }
                }
            )
😕
b
Could you paste a snippet that did not work for you as well?
r
this is the snippet
Copy code
Div(
            attrs = {
                style {
                    display(DisplayStyle.Flex)
                    width(100.percent)
                    justifyContent(JustifyContent.SpaceBetween)
                    flexFlow(FlexDirection.Row, FlexWrap.Nowrap)
                }
            }
        ) {

            val annualCtcState = remember { mutableStateOf("") }
            MDCTextField(
                annualCtcState.value,
                {
                    type = MDCTextFieldCommonOpts.Type.Outlined
                    label = "Annual CTC"

                },
                {
                    style {
                        margin(8.px)
                        width(33.percent)
                        title("Annual CTC")

                    }
                    onInput {
                        annualCtcState.value = it.value
                    }
                }
            )

            val inHandPerMonthState = remember { mutableStateOf("") }
            MDCTextField(
                inHandPerMonthState.value,
                {
                    type = MDCTextFieldCommonOpts.Type.Outlined
                    label = "In Hand Per Month"
                },
                {
                    style {
                        margin(8.px)
                        width(33.percent)
                        title("In Hand per month")

                    }
                    onInput {
                        inHandPerMonthState.value = it.value
                    }
                }
            )

            val bonusState = remember { mutableStateOf("") }
            MDCTextField(
                bonusState.value,
                {
                    type = MDCTextFieldCommonOpts.Type.Outlined
                    label = "Bonus"
                },
                {
                    style {
                        margin(8.px)
                        width(33.percent)
                        title("Bonus")

                    }
                    onInput {
                        bonusState.value = it.value
                    }
                }
            )
        }
main issue is
width
is not working as it was in core
TextInput
b
🤦 my bad, missed the MDCTextField invocation in your initial snippet... Browsing code on mobile is hard 😅
r
yeah it is really 😅
b
Have a look at the generated html. If I remember correctly, mdc textfield component is wrapped in a div, so your stiles are not applied on the textfield element. You can apply your styling to children elements via css class selectors.
r
I added the
width
style in child elements only
b
Although it looks like a bug in mdc as width on parent should be respected by the children.
r
Plus its able to pickup the Div which I wrapped it in'
b
You did not.
I meant MDCTextField children that are rendered on the dom (not visible from kotlin dsl)
Just check out what's actually rendered on the dom and you'll understand.
r
It is showing 33 percent width
b
Hah, so it does. Then the problem is the exact opposite. Apply styling on mdc component root element via your wrapper div and css class selectors
r
did not get you 😐
b
Width should be applied on the label
I.e. parent of input element
r
Here parent, wrapping
Div
would not that apply with to parent only
b
Yes, that's why you also need to make use of css selectors to apply styling to children via parent
Copy code
.mdc-textfield > {
  width: 30%
}
Or something like that. Check compose web styling docs I've linked above on how to do it properly
r
I tried to add
flexGrow
for my purpose but it did not add
flexGrow
in the final html
c
style { display(DisplayStyle.Flex) flexDirection(FlexDirection.Row) alignContent(AlignContent.SpaceEvenly) }