UI Kit components
Jira UI Kit components
UI Kit hooks
Forge bridge APIs
Jira bridge APIs
Upgrade UI Kit versions
Previous versions

XCSS

With components support xcss prop, xcss utility function should be used to wrap the XCSS style definition before passing it to the component.

1
2
import { xcss } from "@forge/react";

Description

XCSS is a styling API that utilizes Atlassian Design Tokens to style primitive components safely with tokens.

Key features

  • XCSS restricts nested selectors completely from usage.
  • Pseudo class / element selectors are supported currently.
  • The majority of style attributes will be restricted to Atlassian Design Token based values to ensure safety and consistency.

Supported components

XCSS support is currently available on the Box component.

Supported properties

Props

Border

Border color

Border color related properties accept border color tokens. Learn about applying the right color tokens by understanding color roles and referring to accessibility guidelines.

NameTypeAllowed valuesDescription
borderColorstringBorder color tokens e.g. 'color.border'Set the color of the borders
borderBlockColorstringBorder color tokensSet the color of the logical block borders of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation.
borderBlockEndColorstringBorder color tokensSet the color of the logical block-end border of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation.
borderBlockStartColorstringBorder color tokensSet the color of the logical block-start border of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation.
borderBottomColorstringBorder color tokensSet the color of an element's bottom border.
borderInlineColorstringBorder color tokensSet color of the logical inline borders of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation.
borderInlineEndColorstringBorder color tokensSet the color of the logical inline-end border of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation.
borderInlineStartColorstringBorder color tokensSet the color of the logical inline start border of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation.
borderLeftColorstringBorder color tokensSet the color of an element’s left border.
borderRightColorstringBorder color tokensSet the color of an element’s right border.
borderTopColorstringBorder color tokensSet the color of an element’s top border.

Border radius

NameTypeAllowed valuesDescription
borderRadiusstring'border.radius'Set border radius of an element's side e.g. bottom-left corner.
borderBottomLeftRadiusstring'border.radius'Set border radius of an element's bottom-left corner.
borderBottomRightRadiusstring'border.radius'Set border radius of an element's bottom-right corner.
borderTopLeftRadiusstring'border.radius'Set border radius of an element's top-left corner.
borderTopRightRadiusstring'border.radius'Set border radius of an element's top-right corner.
borderEndEndRadiusstring'border.radius'Set a logical border radius on an element, which maps to a physical border radius that depends on the element's writing-mode, direction, and text-orientation.
borderEndStartRadiusstring'border.radius'Set a logical border radius on an element, which maps to a physical border radius depending on the element's writing-mode, direction, and text-orientation.
borderStartEndRadiusstring'border.radius'Set a logical border radius on an element, which maps to a physical border radius depending on the element's writing-mode, direction, and text-orientation.
borderStartStartRadiusstring'border.radius'Set a logical border radius on an element, which maps to a physical border radius that depends on the element's writing-mode, direction, and text-orientation.

Border width

NameTypeAllowed valuesDescription
borderWidthstring'border.width'Set the width of an element's border.
borderBlockWidthstring'border.width'Set the width of the logical block borders of an element, which maps to a physical border width depending on the element's writing mode, directionality, and text orientation.
borderBlockEndWidthstring'border.width'Set the width of the logical block-end border of an element, which maps to a physical border width depending on the element's writing mode, directionality, and text orientation.
borderBlockStartWidthstring'border.width'Set the width of the logical block-start border of an element, which maps to a physical border width depending on the element's writing mode, directionality, and text orientation.
borderBottomWidthstring'border.width'Set the width of the bottom border of an element.
borderInlineWidthstring'border.width'Set the width of the logical inline borders of an element, which maps to a physical border width depending on the element's writing mode, directionality, and text orientation.
borderInlineEndWidthstring'border.width'Set the width of the logical inline-end border of an element, which maps to a physical border width depending on the element's writing mode, directionality, and text orientation.
borderInlineStartWidthstring'border.width'Set the width of the logical inline-start border of an element, which maps to a physical border width depending on the element's writing mode, directionality, and text orientation.
borderLeftWidthstring'border.width'Set the width of the left border of an element.
borderRightWidthstring'border.width'Set the width of the right border of an element.
borderTopWidthstring'border.width'Set the width of the top border of an element.

Border style

NameTypeAllowed valuesDescription
borderTopStylestring'dotted' | 'dashed' | 'solid' | 'none' | 'hidden'Set the line style of an element's top border.
borderBottomStylestring'dotted' | 'dashed' | 'solid' | 'none' | 'hidden'Set the line style of an element's bottom border.
borderRightStylestring'dotted' | 'dashed' | 'solid' | 'none' | 'hidden'Set the line style of an element's right border.
borderLeftStylestring'dotted' | 'dashed' | 'solid' | 'none' | 'hidden'Set the line style of an element's left border.
borderStylestring'dotted' | 'dashed' | 'solid' | 'none' | 'hidden'Set the line style for all four sides of an element's border.

Color

The colour related properties are used to style and enhance the text and background colours of the elements. Learn about applying the right color tokens by understanding color roles and referring to accessibility guidelines.


Opacity


Shadow


Size

