Water.css
Goals
- Responsive
- Themeable
- Good browser support (works on my old kindle's browser :P)
- Tiny size
- Beautiful
- No classes
Why?
I commonly make quick demo pages or websites with simple content. For these, I don't want to spend time styling them but don't like the ugliness of the default styles.
Water.css is a CSS framework that doesn't require any classes. You just include it in your <head>
and forget about it, while it silently makes everything nicer.
Who?
You might want to use Water.css if you're making a simple static page or demo website that you don't want to spend time styling.
Although it originally wasn't built for more complex websites, many developers have used Water.css as a base stylesheet and creatively applied custom styles to build out an entire app. Nothing is stopping you from doing the same!
How?
Just stick this in your <head>
:
๐
/
โ
Automatic Theme:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/out/water.min.css">
๐
Dark Theme:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/out/dark.min.css">
โ
Light Theme:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/out/light.min.css">
A preview of the different themes is available on the demo page!
How the "Automatic Theme" works
The main water.css
file automatically switches between light and dark mode depending on the system preferences of a user's device. This detection is made possible through a CSS media query called prefers-color-scheme
. In browsers where the preference can't be detected, water.css
will stick to the light theme.
If you want to avoid this behavior, use either dark.css
or light.css
.
Supporting Internet Explorer
All three distributions of Water.css support Internet Explorer 11, but the main water.css
file doesn't respect the user's color scheme and will be locked to light mode due to lack of prefers-color-scheme
support.
Be aware that IE also doesn't support runtime theming, and fixed fallback values will be used. If you want to override the Water.css theme in a way that's compatible with IE, we recommend that you compile your own theme.
Unminified builds
All versions are also available as unminified stylesheets, which can be handy during development.
Simply remove the .min
from the file name.
Theming
Do you want to make some adjustments or build your own theme completely different from the official dark or light themes? Since Water.css is built with CSS variables this is super easy to do! Here's a list list of all the variables you can change to your liking:
--background-body
--background
--background-alt
--selection
--text-main
--text-bright
--text-muted
--links
--focus
--border
--code
--animation-duration
--button-hover
--scrollbar-thumb
--scrollbar-thumb-hover
--form-placeholder
--form-text
--variable
--highlight
--select-arrow
Runtime theming
โ If you use a version with support for legacy browsers like Internet Explorer, skip to Compiling your own theme!
Water.css uses Custom Properties ("CSS variables") to define its base styles such as colors. These can be changed and overwritten right in the browser.
Because of this, you can simply add your own stylesheet to the page and set your own CSS variables there. As long as your stylesheet comes after Water.css in the HTML, your values will override the default ones and your theme is applied!
This short example will use Water.css, but color all links red:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/[email protected]/out/water.min.css" />
<style>
:root {
--links: red;
}
</style>
If you want to change a value for dark or light mode only, use a media query like this:
<style>
:root {
--links: blue; /* Always applied */
}
@media (prefers-color-scheme: dark) {
:root {
--links: yellow; /* Only applied in dark mode (overrides blue) */
}
}
</style>
Compiling your own theme
If you are targeting browsers without support for CSS Custom Properties such as Internet Explorer, runtime theming is not an option. To apply your own theming, you'll need to make your changes in the source files themselves, then re-compile the CSS files. This works like the following:
- Clone the repository to your machine
- Run
yarn
to install dependencies - Make the theming changes you want in
src/variables-*.css
- Run
yarn build
to compile the CSS files - Use the compiled files in the
out/
directory on your site
You also might want to check out the Contributing Guide as it contains further information about the build setup.
Contributing
Water.css becomes better for everyone when people like you help make it better!
Check out our Contributing Guide to learn how to get started.
And thanks for taking the time to contribute! :)
Water.css 2.0
๐๐๐ This PR proposes merging Water.css 2.0.0 into master!
@kylejrp you said there were some comments you wanted to make, what are they?
Also, this introduces a lot of changes - how can we best summarize them for the changeset?
This closes #187.
Next Steps
EDIT: Here's the current checklist:
As far as I can see, here's the current state of Water.css 2.0:
I'd love feedback on what we should do about these things but here's what I've been thinking:
I think we should stop including the
dist
folder within the repository and instead rely on a continuous integration platform, potentially github actions, to build the code and deploy it to both a git tag and npm. This will make contributing easier and ensure that existing sites get updates.I'm not entirely sure about this, but we might want to consider completely remaking the documentation site and build pipeline with something slightly less janky. We could also consider deploying the site to a different service, maybe vercel? This will give the added benefit of being able to gracefully switch over to the new documentation.
Furthermore, a lot of the issues are simply caused by multiple pull requests that have overlap and merge conflicts - I propose instead we create one monster pr that when merged will update everything.
Sorry for the huge block of text, please tell me if I was unclear in any way!
cc @kylejrp @kimulaco @jonaskuske @JackFly26
::selection
By darkening the background color by 40% we can get a nice background color for selections.
I propose adding something like this:
[WIP] New File Structure + Version Picker
This PR changes the file structure to
water.css
,dark.css
, andlight.css
. It also introduces a full rewrite of the version picker on the documentation site.Todo:
Are there any other changes in scope of this pull request?
prefers-color-scheme
https://developer.apple.com/documentation/safari_release_notes/safari_12_1_release_notes
Be good if you can support Safari media queries so that if a user wants a dark scheme, they would get one. And if a user doesn't, they would get a light theme instead?
::selection makes --text-muted barely visible
Both the
::selection
color and--text-muted
are a sort-of similar shade of gray, so selecting text that's muted, e.g. a<footer>
/<cite>
means the text becomes very hard to read.Accessibility Compliance
We should pick a specific level of accessibility and make sure all of our components meet that level of accessibility.
Steps:
I can take care of the build tools, but I think I'm looking for @kognise and the community's opinion on what level of accessibility we should be complying with.
heading semantics
Styling for
<h1>
headings is currently broken, as all<h1>
headings are forced to have the same font size.HTML allows you to have multiple
<h1>
elements on a pageยน, with one being the main site title and the others being nested e.g. inside<article>
elements and acting as the main title for the respective article.Browsers respect this and display nested
<h1>
elements smaller than the main one, butwater.css
breaks this because it forces all<h1>
elements to have the samefont-size
.ยน The Document Outline as intended by HTML5 โ but while browsers visually adhere to it by scaling down
<h1>
elements, they don't implement the Outline algorithm on a semantic level, unfortunately.Gulp build tools
I replaced the previous development server with a souped-up gulp build pipeline. Now you're playing with power! ๐
Gulp
Gulp replaces the previous compiling of the sass files and also handles the development tools. Gulp has lots of other extensions for things like html templating and minification that the demo page could take advantage of in the future.
Sourcemaps
Devtools will now show you the original sass file the rule came from instead of just the full .css file:
It will even show you the original Sass file in devtools:
Note: this makes the dark.css/light.css look really big in devtools, but that's because it's also downloading the sourcemap file. The actual .css file is still small when using in production.
Autoprefixing
You can forget about browser prefixes now - autoprefixer will handle them! I've put a recommended set of supported browsers in the package.json. You can see the coverage here. Feel free to modify! https://browserl.ist/?q=last+1+version%2C+not+dead%2C+%3E+0.2%25
CSS Minification
postcss/cssnano are handling css minification. I'm using their "safe" defaults, but they could be tuned even further to provide some even better minification.
Browser Sync
This does the live reloading / development environment that you had previously set up with
dev.js
. However, there's no more server code for you to maintain! This should automatically stream changes to your browser when you have it open. It automatically launches and watchesindex.html
and the sass files when runningyarn dev
.Publish to npm
It might be nice to have water.css published to npm with every release. Then, users can install it using
npm install water.css
and include it in their projects without referencing a CDN.This would mean we would have to update the
package.json
version semantically with every release as well.[Blockquotes] Added background and new file for blockquote
Objetives:
Hello, id like to help (for beginner friendly issues)
Hello, I go by Hyun.
I am eagerly learning how to code, mainly following The Odin Project curriculum, I feel pretty good in my HTML and CSS foundations (just started learning JS).
I want to get my feet wet and help with some early contributions. Is there anything in the HTML and CSS area I can help with? Thanks
refactor the form section for desktop and mobile view
Improved the styling of the form section of the website both in desktop and mobile view.
Desktop View
| Before: | After: | :-------------------------:|:-------------------------: |
|
|
Mobile View
| Before: | After: | :-------------------------:|:-------------------------: |
|
|
feat(radio): change focus ring to match round input
Description
This uses a drop-shadow filter and clip path to create a round focus indicator on radio inputs. Issue #278
Method
How and where has this been tested?
Screenshots
Browser Compatibility
Although this is compatible with Safari, it is worth noting that an existing issue with the display of radio inputs in Safari results in cropping of the input. This was a pre-existing issue due to the width, height, and font size on the input. I recommend that this be resolved in a separate issue.
Safari screenshot:
Please let me know if any changes are needed and I would be glad to take care of it.