Skip to content

Advanced Configuration

utilities

The utilities field is an array of utility definitions. Each utility definition is an object with the following fields:

FieldTypeDescription
keystringThe key of the utility, e.g. bg
cssstringThe css handler for the utility, e.g. background-color: $1
modifierValueDefThe modifier for the utility, e.g. bg-blue-500/50
themestringThe theme key for the utility, will read from theme by this key later, e.g. colors (camelCase)
typeDataType | PropertyKeyType of the utility, for inferring value of arbitrary values, could either be a css data type or a property key, e.g. percentage, font-size
negativebooleanWhether the utility supports negative values
fractionbooleanWhether the utility supports fraction values, e.g. w-1/2

Basic Usage

e.g. A rswind.config.json defining a custom utility like outline-color:

json
{
  "utilities": [
    {
      "key": "outline",
      "css": {
        "outline-color": "$0:color"
      },
      "theme": "colors"
    }
  ]
}

By simply defining a key with outline and theme of colors, utilities like outline-blue-500 are able to use

type

Adding type for this utility, we can use arbitrary value like outline-[#333333]

json
{
  "utilities": [
    {
      "key": "outline-color",
      "css": {
        "outline-color": "$0:color"
      },
      "theme": "colors",
      "type": "color"
    }
  ]
}

modifier

Assume we need opacity, by defining modifier

outline-blue-500/50 and outline-red-600/[99] are available

json
{
  "utilities": [
    {
      "key": "outline-color",
      "css": {
        "outline-color": "$0:color"
      },
      "theme": "colors",
      "type": "color",
      "modifier": {
        "theme": "opacity",
        "type": "percentage"
      }
    }
  ]
}

Released under the MIT License.