On this page

Style of the component

If you use Ray to build a miniapp or a WeChat miniApp, responsive pixel (rpx) is recommended.

rpx can be used to adapt to screen width. The specified screen width is 750rpx. Take iPhone 6 as an example. The screen width is 375px and has total 750 physical pixels.

750rpx = 375px = 750 physical pixels, 1rpx = 0.5px = 1 physical pixel.

Devicerpx converted to px (screen width ÷ 750)px converted to rpx (750 ÷ screen width)
iPhone 51rpx = 0.42px1px = 2.34rpx
iPhone 61rpx = 0.5px1px = 2rpx
iPhone 6 Plus1rpx = 0.552px1px = 1.81rpx

Preprocessor

Ray supports less by default. In the future, more preprocessor settings will be available in the form of plugins.

px conversion

Ray uses the px unit. This unit remains unchanged when you build a miniapp. If you build a web app, px is converted to rem, with a ratio of 100:1.

Example:

.foo {
  height: 16px;
}

Build a miniapp

.foo {
  height: 16px;
}

Build a web app

.foo {
  height: 0.16rem;
}

CSS Modules

Ray automatically recognizes CSS Modules. Files with .module.css or .module.less suffixes are recognized as CSS Modules files.

Example:

// Automatically recognize foo.module.css as CSS Modules
import styles from './foo.module.css';
// Automatically recognize bar.css as global style
import './bar.css';