[GH-ISSUE #475] Add example of overriding Styles to docs? #344

Closed
opened 2026-03-04 01:04:11 +03:00 by kerem · 1 comment
Owner

Originally created by @khughitt on GitHub (Jul 18, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/475

Greetings!

In the docs for tview, it is mentioned that:

When primitives are instantiated, they are initialized with colors taken from the global Styles variable. You may change this
variable to adapt the look and feel of the primitives to your preferred style.

Would it be possible to expand a bit on this and provide an explicit example of how this can be achieved, either for individual colors, or for entire themes?

Apologies in advance if this is something that is trivial to do -- I'm only on day two of working with Go (and quite impressed, so far!)

I did try updating / redefining Styles in the global package space, but it didn't seem to have any effect. I suspect I'm just misunderstanding how scoping works with global variables or something else very basic..

Any suggestions/guidance would be greatly appreciate though.

Thanks!

Originally created by @khughitt on GitHub (Jul 18, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/475 Greetings! In the docs for tview, it is mentioned that: > When primitives are instantiated, they are initialized with colors taken from the global Styles variable. You may change this variable to adapt the look and feel of the primitives to your preferred style. Would it be possible to expand a bit on this and provide an explicit example of how this can be achieved, either for individual colors, or for entire themes? Apologies in advance if this is something that is trivial to do -- I'm only on day two of working with Go (and quite impressed, so far!) I did try updating / redefining `Styles` in the global package space, but it didn't seem to have any effect. I suspect I'm just misunderstanding how scoping works with global variables or something else very basic.. Any suggestions/guidance would be greatly appreciate though. Thanks!
kerem closed this issue 2026-03-04 01:04:11 +03:00
Author
Owner

@khughitt commented on GitHub (Aug 3, 2020):

Never mind! I figured it out. Sure enough it was just a matter of using the proper namespacing syntax.

In case it helps anyone else, to modify a setting inside main(), you can do something along the lines of:

tview.Styles.PrimitiveBackgroundColor = tcell.ColorRed
<!-- gh-comment-id:668210330 --> @khughitt commented on GitHub (Aug 3, 2020): Never mind! I figured it out. Sure enough it was just a matter of using the proper namespacing syntax. In case it helps anyone else, to modify a setting inside `main()`, you can do something along the lines of: ```go tview.Styles.PrimitiveBackgroundColor = tcell.ColorRed ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#344
No description provided.