Castle logo

CASTLE UI

search

Search

K
hexagon

Style props are a way to alter the style of a component by simply passing props to it. It helps to save time by providing helpful shorthand ways to style components.

Reference

Design System

Some props are mapped to our styling guide, instead of being traditional css props.

PropDescriptionValue
levelPerceived depth on UI (Cards or Shaded areas)-2 ... 3
borderWidthWidth on bordersnormal , thick
borderStyleBorder stylesolid , dashed

Margin and padding

<Box m={2}>One</Box>
<Box maxW="960px" mx="auto">Two</Box>
content_copy

Copy

PropCSS PropertyTheme Key
m, marginmarginspace
mt, marginTopmargin-topspace
mr, marginRightmargin-rightspace
me, marginEndmargin-inline-endspace
mb, marginBottommargin-bottomspace
ml, marginLeftmargin-leftspace
ms, marginStartmargin-inline-startspace
mxmargin-inline-start + margin-inline-endspace
mymargin-top + margin-bottomspace
p, paddingpaddingspace
pt, paddingToppadding-topspace
pr, paddingRightpadding-rightspace
pe, paddingEndpadding-inline-endspace
pb, paddingBottompadding-bottomspace
pl, paddingLeftpadding-leftspace
ps, paddingStartpadding-inline-startspace
pxpadding-inline-start + padding-inline-endspace
pypadding-top + padding-bottomspace

For mx and px props, we use margin-inline-start and margin-inline-end to ensure the generated styles are RTL-friendly

Color and background color

import { Box } from "@passfort/ui"
// picks up a nested color value using dot notation
// => \`theme.colors.gray[50]\`
<Box color='gray.50' />
// raw CSS color value
<Box color='#f00' />
// background colors
<Box bg='tomato' />
// verbose prop
<Box backgroundColor='tomato' />
content_copy

Copy

PropCSS PropertyTheme Key
colorcolorcolors
bg, backgroundbackgroundcolors
bgColorbackground-colorcolors
opacityopacitynone

Typography

// font-size of \`theme.fontSizes.md\`
<Text fontSize="md" />
// font-size \`32px\`
<Text fontSize={32} />
// font-size \`2em\`
<Text fontSize='2em' />
// text-align \`left\` on all viewports and \`center\` from the first breakpoint and up
<Text textAlign={[ 'left', 'center' ]} />
content_copy

Copy

PropCSS PropertyTheme Key
fontFamilyfont-familyfonts
fontSizefont-sizefontSizes
fontWeightfont-weightfontWeights
lineHeightline-heightlineHeights
letterSpacingletter-spacingletterSpacings
textAligntext-alignnone
fontStylefont-stylenone
textTransformtext-transformnone
textDecorationtext-decorationnone

Layout, width and height

import { Box } from "@passfort/ui"
// verbose
<Box width="100%" height={32} />
// shorthand
<Box w="100%" h="32px" />
// use theme sizing
<Box boxSize="sm" />
// width \`50%\`
<Box w={1/2} />
// width \`256px\`
<Box w={256} />
// width \`40px\`
<Box w='40px' />
content_copy

Copy

PropCSS PropertyTheme Key
w, widthwidthsizes
h, heightheightsizes
minW, minWidthmin-widthsizes
maxW, maxWidthmax-widthsizes
minH, minHeightmin-heightsizes
maxH, maxHeightmax-heightsizes
d, displaydisplaynone
boxSizewidth, heightsizes
verticalAlignvertical-alignnone
overflowoverflownone
overflowXoverflowXnone
overflowYoverflowYnone

Flexbox

// verbose
<Box display="flex" alignItems="center" justifyContent="space-between">
Box with Flex props
</Box>
// shorthand using the \`Flex\` component
<Flex align="center" justify="center">
Flex Container
</Flex>
content_copy

Copy

Note: Props in * will only work if you use the Flex component.

PropCSS PropertyTheme Key
alignItems, *alignalign-itemsnone
alignContentalign-contentnone
justifyItemsjustify-itemsnone
justifyContent, *justifyjustify-contentnone
flexWrap, *wrapflex-wrapnone
flexDirection, flexDir, *directionflex-directionnone
flexflexnone
flexGrowflex-grownone
flexShrinkflex-shrinknone
flexBasisflex-basisnone
justifySelfjustify-selfnone
alignSelfalign-selfnone
orderordernone

Grid Layout

// verbose
<Box display="grid" gridGap={2} gridAutoFlow="row dense">
Grid
</Box>
// shorthand using the \`Grid\` component
<Grid gap={2} autoFlow="row dense">
Grid
</Grid>
content_copy

Copy

Note: Props in * will only work if you use the Grid component.

