Style Props
Hopper components are designed to be consistent across all Workleap applications. They include built-in styling that has been considered carefully, and extensively tested. In general, customizing Hopper is discouraged, but most components do offer control over layout and other aspects. In addition, you can use Hopper's tokens to ensure your application conforms to design requirements, and is adaptive across color schemes.
Style props
A Hopper style property is a mapping of a CSS property to a component property. With style props, Hopper let you easily set style values for a curated set of CSS properties like font-size, margin, padding, width and many more.
All of the available style props are listed in the "Properties List" section below.
Usage
To use a style prop on a Hopper component, pass the prop as a camelCased string to the component. By default, only tokens are accepted as values for style props. They help promote consistency and maintainability across your application.
If you need to pass a custom value, you can use the UNSAFE_
prefix to bypass the token system. You can refer to the "Escape hatches" section for more information.
Shorthands
Props like border and paddingX are also provided to help you save keystrokes. An exhaustive list of all the supported props is available in the "Properties List" section.
Responsive styles
All style props support responsive values. You can pass an object with breakpoints as keys and values as values to a style prop to set different values for different breakpoints. More information is available in the Responsive Styles article.
Escape hatches
While we encourage teams to utilize Hopper styles as it is, we do realize that sometimes product specific customizations may be needed. In these cases, we encourage you or your designers to talk to us. We may be able to suggest an alternative implementation strategy, or perhaps your design can help inform future Hopper additions.
While the traditional className and style props are always supported in Hopper components, we also provide an escape hatch for passing custom values to style props. This is done by prefixing the prop name with UNSAFE_
.
The UNSAFE_
prefix might look scary, but it's there to remind you that you're bypassing the token system. It's a way to ensure that you're aware that you're doing something that might not be automatically updated when tokens change.
It will also help you to search for these usages when you want to update them, or help us to provide missing tokens.
Pseudo-classes
Style props doesn't support every CSS pseudo-classes. Location pseudo-classes, input pseudo-classes, tree-structural pseudo-classes, ::before and ::after are not supported and will most likely never be.
When a CSS pseudo-class is not supported by Hopper style props, we recommend using a CSS class.
Since the following user action pseudo-classes are often used, some style props support them. These behaves like their pseudo CSS counterparts.
Suffix | Pseudo state |
---|---|
active | :active |
hover | :hover |
focus | :focus |
Not all style props support user action pseudo-classes. Find out which props support user action pseudo-classes in the "Properties List" section.
Properties List
The following tables provide a list of all available style props by category.
Space
<Div padding="inset-md"> Hopper </Div>
Prop | CSS property | Scale | Supports |
---|---|---|---|
margin | margin | Spacing | breakpoints |
marginTop | margin-top | Spacing | breakpoints |
marginBottom | margin-bottom | Spacing | breakpoints |
marginRight | margin-right | Spacing | breakpoints |
marginLeft | margin-left | Spacing | breakpoints |
marginX | margin-left & margin-right | Spacing | breakpoints |
marginY | margin-top & margin-bottom | Spacing | breakpoints |
padding | padding | Spacing | breakpoints |
paddingTop | padding-top | Spacing | breakpoints |
paddingBottom | padding-bottom | Spacing | breakpoints |
paddingRight | padding-right | Spacing | breakpoints |
paddingLeft | padding-left | Spacing | breakpoints |
paddingX | padding-left & padding-right | Spacing | breakpoints |
paddingY | padding-top & padding-bottom | Spacing | breakpoints |
whiteSpace | white-space | none | breakpoints |
Color
<Div backgroundColor="primary-weak" color="neutral"> Hopper </Div>
Prop | CSS property | Scale | Supports |
---|---|---|---|
color | color | Colors | breakpoints & focus/hover/active |
backgroundColor | background-color | Colors | breakpoints & focus/hover/active |
opacity | opacity | none | breakpoints & focus/hover/active |
fill | fill | Colors | breakpoints & focus/hover |
stroke | stroke | Colors | breakpoints |
filter | filter | none | breakpoints |
Typography
<Header letterSpacing="0.3rem">Hopper</Header>
Prop | CSS property | Scale | Supports |
---|---|---|---|
fontSize | font-size | Typography | breakpoints |
fontWeight | font-weight | Typography | breakpoints |
lineHeight | line-height | Typography | breakpoints |
letterSpacing | letter-spacing | none | breakpoints |
textAlign | text-align | none | breakpoints |
textTransform | text-transform | none | breakpoints |
textDecoration | text-decoration | none | breakpoints |
textOverflow | text-overflow | none | breakpoints |
wordBreak | word-break | none | breakpoints |
fontStyle | font-style | none | breakpoints |
Layout
<Div UNSAFE_width="30rem"> Hopper </Div>
Prop | CSS property | Scale | Supports |
---|---|---|---|
width | width | Dimensions | breakpoints |
height | height | Dimensions | breakpoints |
minWidth | min-width | Dimensions | breakpoints |
maxWidth | max-width | Dimensions | breakpoints |
minHeight | min-height | Dimensions | breakpoints |
maxHeight | max-height | Dimensions | breakpoints |
display | display | none | breakpoints |
verticalAlign | vertical-align | none | breakpoints |
overflow | overflow | none | breakpoints |
overflowX | overflow-x | none | breakpoints |
overflowY | overflow-y | none | breakpoints |
gap | gap | none | breakpoints |
alignSelf | align-self | none | breakpoints |
aspectRatio | aspect-ratio | none | breakpoints |
justifyContent | justify-content | none | breakpoints |
justifyItems | justify-items | none | breakpoints |
justifySelf | justify-self | none | breakpoints |
contentVisibility | content-visibility | none | breakpoints |
transform | transform | none | breakpoints |
transformOrigin | transform-origin | none | breakpoints |
transformStyle | transform-style | none | breakpoints |
Flex Layout
<Div alignItems="center"> <Text>Tree frog</Text> <Text>Pond frog</Text> </Div>
Prop | CSS property | Scale | Supports |
---|---|---|---|
alignItems | align-items | none | breakpoints |
alignContent | align-content | none | breakpoints |
flex | flex (shorthand) | none | breakpoints |
flexBasis | flex-basis | none | breakpoints |
flexDirection | flex-direction | none | breakpoints |
flexFlow | flex-flow | none | breakpoints |
flexGrow | flex-grow | none | breakpoints |
flexShrink | flex-shrink | none | breakpoints |
flexWrap | flex-wrap | none | breakpoints |
order | order | none | breakpoints |
Grid Layout
<Div gridAutoFlow="row dense"> <Text>Tree frog</Text> <Text>Pond frog</Text> </Div>
Prop | CSS property | Scale | Supports |
---|---|---|---|
grid | grid (shorthand) | none | breakpoints |
gridArea | grid-area | none | breakpoints |
gridAutoColumns | grid-auto-columns | Dimensions | breakpoints |
gridAutoFlow | grid-auto-flow | none | breakpoints |
gridAutoRows | grid-auto-rows | Dimensions | breakpoints |
gridColumn | grid-column | none | breakpoints |
gridColumnEnd | grid-column-end | none | breakpoints |
gridColumnSpan | grid-column-span | none | breakpoints |
gridColumnStart | grid-column-start | none | breakpoints |
gridRow | grid-row | none | breakpoints |
gridRowEnd | grid-row-end | none | breakpoints |
gridRowSpan | grid-row-span | none | breakpoints |
gridRowStart | grid-row-start | none | breakpoints |
gridTemplate | grid-template | none | breakpoints |
gridTemplateAreas | grid-template-areas | none | breakpoints |
gridTemplateColumns | grid-template-columns | Dimensions | breakpoints |
gridTemplateRows | grid-template-rows | Dimensions | breakpoints |
columnGap | column-gap | Spacing | breakpoints |
rowGap | row-gap | Spacing | breakpoints |
Background
<Div backgroundImage="url('/images/dog.png')" backgroundPosition="center" backgroundRepeat="no-repeat" />
Prop | CSS property | Scale | Supports |
---|---|---|---|
backgroundImage | background-image | none | breakpoints |
backgroundPosition | background-position | none | breakpoints |
backgroundRepeat | background-repeat | none | breakpoints |
backgroundSize | background-size | none | breakpoints |
Border
<Div border="primary" borderRadius="rounded-md" > Tree frog </Div>
Border props (border, borderBottom, borderTop, borderRight, borderLeft) uses an implicit style (solid) and width(1px). These properties only accepts colors for value.
Prop | CSS property | Scale | Supports |
---|---|---|---|
border | border-color | Colors | breakpoints & focus/hover/active |
borderBottom | border-bottom-color | Colors | breakpoints & focus/hover/active |
borderTop | border-top-color | Colors | breakpoints & focus/hover/active |
borderLeft | border-left-color | Colors | breakpoints & focus/hover/active |
borderRight | border-right-color | Colors | breakpoints & focus/hover/active |
borderRadius | border-radius | Shape | breakpoints |
borderTopLeftRadius | border-top-left-radius | Shape | breakpoints |
borderTopRightRadius | border-top-right-radius | Shape | breakpoints |
borderBottomLeftRadius | border-bottom-left-radius | Shape | breakpoints |
borderBottomRightRadius | border-bottom-right-radius | Shape | breakpoints |
outline | outline | none | breakpoints & focus |
Position
<Div top="12px" position="absolute" />
Prop | CSS property | Scale | Supports |
---|---|---|---|
position | position | none | breakpoints |
top | top | none | breakpoints |
bottom | bottom | none | breakpoints |
right | right | none | breakpoints |
left | left | none | breakpoints |
zIndex | z-index | none | breakpoints |
objectFit | object-fit | none | breakpoints |
objectPosition | object-position | none | breakpoints |
Shadow
<Div boxShadow="lifted" />
Prop | CSS property | Scale | Supports |
---|---|---|---|
boxShadow | box-shadow | Shape | breakpoints & focus/hover/active |
Miscellaneous
Prop | CSS property | Scale | Supports |
---|---|---|---|
content | content | none | breakpoint |
cursor | cursor | none | breakpoint & hover |
pointerEvents | pointer-events | none | breakpoint |
resize | resize | none | breakpoint |
willChange | will-change | none | breakpoint |