Revert the palette
palette
Palette
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])
path
stringdefaultValue
any?
const Button = styled.button`
font-family: ${font('primary')};
`
Returns Font
Shorthand to key(['sizes', path])
path
stringdefaultValue
any?
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
...anyindex
number The index of tone in theme palette tones arraypath
string The key of the tones in theme palette object (optional, defaultprops.palette
)exceptions
Object? An object with path as key and index as valuereverse
boolean? Flag to return tone fromreversePalette
orpalette
defaultValue
string? 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