<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

Core props

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.

For more information, see Color.

Share

Text color

The textColor prop is a core prop that can be used to change the color of text.

Ensure that text and background meet a 4.5:1 color contrast ratio.

The preview has been updated.

Background color

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.

The preview has been updated.

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.

For more information, see Typography.

Share

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.

Share

Margin and padding

In the table below, "x" sets the x-axis (both left and right), while "y" sets the y-axis (both top and bottom).

Prop

Allowed values

margin / m

1-12, auto

marginX / mx

1-12, auto, between-actions, to-actions

marginY / my

1-12, auto, between-sections, between-subsections, between-actions, to-actions

marginTop / mt

1-12, auto, between-sections, between-subsections, between-actions, to-actions

marginRight / mr

1-12, auto, between-actions, to-actions, between-icon-and-text

marginBottom / mb

1-12, auto, between-sections, between-subsections, between-actions, to-actions

marginLeft / ml

1-12, auto, between-actions, to-actions, between-icon-and-text

padding / p

1-12

paddingX / px

1-12

paddingY / py

1-12

paddingTop / pt

1-12

paddingRight / pr

1-12

paddingBottom / pb

1-12

paddingLeft / pl

1-12

Responsive

All props support responsive values, allowing for different values on different screen sizes.

Share

Vanilla

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.

For more information, See Modes.

Render props

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 preview has been updated.

Share

display

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 preview has been updated.

loadingShimmer

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.

The preview has been updated.