posit-dev / brand-yml

Unified branding with a single yaml file.
https://posit-dev.github.io/brand-yml/
MIT License
26 stars 2 forks source link

Using brands on cards and/or buttons #50

Open pipaber opened 1 day ago

pipaber commented 1 day ago

For shiny Python apps, if I want to set different 3 colours for 3 cards. This is easy to do with a _brand.yml file?

gadenbuie commented 1 day ago

Sort of? For example, if you set theme colors in color, then those values are used automatically by Shiny.

For example, if you've set color.primary, color.secondary and color.info,

color:
  palette:
    cyan: "#17A2B8"
    purple: "#6F42C1"
    white: "#F8F8F8"
  primary: purple
  secondary: black
  info: cyan

then you can use those values for value box themes

ui.layout_columns(
    ui.value_box("Metric 1", "100", theme="primary"),
    ui.value_box("Metric 2", "200", theme="secondary"),
    ui.value_box("Metric 3", "300", theme="info"),
),

and you could also apply the classes text-bg-primary, text-bg-secondary, text-bg-info to a card – with ui.card(..., class_="text-bg-primary") to get themed cards.

pipaber commented 1 day ago

Oh I understand! Many thanks!. Also, I was using something like this in a .css file:

.card-header {
    background: linear-gradient(15deg,#f37921, #e27256ea); 
    color: black;
    padding: 10px; 
}

.card {
    background-color: rgba(255, 255, 255, 0.9);
}

It's possible to set a color gradient or use rgba colors from a _brand-yml file?

gadenbuie commented 1 day ago

brand.yml will be somewhat orthogonal to this kind of CSS. In other words, the goal of the brand yml data is to set up a good baseline of defaults. There is a place where you can store extra CSS rules just for Shiny though:

defaults:
  shiny:
    theme:
      rules: |
        .card-header {
           background: linear-gradient(15deg,#f37921, #e27256ea); 
           color: black;
           padding: 10px; 
        }

        .card {
           background-color: rgba(255, 255, 255, 0.9);
        }