UI component library for Solid.js with SSR support

Overview

Dolmen

Dolmen is a themeable UI component library designed to work with Solid.js and optimized for SSR (Server-side rendering). It provides a broad selection of UI components with minimal overhead.

Themes

Themes are implemented using Stitches and CSS variables. Once a theme has been defined, you can add it to any element (and it's descendants) by adding the theme's class to that element. There is no need for a theme provider or context.

Multiple themes are supported, so you can have (for example) a sidebar with a different color scheme than the main page.

Limitations of SSR

An important consideration when rendering HTML on the server is avoiding the ugly "Flash of Unstyled Content" (FOUC) when the HTML is displayed before the CSS is loaded. This requires that all of the CSS needs to be server-side renderable.

Dolmen uses the Stitches package to generate CSS stylesheets from JavaScript on the server as well as on the client.

One limitation of this approach is that the server-generated CSS is not quite as dynamic as CSS that is generated on the client. With client-side CSS-in-JS it is possible to create styles algorithmically, but with pregenerated CSS this can cause a combinatorial explosion of stylesheets unless care is taken to limit the number of combinations.

Dolmen provides some of the benefits of dynamic styling by cherry-picking the most common and useful style combinations and incorporating them into the component APIs, similar to what styled-system does. Here's an example:

<PageHeader gap="xs" flexDirection="row">
  <Button icon round>Sign In</Button>
</PageHeader>

However, what you can't do is something like this:

<PageHeader gap="10px">
  <Button icon round>Sign In</Button>
</PageHeader>

The reason is because the value 10px is not in the selected set of known gap sizes.

To get around this limitation, the component can be styled in the traditional way, by applying a conventional stylesheet:

<PageHeader class="page-header">
  <Button icon round>Sign In</Button>
</PageHeader>
// Stylesheet
.page-header {
  gap: 10px;
}

Dolmen does not put any restriction on what kind of stylesheets you use - it will work with SASS, vanilla-extract, Tailwind, or any other CSS technology out there. You can also use CSS-in-JS frameworks if you want, bearing in mind that you may be subject to FOUC issues unless you have a means to generate the stylesheet at build time.

Bottom line, what this means is that when using the styling properties in the component APIs, one should not expect that every possible CSS property will be available, but rather only the most popular ones. Since these style properties are all known TypeScript types, auto-complete in your editor can help you to discover which properties are available and what their allowed values are.

Developing

Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:

npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

Building

Solid apps are built with adapters, which optimise your project for deployment to different environments.

By default, npm run build will generate a Node app that you can run with node build. To use a different adapter, add it to the devDependencies in package.json and specify in your vite.config.js.

You might also like...

Um website completo desenvolvido com Next SSR, Typescript, Prismic CMS do tipo blog com diversas funcionalidades para interações entre os usuários.

Um website completo desenvolvido com Next SSR, Typescript, Prismic CMS do tipo blog com diversas funcionalidades para interações entre os usuários.

Título: Spacetraveling Descrição: Um website completo desenvolvido com Next SSR, Typescript, Prismic CMS do tipo blog com diversas funcionalidades par

Dec 21, 2022

Google Clone using NEXT JS ,SSR, Tailwind and Google API's to search data.

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Sep 23, 2022

A demonstration app for Fresh that shows how to use SSR, the islands functionality, APIs and more

Fresh Pokemon Demo Code This is a demonstration app for Fresh that shows how to use SSR, the islands functionality, APIs and more. You do need to conn

Dec 18, 2022

Provide single node.js server with popular ssr and web framework

create-fullstack-node-app Provide single node.js server with popular ssr and web framework With NPM: npx create-fullstack-node-app@latest Frameworks:

Sep 26, 2022

Example of a Cloudflare Pages server side rendering (SSR) project powered by Hono.

Hono SSR on Cloudflare Pages Example of a Cloudflare Pages server side rendered (SSR) project powered by Hono. This project demonstrates: Accessing en

Nov 19, 2022

A tiny, SSR-friendly hook for listening to gamepad events.

useGamepadEvents useGamepadEvents is a tiny, SSR-friendly hook for listening to gamepad events. It's a wrapper around the Gamepad API designed for fir

Oct 2, 2022

Type-safe session for all Astro SSR project

Astro Session Why use Astro Session? When building server application with Astro, you will often need session system to identify request coming from t

Dec 19, 2022

Solid.js library adding a services layer for global shared state.

Solid.js library adding a services layer for global shared state.

Solid Services Services are "global" objects useful for features that require shared state or persistent connections. Example uses of services might i

Dec 30, 2022

A ~2kb hotkeys library for solid that adds only 2 event listeners.

A ~2kb hotkeys library for solid that adds only 2 event listeners.

Solid Hotkeys - Cmd+S+H Solid Hotkeys is the easiest way to add hotkeys to your application. Built for and with Solid. Motivation You gotta have hotke

Aug 1, 2022
Comments
  • Bundling issues

    Bundling issues

    Goal

    The goal of the project is to produce a UI widget set that works well with Solid.js and SSR.

    Requirements

    • No CSS-in-JS generated at runtime. This produces an ugly flash of unstyled content when the page is rendered on the server.
    • Users of the library should only have to bundle what is needed:
      • All JavaScript needs to be tree-shakeable.
      • CSS resources should not be prematurely bundled - instead, a separate CSS resource for each widget. If the user wants to combine CSS resources, they can do that in the bundler for their app.
    • Users of the library should not be constrained to using the same CSS framework as the library. Instead, the CSS bundled with the library should be static CSS that has already been processed.

    Current Status

    Currently I am using vanilla-extract to generate CSS resources from TypeScript at build time. There is a small amount of runtime for generating class name lists, but this is SSR-compatible.

    Vanilla-extract requires a bundler - it will work with esbuild, Vite, Webpack, rollup, and some others. This means that in a production app, the library gets bundled twice: once at the library level, and once at the application level.

    In order to work with Solid SSR, the library needs to provide something close to the original source, with the JSX tags preserved. However, at minimum the files in dist/ should be run through tsc, because the application may have a tsconfig.json with different compiler options. (Most tsconfig options don't affect how the code is written, but some - like isolateModules - can have an impact on how the code is written.)

    Other than stripping type annotations and resolving stylesheet import references, the bundler at this level should do as little as possible.

    Bundling Options

    Here is a list of the various possible bundling options:

    • tsc - this is the simplest solution, unfortunately it doesn't work because there's no vanilla-extract plugin for tsc.
    • esbuild has nothing like a "preserveModules" option, meaning that the only option is to combine all JavaScript into a single output file. While this file is tree-shakeable, the problem is that there's no way to tree-shake CSS - the file has to include an import for every generated stylesheet, and the app has no way to exclude stylesheets that are not being used.
    • vite While vite does have a 'library mode', the problems are similar to esbuild: there's no way to generate individual modules for each source file.
    • rollup - there is both a vanilla-extract plugin and a preserve modules option. This almost works, however rollup isn't smart enough to preserve the '.jsx' extension on files containing JSX syntax. In other words, input files with the extension '.tsx' get mapped to '.js' even when the JSX option is set to "preserve". This causes the application-level bundler to choke.
      • There is a rollup plugin which can be used to customize output file extensions, however it is old, appears to be unmaintained, and I could not get it to work.

    As you can see, none of these options currently work.

    Alternatives

    The most obvious approach is to abandon using vanilla-extract and re-write all of the stylesheets in SASS, possibly using CSS modules. However, in doing so I lost a lot of the benefits of vanilla-extract - type safety for CSS classes, dead code discovery, and so on.

    In this case, I would probably then use plain tsc for generating the dist folder.

    opened by viridia 1
Owner
Talin
I'm a recovering game programmer.
Talin
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Solid component and library for LiveKit (unofficial)

This package provides Solid components that makes it easier to use LiveKit in a Solid app. Inspired completely by https://github.com/livekit/livekit-r

Prince Neil Cedrick Castro 6 Mar 8, 2022
hCaptcha Component Library for Solid.

Solid hCaptcha Component Library This is a port of @hcaptcha/react-hcaptcha for Solid. Description hCaptcha is a drop-replacement for reCAPTCHA that p

Mikkel RINGAUD 5 Dec 4, 2022
🔥 Set up your new Solid component library in seconds!

Create Solid Library Create SolidJS libraries with ease! Usage npx create-solid-library <name> Development Developing components is often a visual pro

blusk 6 Oct 28, 2022
Query for CSS brower support data, combined from caniuse and MDN, including version support started and global support percentages.

css-browser-support Query for CSS browser support data, combined from caniuse and MDN, including version support started and global support percentage

Stephanie Eckles 65 Nov 2, 2022
👇 Bread n butter utility for component-tied mouse/touch gestures in Solid.

solid-gesture solid-gesture is a port of @use-gesture/react which lets you bind richer mouse and touch events to any component or view. With the data

Robert Soriano 8 Sep 30, 2022
Simple and minimal split pane component for Solid!

solid-split-pane Split pane component for Solid! Uses Split.Js under the hood. Takes all props that split.js takes, plus a gutterClass. (Q) Why not so

blusk 5 Oct 28, 2022
A starter project that includes theme switching functionality with Stitches CSS-in-JS and Remix SSR.

Welcome to Remix! Remix Docs Development From your terminal: npm run dev This starts your app in development mode, rebuilding assets on file changes.

Ross Moody 13 Dec 22, 2022