NameTypeAllowed valuesDescription
widthstring'30px' | '25em' | '10%'Set an element's width.
heightstring'30px' | '25em' | '10%'Set an element's height.
minWidthstring'30px' | '25em' | '10%'Sets the minimum width of an element.
maxWidthstring'30px' | '25em' | '10%'Set the maximum width of an element
minHeightstring'30px' | '25em' | '10%'Set the minimum height of an element.
maxHeightstring'30px' | '25em' | '10%'Set the maximum height of an element.

Space

NameTypeAllowed valuesDescription
marginstringSpace tokens e.g. 'space.050'Set the margin area on all four sides of an element.
marginBlockstringSpace tokensSet the logical block start and end margins of an element, which maps to physical margins depending on the element's writing mode, directionality, and text orientation.
marginBlockEndstringSpace tokensSet the logical block end margin of an element, which maps to a physical margin depending on the element's writing mode, directionality, and text orientation.
marginBlockStartstringSpace tokensSet the logical block start margin of an element, which maps to a physical margin depending on the element's writing mode, directionality, and text orientation.
marginBottomstringSpace tokensSet the margin area on the bottom of an element.
marginInlinestringSpace tokensSet both the logical inline start and end margins of an element, which maps to physical margins depending on the element's writing mode, directionality, and text orientation.
marginInlineEndstringSpace tokensSet the logical inline end margin of an element, which maps to a physical margin depending on the element's writing mode, directionality, and text orientation.
marginInlineStartstringSpace tokensSet the logical inline start margin of an element, which maps to a physical margin depending on the element's writing mode, directionality, and text orientation.
marginLeftstringSpace tokensSet the margin area on the left side of an element.
marginRightstringSpace tokensSet the margin area on the right side of an element.
marginTopstringSpace tokensSet the margin area on the top of an element.
paddingstringSpace tokensSet the padding area on all four sides of an element at once.
paddingBlockstringSpace tokensSet the logical block start and end padding of an element, which maps to physical padding properties depending on the element's writing mode, directionality, and text orientation.
paddingBlockEndstringSpace tokensSet the logical block end padding of an element, which maps to a physical padding depending on the element's writing mode, directionality, and text orientation.
paddingBlockStartstringSpace tokensSet the logical block start padding of an element, which maps to a physical padding depending on the element's writing mode, directionality, and text orientation.
paddingBottomstringSpace tokensSet the height of the padding area on the bottom of an element.
paddingInlinestringSpace tokensSet the logical inline start and end padding of an element, which maps to physical padding properties depending on the element's writing mode, directionality, and text orientation.
paddingInlineEndstringSpace tokensSet the logical inline end padding of an element, which maps to a physical padding depending on the element's writing mode, directionality, and text orientation.
paddingInlineStartstringSpace tokensSet the logical inline start padding of an element, which maps to a physical padding depending on the element's writing mode, directionality, and text orientation.
paddingLeftstringSpace tokensSet the width of the padding area to the left of an element.
paddingRightstringSpace tokensSet the width of the padding area on the right of an element.
paddingTopstringSpace tokensSet the height of the padding area on the top of an element.

Examples

Basic

XCSS can pull together different types of interactions and UI in a safer, more composable way.

Example of using basic xcss on box component

1
2
import React from 'react';

import { Heading, Box, Stack, xcss } from '@forge/react';

const textStyle = xcss({
  color: 'color.text',
});

const cardStyle = xcss({
  backgroundColor: 'color.background.accent.purple.subtlest',
  padding: 'space.200',
  borderColor: 'color.border.discovery',
  borderWidth: 'border.width',
  borderStyle: 'solid',
  borderRadius: 'border.radius',
  width: '240px',
});

export const Basic = () => (
  <Box xcss={cardStyle}>
    <Stack space="space.100">
      <Heading as="h3" level="h600">Heading</Heading>
      <Box xcss={textStyle}>Description</Box>
    </Stack>
  </Box>
);

Interactivity

To enable interactivity, use familiar selectors like :hover.

Example of using xcss with hover on box component

1
2
import React from 'react';

import { Heading, Box, Stack, Link, xcss } from '@forge/react';

const textStyle = xcss({
  color: 'color.text',
  marginBottom: 'space.200',
});

const cardStyle = xcss({
  backgroundColor: 'elevation.surface',
  padding: 'space.200',
  borderColor: 'color.border',
  borderWidth: 'border.width',
  borderStyle: 'solid',
  borderRadius: 'border.radius',
  ':hover': {
    backgroundColor: 'elevation.surface.hovered',
  },
});

const GetStartedCard = ({ header, description }) => {
  return (
    <Box xcss={cardStyle}>
      <Stack space="space.100" alignInline="start">
        <Heading as="h3" level="h600">{header}</Heading>
        <Box xcss={textStyle}>{description}</Box>
        <Link  href="/">
          Get started
        </Link>
      </Stack>
    </Box>
  );
}

export const InteractivityExample = () => (
  <Inline space="space.200">
    <GetStartedCard header="Set up" description="Create a project and add tasks" />
    <GetStartedCard header="Plan project" description="Assign tasks and set timelines" />
  </Inline>
);

Rate this page: