Themes

One of the central concepts in material design is the color palette—while it does not mandate the colors that an application can use, it has very clear rules about color choice and combinations that work. Designers are encouraged to pick a primary color from the standard palettes (used in most user interface elements) and a secondary color (for highlights and accents) that complement each other. For each color, there are standard light and dark variants, which can add depth to an application interface. You can explore these through the online color tool at material.io/tools/color.

The palette that Shiny uses follows this approach; the available colors are:

  • theme.ForegroundThe standard foreground color for the theme—used for text and icons
  • theme.BackgroundThe standard background color for containers
  • theme.Neutral: A background color for smaller areas that should be distinct from the background
  • theme.Light: A lighter version of the neutral color
  • theme.Dark: A darker version of the neutral color
  • theme.Accent: The main color from the secondary palette, used for highlighting key elements

Colors in the Shiny API are passed using the theme.Color type instead of the golang color.Color type. This ensures that the colors used are from the theme palette. From a theme color type, you can call the Color() function to get a standard color type or the Uniform() function to get image.Uniform which is used to draw filled rectangles in a Paint() function.

Applications can choose to use the built-in theme (theme.Default) or to provide their own. Any type that implements theme.Theme can be used in the rendering of a Shiny GUI.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.187.165