Hi. how do i increase the border outline thickness...
# compose
j
Hi. how do i increase the border outline thickness on a outline textfield? I do not see anything from the api docs below that enables me to do so.
Copy code
@Composable
fun OutlinedTextField(
    value: String,
    onValueChange: (String) -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    readOnly: Boolean = false,
    textStyle: TextStyle = LocalTextStyle.current,
    label: (@Composable () -> Unit)? = null,
    placeholder: (@Composable () -> Unit)? = null,
    leadingIcon: (@Composable () -> Unit)? = null,
    trailingIcon: (@Composable () -> Unit)? = null,
    prefix: (@Composable () -> Unit)? = null,
    suffix: (@Composable () -> Unit)? = null,
    supportingText: (@Composable () -> Unit)? = null,
    isError: Boolean = false,
    visualTransformation: VisualTransformation = VisualTransformation.None,
    keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
    keyboardActions: KeyboardActions = KeyboardActions.Default,
    singleLine: Boolean = false,
    maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
    minLines: Int = 1,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    shape: Shape = OutlinedTextFieldDefaults.shape,
    colors: TextFieldColors = OutlinedTextFieldDefaults.colors()
): Unit
j
you can add border using
Modifier.border()
j
but it already has one ? its a outlinetextfield
j
Copy code
OutlinedButton(
                    modifier = Modifier.border(10.dp, Color.Blue, ButtonDefaults.outlinedShape),
                    onClick = {
                    }) {
                    Text("Go To Student Profile")
                }
was it helpful?
j
thats a outline button
im using a outlineTextField
j
same on outlinedTextField
j
i will try it anyway and see
\but it uses its own border though
j
let me send you an example. Just give me a moment
j
just tried it and it just adds another border on top of the default on
i wanna increase the width of the default one
see here
j
Ohh. Sorry you cannot edit border size in outlined text field. You need to create custom text field using
BasicTextField
j
Looks like u cant as i need to overide OutlinedTextFieldDefaults.DecorationBox(
ok
will it present and do the animation part where the label text animates and moves to the top left when a user clicks to enter text?
j
you need to make it through by yourself. Because
OutlinedTextField
is doing all the stuffs internally by wrapping up
BasicTextField
j
yea
ist odd how google doesnt allow us to tweak the outline
all they need to do is expose
UnfocusedBorderThickness
and
FocuesBorderThickness
absolute mental they diddnt
j
all the default component is part of the material design system so, we have to follow the style
j
i hear u but should be able to change it if we want to
j
you could create custom one by copying the
OutlinedTextField
source code and modify the necessary things
j
could do but seems overkill
f
The reasoning is that Material is opinionated design language with strict set of rules which the material components follow. If you want to deviate from this design, you'll have to go the custom path.
j
seems like the only way though just to change the thickness of the border....
they gave us the ability to change the colour at least...
yes i mean i can push back on the designers to say that it should be 1.dp thickness
lets see what they say
f
There are many things that could be customisable. The API surface would be huge if you could tweak every single thing. It's a slippery slope
👍 1
j
i hear u dude but tweaking a very common visible bit of a ui should be fine
but tweaking say, how the cursor animates or how keyboard pops up etc , yes that should not be exposed
we should be able to change colors and sizes of things
for all material components IMO
Because not all graphic deisgners follow material
or the wider business doesnt follow it strickly
trust me if it was my own app, i would use default material 100%
Another thing is why am i able to change teh shape of the outline textfield? doesnt that have a more impactful breaking the material design then a border thickness?
j
yeah. you're right @Jrichards1408. even in the flutter TextField border is editable based on event (ie: focus, active, etc)
flutter standard library also follow material design system
f
Yeah, I had the same problem a lot of times and I agree with you that some things are really infuriating. But with Compose the Google team made decision to be more strict with the components because making custom ones is way way easier in Compose. You use some design language, you have to follow it's rules. It's simple as that
j
I agree with you that compose is lot easier then other ui framework
j
yup yup i hear ya. i will try and push back on designers if they complain about the border thickness
j
So, we could make custom things more faster
j
cool cool yes it does
i love compose
anyways thanks all and sorry for the mini rant!