trafnar
Joined 17 years ago
Joined 17 years ago
Imba allows you to write CSS anywhere in a component definition using CSS-like syntax (rather than Javascript object syntax).
The syntax for adding a quick inline style is so simple:
<div [width:20px]>
You can even do hover states in an inline style: <div [color:red @hover:blue]>
And interpolation is easy too: <div [width:{someValue}px]>
Putting a CSS block at any level of your tag hierarchy scopes it to that tag. <div.foo>
<div.bar>
css color:red # this applies to div.bar
em color:blue # this applies to div.bar em
"hello"
<em> "world"
CSS blocks declared in a component definition but outside of the markup, apply to the whole tag. CSS declared in a file, outside of a component definition, apply to all components defined in that file. There is also a global keyword to apply styles globally.and there's a whole range of other useful features, a favorite of mind is the shorthand syntax for things like this:
c:red # same as color:red
d:vtc # same as display:flex flex-direction:column justify-content:center
x:10px rotate:30deg # same as transform:translateX(10px), rotate(30deg) tag Counter
count = 0
<self @click=(count++)> "count: {count}"- TaskTXT - Plain text todos and tasks with timers https://www.tasktxt.com
- ReadyRunner - GPT chat for desktop https://www.readyrunner.ai
- Chonky Menu Re-Creation - Breakdown of a fancy menu UI https://www.nathanmanousos.com/posts/chonky-menu
I’ve made several videos about Imba too:
- Building a counter in 49 seconds: https://www.youtube.com/watch?v=8XS5q9xhaMc
- Video timeline UI: https://www.youtube.com/watch?v=GbKTEqmCAJM
- All of my Imba videos here: https://www.youtube.com/playlist?list=PLYxkh3w952l5cwxYLcCsd...
I made the (free) official course on Scrimba: https://www.imba.io/learn/imba
Which is also on YouTube: https://www.youtube.com/watch?v=8DcOgcCy7zs
I understand that Imba is not appropriate for everyone and every project but I encourage you not to dismiss it. One are where it is clearly valuable is in building prototypes and side projects.
css div { background-color: red; display: flex; flex-direction: column; }
div@hover {background-color:blue;}
css div background-color: red display: flex flex-direction: column
div@hover background-color: blue
css div bgc:red @hover:blue d:vflex let count = 0
tag Counter
<self @click=(count++)> "Count is: {count}"
imba.mount <Counter>, document.body