react-native inspired implementation of stylesheet, written in typescript
npm install nodegui-stylesheetreact-native inspired implementation of stylesheet, written in typescript
Compatible with plain nodegui and react-nodegui, both JS and TS.
1 Create a stylesheet
``javascript
import { create } from 'nodegui-stylesheet';
const style = create({
wrapper: {
flex: 1
},
logo: {
fontSize: 14
}
});
`
2 Use stylesheet properties instead of long css strings
`typescript jsx`
// with nogegui-react
`javascript`
// with plain nogegui
const label = new QLabel();
label.setText("Hello");
label.setInlineStyle(style.logo);
3 Use specific units if you need them, list of supported units from qt docs:
- px: pixels
- pt: the size of one point (i.e., 1/72 of an inch)
- em: the em width of the font (i.e., the width of 'M')
- ex: the ex width of the font (i.e., the height of 'x')
`javascript
import { create, units } from 'nodegui-stylesheet';
const style = create({
wrapper: {
flex: 1
},
logo: {
marginTop: units(1, 'ex')
}
});
``