Basic input form elements as mithril components
npm install mithril-material-formsLightweight input form components using mithril. Requires material-icon font to work correctly (checkbox, select).
``html`
`scss`
// pick requried styles
@import "mithril-material-forms/styles/layout";
@import "mithril-material-forms/styles/typography";
// maybe add additional themes
@import "mithril-material-forms/styles/theme-material";
@import "mithril-material-forms/styles/theme-solid";
// and choose a default theme
@import "mithril-material-forms/styles/theme-solid-as-default";
Use with
`typescript`
import m from "mithril";
import { Switch, SwitchAttrs } from "mithril-material-forms";
m.render(document.body,
m(Switch,
);
For attribute details check each component implementation in _index.js_. For a list of example build checkout the examples page in /docs/index.html or goto mithril-material-forms docs
Change default theme, by including styles and setting the theme through attributes
`typescript`
import m from "mithril";
import "mithril-material-forms/styles/theme-solid";
import { Switch, SwitchAttrs } from "mithril-material-forms";
m.render(document.body,
m(Switch,
);
- per convention, an attribute onchange(value): void is used to register to change events
v4
- mithril is now written in typescript and uses no babel transpilation. There may be a need for polyfills
- components are exported separately
v3
- required mithril-dependency >= v2onchange
- all callbacks have mithil-lowercase names instead of _onChange_button
- this was inconsistent in , checkbox and input
Adding a new component
A set of instructions for creating and adding a new mithril material component.
1. Add a new folder to ./components/./components/
2. In this folder, create following files:
- Component code: ./components/
- General style: ./components/
- [Optional] Style for material theme: ./components/
- [Optional] Style for solid theme: ./index.ts
3. Register your component in ./components/
4. Add your layout file () to ./styles/layout.scss./app/index.ts
5. To add your new to component to the demo page, in ...template` object, in all possible variations (e.g. disabled, with(out) icon, etc.)
- Add it to the
- Add it to the last render function