Patterns

Learn useful patterns for working with components.


Polymorphism

Use the asChild prop to change the underlying tag rendered by components with a singular root element.

<Text asChild>
<h1>Hello world</h1>
</Text>

Utilities

We ship a few handy shorthands which you can use as props on all components.

PropertyDescription
mApplies margin
mtApplies margin-top
mrApplies margin-right
mbApplies margin-bottom
mlApplies margin-left
mxApplies margin-left and margin-right
myApplies margin-top and margin-bottom
pApplies padding
ptApplies padding-top
prApplies padding-right
pbApplies padding-bottom
plApplies padding-left
pxApplies padding-left and padding-right
pyApplies padding-top and padding-bottom

Only values from the spacing scale are available as props. For example, to apply a margin-right value of 4px.

<Button mr="4">Submit<Button>;