PropCSS PropertyTheme Key
gridGap, *gapgrid-gapspace
gridRowGap, *rowGapgrid-row-gapspace
gridColumnGap, *columnGapgrid-column-gapspace
gridColumn, *columngrid-columnnone
gridRow, *rowgrid-rownone
gridArea, *areagrid-areanone
gridAutoFlow, *autoFlowgrid-auto-flownone
gridAutoRows, *autoRowsgrid-auto-rowsnone
gridAutoColumns, *autoColumnsgrid-auto-columnsnone
gridTemplateRows, *templateRowsgrid-template-rowsnone
gridTemplateColumns, *templateColumnsgrid-template-columnsnone
gridTemplateAreas, *templateAreasgrid-template-areasnone

Background

// verbose
<Box
backgroundImage="url('/images/kyuubi.png')"
backgroundPosition="center"
backgroundRepeat="no-repeat"
/>
// shorthand
<Box
bgImage="url('/images/gaara.png')"
bgPosition="center"
bgRepeat="no-repeat"
/>
content_copy

Copy

PropCSS PropertyTheme Key
bg, backgroundbackgroundnone
bgImage, backgroundImagebackground-imagenone
bgSize, backgroundSizebackground-sizenone
bgPosition, backgroundPositionbackground-positionnone
bgRepeat, backgroundRepeatbackground-repeatnone
bgAttachment, backgroundAttachmentbackground-attachmentnone

Borders

<Box border="1px" borderColor="N200">
Card
</Box>
content_copy

Copy

PropCSS PropertyTheme Field
borderborderborders
borderWidthborder-widthborderWidths
borderStyleborder-styleborderStyles
borderColorborder-colorcolors
borderTopborder-topborders
borderTopWidthborder-top-widthborderWidths
borderTopStyleborder-top-styleborderStyles
borderTopColorborder-top-colorcolors
borderRightborder-rightborders
borderEndborder-inline-endborders
borderRightWidthborder-right-widthborderWidths
borderEndWidthborder-inline-end-widthborderWidths
borderRightStyleborder-right-styleborderStyles
borderEndStyleborder-inline-end-styleborderStyles
borderRightColorborder-right-colorcolors
borderEndColorborder-inline-end-colorcolors
borderBottomborder-bottomborders
borderBottomWidthborder-bottom-widthborderWidths
borderBottomStyleborder-bottom-styleborderStyles
borderBottomColorborder-bottom-colorcolors
borderLeftborder-leftborders
borderStartborder-inline-startborders
borderLeftWidthborder-left-widthborderWidths
borderStartWidthborder-inline-start-widthborderWidths
borderLeftStyleborder-left-styleborderStyles
borderStartStyleborder-inline-start-styleborderStyles
borderLeftColorborder-left-colorcolors
borderStartColorborder-inline-start-colorcolors
borderXborder-left, border-rightborders
borderYborder-top, border-bottomborders

Border Radius

// This button will have no right borderRadius
<Button borderRightRadius="0">Button 1</Button>
// This button will have no left borderRadius
<Button borderLeftRadius="0">Button 2</Button>
// top left and top right radius will be \`theme.radii.md\` => 4px
<Button borderTopRadius="md">Button 2</Button>
content_copy

Copy

PropCSS PropertyTheme Field
borderRadiusborder-radiusradii
borderTopLeftRadiusborder-top-left-radiusradii
borderTopStartRadiusborder-top-left-radius in LTR, border-top-right-radius in RTLradii
borderTopRightRadiusborder-top-right-radiusradii
borderTopEndRadiusborder-top-right-radius in LTR, border-top-left-radius in RTLradii
borderBottomRightRadiusborder-bottom-right-radiusradii
borderBottomEndRadiusborder-bottom-right-radius in LTR, border-bottom-left-radius in RTLradii
borderBottomLeftRadiusborder-bottom-left-radiusradii
borderBottomStartRadiusborder-bottom-left-radius in LTR, border-bottom-left-radius in RTLradii
borderTopRadiusborder-top-left-radius + border-top-right-radiusradii
borderRightRadiusborder-top-right-radius + border-bottom-right-radiusradii
borderEndRadiusborder-top-right-radius + border-bottom-right-radiusradii
borderBottomRadiusborder-bottom-left-radius + border-bottom-right-radiusradii
borderLeftRadiusborder-top-left-radius + border-bottom-left-radiusradii
borderStartRadiusborder-top-left-radius + border-bottom-left-radiusradii

Position

// verbose
<Box position="absolute">Cover</Box>
// shorthand
<Box pos="absolute">Cover</Box>
<Box pos="absolute" top="0" left="0">
Absolute with top and left
</Box>
<Box pos="fixed" w="100%" zIndex={2}>
Fixed with zIndex
</Box>
content_copy

