Getting Started
Theming

COMPONENTS

Box
Button
Drawer
Flex
Heading
Input
Navbar
Tabs
Text
Textarea

Theming

Composite UI is a design system first component library. This means all ui elements are intended to be controlled by the theme you provide using the

ThemeProvider
. That includes everything from different component variants to overall ui spacing, typography, colors, and more. The theme format that Composite UI uses is based on the System UI Theme Specification.

To create your own theme object you simply need to follow the System UI structure. If you are using Typescript, then simply define your theme object using the

ITheme
interface exported by
composite-ui
.

Alternatively, Composite UI provides a default theme out of the box that you can start using right away or modify/customize in any way you see fit. Below is a reference for what the default theme includes.

Colors

The Composite UI color scheme is intentionally simple, consisting only of different shades of white, gray, and black. A color system is one of the most imporant parts of defining and application or product, and Composite UI wants to make no assumptions about the application that uses it.

Text

Primary

#212121

Secondary

#424242

Light

#757575

Background

Primary

#fff

Secondary

#F4F5F6

Gray

0

#757575

1

#D9DBDC

2

#EEF0F2

3

#F4F5F6

4

#FAFAFB

There are a lot of different ways to structure your theme's color scheme. Often times it is useful to have fields oriented around usecase such as

text
,
background
, etc. so that you can easily reference the color you want like this:

Hello world

For additional colors you can have extra keys for each kind of color in your application. In the Composite UI theme, we have kept things simple and use arrays for each set of colors. These can then be referenced in code with dot notation like

color="gray.3"
.

A more complex color system will often prefer to have color palettes that have saturation levels for each color ranging from 10 to 900. These colors are then referenced by their saturation level, such as

gray.20
,
gray.50
etc. The theme object shape makes no assumptions about how you will structure your color scheme. If you prefer to use saturation numbers, you can build a theme like this:

const theme = {
// ...
colors: {
gray: {
// ...
40: '#F4F5F6',
// ...
300: '#D9DBDC'
// ...
}
}
}

You can then reference these colors in code by saying

color="gray.40"
.

Shadow

0
1
2
const theme = {
shadow: [
'none',
'0px 1px 5px rgba(0,0,0,0.12)',
'0px 3px 10px rgba(0,0,0,0.06)'
];
// ...
}

Typography

const theme = {
fonts: {
body: `-apple-system,BlinkMacSystemFont,
'Segoe UI','Oxygen','Ubuntu','Cantarell',
'Fira Sans','Droid Sans','Helvetica Neue',
sans-serif`,
},
fontSizes:[12, 14, 16, 20, 24, 32, 48, 64, 72]
}

Spacing

const theme = {
space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
// ...
}