-
Notifications
You must be signed in to change notification settings - Fork 0
Apply styles globally and selectors
Brandon Jordan edited this page Oct 13, 2023
·
4 revisions
If you want to apply a style to the document <body>
tag, simply add style methods to the view()
or router()
function.
view([
// ...
]).font('system')
// or router
router([
// ...
]).font('system')
If you want to apply styles to every instance of a component like you would in CSS, but using the style methods, use the globalStyle()
function.
import { globalStyle } from 'javascript-ui';
globalStyle('input, textarea')
.rounded('5px')
.border('#c7c7c7', '2px')
.paddings(['8px', '5px'])
.font('system');
Create a JavaScript UI Element instance using a custom selector.
import { select } from 'javascript-ui';
select('.selector#id')
.rounded('5px')
.border('#c7c7c7', '2px')
.paddings(['8px', '5px'])
.font('system');
You can also create custom components that return a customized version of another component.
CustomButton.js
:
import {Button} from 'javascript-ui';
export function CustomButton(label) {
return Button(label)
.rounded('5px')
.border('#c7c7c7', '2px')
.paddings(['8px', '5px'])
.font('system')
.onClick( () => {
// do something...
});
}
index.js
:
import {view} from 'javascript-ui';
import {CustomButton} from 'CustomButton.js'
window.onload = () => {
view([
CustomButton('Button Text')
// ...
])
};