Styling your components
Styling components is quite simple; you can either use standard CSS or CSS Modules.
CSS
import { Component, html } from 'vistajs/dom';
import { bootstrap } from 'vistajs/boot';
// Just import your styles
import './styles.css'
const App = Component('my-component', () => {
return () => html`<button>Hello World</button>`;
})
const root = document.querySelector('#root') as Element;
bootstrap(root, App).button {
border: 0;
padding: 0.5rem 1rem;
background-color: #000;
color: #fff;
border-radius: 0.25rem;
}CSS Modules
import { Component, html } from 'vistajs/dom';
import { bootstrap } from 'vistajs/boot';
// Just import your styles, reminding of naming it with *.module.css
import styles './styles.module.css'
const App = Component('my-component', () => {
return () => html`<button class='${styles.button}'>Hello World</button>`;
})
const root = document.querySelector('#root') as Element;
bootstrap(root, App).button {
border: 0;
padding: 0.5rem 1rem;
background-color: #000;
color: #fff;
border-radius: 0.25rem;
}Going further
These are the basics. However, since VistaJS is powered by Vite, you can extend it by adding your own styling configurations. Feel free to reach out to Vite for more details.
Last updated