Golang Fyne: change button (font) size

90 Views Asked by At

I have a simple application with a few buttons. I would like to have larger buttons with large text on these buttons.

I currently use container.NewGridWithColumns(4). But I'have also tried newGridWrap with a size but I prefer to use columns.

A custom theme perhaps?

func (m myTheme) Size(name fyne.ThemeSizeName) float32 {
    switch name {
    case theme.SizeNameText:
        return 40
    }

    return theme.DefaultTheme().Size(name)
}

But this changes ALL text and really messes with the other UI parts. Everything else overflows now and I can't get it to work.

Is there any way to just change the (text) size of a few buttons?

https://docs.fyne.io/widget/button only mentions themeing but that applies to the entire application.

1

There are 1 best solutions below

1
andy.xyz On

The standard widgets all use the same font size so that it aligns well in the UI. To make a button that has a different font (size) you would need to put a canvas.Text element over a button with no label (Stack container will help)