RFC: Theming in jaspr #162
schultek
announced in
Announcements & RFCs
Replies: 1 comment
-
I have never used Tailwind but from the examples I have seen it's super unreadable. Having Tailwind-specific themes would be awesome. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With the typed
Styles
class coming in the next release (#18), jaspr will get a powerful mechanism of styling elements through pure type-safe Dart.There are currently two main cases where
Styles
can be used:DomComponent
rendered as inline styles<style>
element as a set of css rulesThere is a clear mismatch of good vs bad practices when applying these to the declarative component model vs the html/css model:
Styling a component directly
<style>
) and the referred to via ids, classes and other selectors. Inline styles are also less performant than style-sheet rules with e.g. classes (especially for modifying inline-styles vs toggling classes on and off).Bundling rules in a stylesheet
Additionally there is the issue of bundle size. Right now,
Styles
would be included in the compiled js bundle, even if they are defined statically and don't change. This is not optimal especially when using ssr where the server could render out the styles to css and the client would only need to know the classes referencing the styles.Themes
Themes should solve the above problems by
a) providing a familiar, declarative api for the user to define and use themes (which are a collection of styles)
b) internally use css best practices (stylesheets with classes over inline styles)
c) only bundling relevant parts for the client (ideally removing any styles instances)
This could be implemented like this:
Beta Was this translation helpful? Give feedback.
All reactions