Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
Orbit styled system is powered by the values of a theme object provided by the application. The Orbit theme object specification have been inspired by the Styled System Theme Specification.
A theme object is a combination of design values and design scales (spacing, sizing, colors, etc..).
Some scales are defined in Orbit as arrays for ordinal values like space
or as plain objects for named values like colors
. Some are even a mix of both, such as fontSizes
.
An Orbit theme object is composed of the following 8 keys:
Theme key | CSS properties | Scale |
---|---|---|
space | margin, margin-top, margin-bottom, margin-right, margin-left, padding, padding-left, padding-right, padding-bottom, gap, column-gap, row-gap | 1..13 |
sizing | width, height, min-width, max-width, min-height, max-height, grid-auto-columns, grid-auto-rows | 1..18 |
boxShadows | box-shadow | 1..2 / alias |
fontSizes | font-size | 1..11 / alias |
colors | color, background-color, border-color | [color]-[1..10] / alias |
fontWeights | font-weights | 1..3 |
lineHeights | line-heights | 1..6 |
borderRadii | border-radius | 1..4 / alias |
When rendered with the createThemeVars
function, the following CSS variables will be outputted from the theme object values.
Theme key | CSS variables |
---|---|
space | --o-ui-sp-{x} |
sizing | --o-ui-sz-{x} |
boxShadows | --o-ui-bs-{x} |
fontSizes | --o-ui-fs-{x} |
colors | --o-ui-{x} |
fontWeights | --o-ui-fw-{x} |
lineHeights | --o-ui-lh-{x} |
borderRadii | --o-ui-br-{x} |
Orbit components and Orbit style props doesn't render any styles until a theme is applied.
To apply a theme:
createThemeVars
function<ThemeProvider>
component with the theme objectimport { createThemeVars, ThemeProvider } from "@sharegate/orbit-ui";createThemeVars([theme]);<ThemeProvider theme={theme} colorScheme="light"><Button>Launch</Button></ThemeProvider>
Any object can be used as an Orbit theme object as long as it extends the OrbitTheme
TypeScript type. A few options are available.
Make sure you provide the right definition by extending the OrbitTheme
type.
import { OrbitTheme, createThemeVars, ThemeProvider } from "@sharegate/orbit-ui";const SpaceTheme: OrbitTheme = {name: "space-theme",space: [],sizing: [],fontSizes: {}// ...};createThemeVars([theme]);<ThemeProvider theme={theme} colorScheme="light"><Button>Launch</Button></ThemeProvider>
With createTheme
, you only have to provide a subset of OrbitTheme
values. The remaining values will fallback to Orbit defaults.
import { createTheme, createThemeVars, ThemeProvider } from "@sharegate/orbit-ui";const SpaceTheme = createTheme({name: "space-theme",colors: {white: "#fff",black: "#000",accent: ["hsla(174, 61%, 94%, 1)","hsla(173, 63%, 85%, 1)","hsla(173, 63%, 75%, 1)","hsla(173, 64%, 65%, 1)","hsla(173, 64%, 50%, 1)","hsla(172, 65%, 48%, 1)","hsla(173, 65%, 46%, 1)","hsla(172, 63%, 45%, 1)","hsla(172, 64%, 43%, 1)","hsla(172, 62%, 41%, 1)"]// ...}// ...});createThemeVars([theme]);<ThemeProvider theme={theme} colorScheme="light"><Button>Launch</Button></ThemeProvider>
The only theme available at the moment is ShareGateTheme
.
import { ShareGateTheme, createThemeVars, ThemeProvider } from "@sharegate/orbit-ui";createThemeVars([ShareGateTheme]);<ThemeProvider theme={ShareGateTheme} colorScheme="light"><Button>Launch</Button></ThemeProvider>
Theme objects are primarily used to boostrap Orbit styled system but they can also be used directly in JavaScript code when you need to fetch a value.
If you have access to the theme object, use the object directly.
<Div padding={SpaceTheme.spacing[2]}>Hello world!</Div>
If you don't have access to the theme object, retrieve a ThemeAccessor
instance from the ThemeContext
by using the useThemeContext
hook and access the theme values from the instance.
import { useThemeContext } from "sharegate/orbit-ui";const { themeAccessor } = useThemeContext();return <Div padding={themeAccessor.getSizing(3)}>Hello world!</Div>