How to change height of TextField? Looks like ther...
# compose
a
How to change height of TextField? Looks like there are vertical padding
d
I believe you need to use BasicTextField and create a widget on your own for now, There's a bug open where they plan to expose more internal parts of the TextField to make it easier to build custom input fields https://issuetracker.google.com/issues/179882597
or you can cheat and apply the background on top of a bigger TextField using
Modifier.drawBehind { }
@Artem Kopan
a
Thanks!
d
there is right answer already: you have to implement your own TextField based on BasicTextField
1
j
But then I will have to reimplement the OutlinedTextField in my project. 👎
d
The implementation of
OutlinedTextField
is the one of material design, if you need something different, yes, you'll have to implement yourself. Rather than creating a widgets with all possible customization available google is working on exposing smaller components to make it easier to write your own, but currently you can get inspiration on what the material library do to build your own.
👌 1
j
So we will have to fork the implementation of Button as well, just because instead of providing reasonable default values the Material library hardcode those values. Compose Material is advertised as being great for creating your own design system, but not so much if you tries to deviate from the Material definition. I will try to talk with designers because it would be a nightmare to keep this code.
d
You don't have to fork Button actually, it is super easy to implement Button from scratch: just give the surface its background and modifier.clickable -> your button is ready
j
and accessibility and all the new possible things that would come automatically to the material library.
d
So we will have to fork the implementation of Button as well, just because instead of providing reasonable default values the Material library hardcode those values. Compose Material is advertised as being great for creating your own design system, but not so much if you tries to deviate from the Material definition. I will try to talk with designers because it would be a nightmare to keep this code.
You should not be disappointed at this, you should be happy. It was one of the issues of XML views... You needed lot of customization options cause it was really hard to build your own if the customization did not allowed it. With compose you'll get more basic widgets and it will be way easier to create your custom ones and build your own design system.
1
j
Man, I want to change the height of a composable, to do so the internal padding needs to be adjustable and not the hardcoded 8 dp. If O choose to implement my own I will have to reimplement a bunch of other stuff, like the outline for the TextInput. This is not how composable pattern work.
d
You are missing the point. Put yourself in the material developer shoes. If you support that use case and than material design change into something that is not compatible with that you need to maintain backwards compatibility. It's a bad idea to support something not in your requirements. It is a better idea to support smaller components that makes it easier for you to build your own.
j
“It is a better idea to support smaller components that makes it easier for you to build your own.” The way things are today are the opposite of it. I can’t use OutlinedTextInput (or parts of it) to create my own design system. The Material components don’t need to be bigger, they need to expose things to allow customisation and this should be in their requirements.
d
Compose is new, give it time and you'll have plenty of choice. If you don't want to give it time you are an early adopter and you get to shape it with feedback and libraries that will get adopted
d
I can’t use OutlinedTextInput (or parts of it) to create my own design system.
You actually have all source code, so you can use any part you need (and edit it as you wish). I have faced same problem and it took about 2 hours to copy TextField implementation and throw away all things that I don't need.
The Material components don’t need to be bigger, they need to expose things to allow customisation and this should be in their requirements.
Material components need to follow Material guidelines. The problem is that your designer doesn't follow guidelines, but you try to use component from that guideline.
j
No, I can't. There are many classes that are not public.
d
That is strange, because I did that actually.