SWAN provides a set of core props that can be used on any component.
Many of them indicate that they have Responsive supportβthis means you can provide different values for different screen sizes. For more information, see Responsive System.
Color props
Color contains two categories of core props: text color and background color. Like other core props, the allowed values for these props align with tokens.
The backgroundColor (or bgc) prop is a core prop that can be used to change the color of the background.
Ensure that text and background meet a 4.5:1 color contrast ratio. The BACKGROUND_WITH_MODE object can be used to dynamically set Dark mode to ensure the correct contrast.
Import the object from @vp/marketing-colors instead. Find more information and migration documentation in the Deprecation roadmap.
For marketing-specific background colors, the MARKETING_COLORS object offers a set of approved marketing-only background colors for use in Contentful/Builder. These can be used with whitelisted SWAN components (such as Banner) through the --swan-public-marketing-background CSS Custom Property.
Vanilla
In the vanilla API, the text color CSS class is swan-text-color-[color], e.g. swan-text-color-error.
In the vanilla API, the background color CSS class is swan-bgc-[color], e.g. swan-bgc-error.)
Text props
To apply text styling on any component it strongly recommended to use the fontSkin prop. This props adds all styling required to match the semantically grouped font styles.
If that doesn't suit you can then use other typography props to change things individually like font size, weight, family, color, capitalization, and alignment.
All of these props except fontSkin, fontSize and fontFamily have Responsive support. The fontSkin and fontSize props inherently adjust based on the screen size.
// other than fontSize, you can handle these props responsively
textAlign={{xs:'left',sm:'right'}}
textColor={{sm:'alert',lg:'black'}}
fontWeight={{xs:'normal',md:'bold'}}
textAllCaps={{sm:true,lg:false}}
/>
Space props
Space contains two categories of core props: margin and padding. Like other core props, the allowed values for these props align with tokens. Both named semantic and numeric semantic values can be used.
Space can be set in 1, 2, or 4 dimensions, similar to their shorthand CSS equivalents. Multiple props can be added to the same component, but setting multiple props that change the same dimension is not advised.
Refer to Space for more information on how space props should be used.
The Vanilla API follows the format of swan-[shorthand property]-[size], e.g. swan-mt-2.
Mode props
You can change the appearance of UI via modes. Modes can be activated through their respective core prop, e.g. darkMode. Different modes can be used together as needed, e.g. darkMode and compactMode. Modes can also be nested. To reset to the default token values, standardMode can be applied to overwrite all other modes.
You can change which HTML element a SWAN React component renders. For instance, maybe you want an Icon to be a <button> tag, or want your tile to be an <a> tag.
The display prop sets the CSS display property, specifying the display behavior (the type of rendering box) of an element.
The prop also supports the Responsive system.
Acceptable values: any value in SWANβs TypeScript type StyleDisplay, which covers most of the possible CSS values for display.
overflow
The overflow prop sets the CSS overflow property. This prop has Responsive support.
Acceptable values: any value in SWANβs TypeScript type StyleOverflow, which covers the possible CSS values for overflow.
visuallyHidden
The visuallyHidden prop is used for accessibility support, making content hidden from screens but still available to users on assistive technologies such as screen readers.
It is useful for adding additional explanatory text that sighted users might not need, but which will make the UI better understood by users on assistive technologies. This prop has Responsive support.
Acceptable values: boolean
swanStyle
You can group together any of the above props (p, m, bgc, visuallyHidden, etc) into a single prop called swanStyle. This prop has Responsive support.
The loadingShimmer is for sections of pages that are currently loading, such as skeleton screens. Typically a section with this prop will not have any content inside of it.