import { CodeSnippet } from '@fluentui/docs-components'; import { Provider, ProviderConsumer, Grid, Header, Box, Text, Alert, mergeThemes, teamsTheme, teamsHighContrastTheme, teamsDarkTheme, } from '@fluentui/react-northstar'; import * as _ from 'lodash'; import * as React from 'react'; import { Link } from 'react-router-dom'; import ColorBox, { colorBoxStyles, colorBoxVariables } from '../components/ColorBox'; import Fader, { faderStyles } from '../components/Fader'; import ColorVariants, { colorVariantsStyles } from '../components/ColorVariants'; import DocPage from '../components/DocPage/DocPage'; import ExampleSnippet from '../components/ExampleSnippet'; import ColorSchemes from '../components/ColorSchemes'; import GuidesNavigationFooter from '../components/GuidesNavigationFooter'; import { link, code } from '../utils/helpers'; const theme = { componentVariables: { Box: ({ colorScheme }) => ({ color: colorScheme.brand.foreground3, backgroundColor: colorScheme.brand.background3, }), }, componentStyles: { Box: { root: ({ variables }) => ({ color: variables.color, backgroundColor: variables.backgroundColor, }), }, }, }; const Colors = () => ( ({ '& a': { color: siteVariables.colorScheme.brand.foreground, }, }), }, }, componentVariables: { ColorBox: colorBoxVariables, }, }} > (
Introduction

The organizing of the colors for an application has many requirements and constraints. In Fluent UI, the colors mechanisms are completely based on the siteVariables.

We have two concepts in order for colors to work transparently when the theme switching is in play:

  • {link('Color palette', '#color-palette')} {' '} - central place for all colors available in the application,
  • {link('Color scheme', '#color-scheme')} {' '} - design tokens for all colors used in the application that should be appropriately mapped in all themes.
Everything that follows it's our recommendation and not a requirement. You can make own decision on the structure you want to use in your theme.

Colors in{' '} {link('Teams color palette', '/color-palette')} {' '} have the following categorization.

Primitive colors

This part of the palette contains colors that, semantically, cannot have any tints. This group is represented by two colors, {code('black')} and {code('white')} - as there is nothing blacker than black and nothing whiter than white.

{_.map(['black', 'white'], color => (
))}
Natural colors

This part of palette includes colors from those that are the most commonly used among popular frameworks ( {code('blue')}, {code('green')}, {code('grey')},{code('orange')}, {code('pink')}, {code('purple')},{' '} {code('teal')}, {code('red')}, {code('yellow')}). Each color includes at least ten gradients, this allows us to satisfy most common needs.

This decision is experienced from Material UI and allows to define more variants than by using semantical naming ({code('lightest')}, {code('lighter')}, etc.). However, there is no requirement for client to define all the gradient values for each color - it is just enough to define those that are actually used in the app.

Below there is an example of base tints of Teams' natural colors provided. Full list of all gradient values for them can be found on{' '} {link('Teams color palette page', '/color-palette')} .

{_.map(naturalColors, (variants, color) => (
))}
Contextual colors

This part of the palette may include {code('brand')} color as well as {code('danger')}, {code('success')},{' '} {code('info')} colors, etc.

{_.map(contextualColors, (variants, color) => (
))}
All colors

If the theme requires more colors, they can be added to color palette as needed. These are all colors available in the Teams' theme color palette.

{_.map(['black', 'white'], color => (
))} {_.map({ ...contextualColors, ...naturalColors, ...transparentColors }, (variants, color) => (
))}

To see all colors variants in the palette, follow this{' '} .

Each our theme defines color scheme, which will define the design tokens usages of the different colors from the palette. The color scheme is a prop of {code('siteVariables')} via {code('colorScheme')}{' '} that contains all schemas for the colors available in the palette.

The color tokens defined in the color scheme are mapped to actual values for all themes used in the application. This means that, if the developers use some token from the schema, it will be mapped to the correct color value provided by the current theme.

({ // \`brand\` contains all design tokens for the \`brand\` color color: colorScheme.brand.foreground3, backgroundColor: colorScheme.brand.background3 // \`foreground3\` and \`background3\` are theme-dependent tokens that should // be used as value in styles, you can define own tokens 💪 }) }, componentStyles: { Box: { // 🚀 We recomend to use \`colorScheme\` from variables mapping root: ({ variables }) => ({ color: variables.color, backgroundColor: variables.backgroundColor }) } } }; const ColorSchemeExample = () => ( ); export default ColorSchemeExample; `} render={() => ( <> )} />

You can add multiple color schemes per theme like {code('inverted')} or for specific parts of the application that look different. Your design team can provide you different names for the design tokens:

You can see use color schemes defined for Teams' themes as reference to create own, below is definition for{' '} brand color in in Teams light, high contrast and dark themes.

)} /> ); export default Colors;