Copy

PropCSS PropertyTheme Field
pos,positionpositionnone
zIndexz-indexzIndices
toptopspace
rightrightspace
bottombottomspace
leftleftspace

Shadow

<SimpleGrid
bg="gray.50"
columns={{ sm: 2, md: 4 }}
spacing="8"
p="10"
textAlign="center"
rounded="lg"
color="gray.400"
>
<Box boxShadow="xs" p="6" rounded="md" bg="N0">
xs
</Box>
<Box boxShadow="sm" p="6" rounded="md" bg="white">
sm
</Box>
<Box boxShadow="base" p="6" rounded="md" bg="N0">
Base
</Box>
<Box boxShadow="md" p="6" rounded="md" bg="white">
md
</Box>
<Box boxShadow="lg" p="6" rounded="md" bg="white">
lg
</Box>
<Box boxShadow="xl" p="6" rounded="md" bg="white">
xl
</Box>
<Box boxShadow="2xl" p="6" rounded="md" bg="white">
2xl
</Box>
<Box boxShadow="dark-lg" p="6" rounded="md" bg="white">
Dark lg
</Box>
<Box boxShadow="outline" p="6" rounded="md" bg="white">
Outline
</Box>
<Box boxShadow="inner" p="6" rounded="md" bg="white">
Inner
</Box>
</SimpleGrid>
content_copy

Copy

Pseudo

// :hover style
<Button
colorScheme="teal"
_hover={{
background: "white",
color: "teal.500",
}}
>
Hover me
</Button>
// apply :hover over parent element
<Box
role="group"
>
<Box
_hover={{ fontWeight: 'semibold' }}
_groupHover={{ color: 'tomato' }}
>
</Box>
</Box>
content_copy

Copy

PropCSS PropertyTheme Field
_hover:hover,
[data-hover]
none
_active:active,
[data-active]
none
_focus:focus,
[data-focus]
none
_highlighted[data-highlighted]none
_focusWithin:focus-withinnone
_focusVisible:focus-visiblenone
_disabled[disabled],
[aria-disabled=true],
[data-disabled]
none
_readOnly[aria-readonly=true],
[readonly],
[data-readonly]
none
_before::beforenone
_after::afternone
_empty:emptynone
_expanded[aria-expanded=true],
[data-expanded]
none
_checked[aria-checked=true],
[data-checked]
none
_grabbed[aria-grabbed=true],
[data-grabbed]
none
_pressed[aria-pressed=true],
[data-pressed]
none
_invalid[aria-invalid=true],
[data-invalid]
none
_valid[data-valid],
[data-state=valid]
none
_loading[data-loading],
[aria-busy=true]
none
_selected[aria-selected=true],
[data-selected]
none
_hidden[hidden],
[data-hidden]
none
_autofill:-webkit-autofillnone
_even:nth-of-type(even)none
_odd:nth-of-type(odd)none
_first:first-of-typenone
_last:last-of-typenone
_notFirst:not(:first-of-type)none
_notLast:not(:last-of-type)none
_visited:visitednone
_activeLink[aria-current=page]none
_activeStep[aria-current=step]none
_indeterminate:indeterminate,
[aria-checked=mixed],
[data-indeterminate]
none
_groupHover[role=group]:hover &,
[role=group][data-hover] &
none
_groupFocus[role=group]:focus &,
[role=group][data-focus] &
none
_groupActive[role=group]:active &,
[role=group][data-active] &
none
_groupDisabled[role=group]:disabled &,
[role=group][data-disabled] &
none
_groupInvalid[role=group][data-invalid] &none
_groupChecked[role=group][data-checked] &none
_placeholder::placeholdernone
_fullScreen:fullscreennone
_selection::selectionnone

Other Props

Asides all the common style props listed above, all component will accept the following props:

PropCSS PropertyTheme Field
animationanimationnone
appearanceappearancenone
transformtransformnone
transformOrigintransform-originnone
visibilityvisibilitynone
whiteSpacewhite-spacenone
userSelectuser-selectnone
pointerEventspointer-eventsnone
wordBreakword-breaknone
overflowWrapoverflow-wrapnone
textOverflowtext-overflownone
boxSizingbox-sizingnone
cursorcursornone
resizeresizenone
transitiontransitionnone
objectFitobject-fitnone
objectPositionobject-positionnone
floatfloatnone
fillfillcolors
strokestrokecolors
outlineoutlinenone

The as prop

The as prop is a feature in all of our components that allows you to pass an HTML tag or component to be rendered.

For example, say you are using a Button component, and you need to make it a link instead. You can compose a and Button like this:

content_copy

Copy

live example

This allows you to use all of the Button props and all of the a props without having to wrap the Button in an a component.

Contents