Revert the palette
palettePalette
reversePalette({primary: ['red', 'green', 'blue']})
// {primary: ['blue', 'green', 'red']}Returns Palette
Returns the value of props.theme[path] or styledTheme[path]
const Button = styled.button`
font-family: ${key('fonts.primary')};
color: ${key(['colors', 'primary', 0])};
`Returns any
Shorthand to key(['fonts', path])
pathstringdefaultValueany?
const Button = styled.button`
font-family: ${font('primary')};
`Returns Font
Shorthand to key(['sizes', path])
pathstringdefaultValueany?
const Button = styled.button`
padding: ${size('padding')};
`Returns Size
Returns the value of props.theme[palette || reversePalette][path][index] or
styledTheme[palette || reversePalette][path][index] (default theme)
The arguments can be passed in any order, as long as types are kept.
args...anyindexnumber The index of tone in theme palette tones arraypathstring The key of the tones in theme palette object (optional, defaultprops.palette)exceptionsObject? An object with path as key and index as valuereverseboolean? Flag to return tone fromreversePaletteorpalettedefaultValuestring? Default value
// index = 1
// exception = { grayscale: 0 }
// reverse = true
const Button = styled.button`
background-color: ${palette({ grayscale: 0 }, 1, true)};
`
// renders props.theme.reversePalette.grayscale[0]
<Button palette="grayscale" />
// renders props.theme.palette.danger[1] (nullify reverse)
<Button palette="danger" reverse />Returns Tones