Salty CSS
⚠️ Website is still under development
In the world of frontend dev is there anything saltier than CSS? Salty CSS is built to provide better developer experience for developers looking for performant and feature rich CSS-in-JS solutions.
npx salty-css init [directory]
npx salty-css generate [filePath]
npx salty-css build [directory]
Note: Fastest way to get started with any framework is npx salty-css init [directory] command
npm install @salty-css/next
+ Next.js install guide + Next.js example appnpm install @salty-css/react
+ React install guide + React example codenpm install @salty-css/vite
+ (Vite install guide)npm install @salty-css/webpack
+ Guide coming soonnpm install @salty-css/eslint-plugin-core
+ Guide coming soonnpm install @salty-css/core
(This package contains code for internal use)salty-css
CLIIn your existing repository run npx salty-css init [directory]
which installs required salty-css packages to the current directory, detects framework in use (current support for vite and next.js) and creates project files to the provided directory. Directory can be left blank if you want files to be created to the current directory. Init will also create .saltyrc
which contains some metadata for future CLI commands.
Components can be created with npx salty-css generate [filePath]
which then creates a new Salty CSS component file to the specified path. Additional options like --dir, --tag, --name and --className
are also supported. Read more about them with npx salty-css generate --help
If you want to manually build your project that can be done by running npx salty-css build [directory]
. Directory is not required as CLI can use default directory defined in .saltyrc
. Note that build generates css files but Vite / Webpack plugin is still required for full support.
To ease the pain of package updates all Salty CSS packages can be updated with npx salty-css update
npm i @salty-css/next @salty-css/core @salty-css/react
salty.config.ts
to your app directorynext.config.ts
add import for salty plugin import { withSaltyCss } from '@salty-css/next';
and then add withSaltyCss
to wrap your nextConfig export like so export default withSaltyCss(nextConfig);
next.config.js
add import for salty plugin const { withSaltyCss } = require('@salty-css/next');
and then add withSaltyCss
to wrap your nextConfig export like so module.exports = withSaltyCss(nextConfig);
salty.config.ts
and next.config.ts
are in the same folder!saltygen
directory by running your app once or with cli npx salty-css build [directory]
saltygen/index.css
to some global css file with @import 'insert_path_to_index_css';
.Check out Next.js demo project or react example code
npm i @salty-css/core @salty-css/react
salty.config.ts
to your app directorynpm i @salty-css/vite @salty-css/core
vite.config
add import for salty plugin import { saltyPlugin } from '@salty-css/vite';
and then add saltyPlugin(__dirname)
to your vite configuration pluginssalty.config.ts
and vite.config.ts
are in the same folder!saltygen
directory by running your app once or with cli npx salty-css build [directory]
saltygen/index.css
to some global css file with @import 'insert_path_to_index_css';
..css.ts
, .salty.ts
.styled.ts
or .styles.ts
Salty config
import { defineConfig } from "@salty-css/core/config";
export const config = defineConfig({
variables: {
colors: {
brand: "#111",
highlight: "yellow",
},
},
global: {
html: {
backgroundColor: "#f8f8f8",
},
},
});
Your React component file
import { Wrapper } from "../components/wrapper/wrapper.css";
import { Button } from "../components/button/button.css";
export const IndexPage = () => {
return (
<Wrapper>
<Button variant="solid" onClick={() => alert("It is a button.")}>
Outlined
</Button>
</Wrapper>
);
};
Wrapper (components/wrapper/wrapper.css.ts
)
import { styled } from "@salty-css/react/styled";
export const Wrapper = styled("div", {
base: {
display: "block",
padding: "2vw",
},
});
Button (components/button/button.css.ts
)
import { styled } from "@salty-css/react/styled";
export const Button = styled("button", {
base: {
display: "block",
padding: `0.6em 1.2em`,
border: "1px solid currentColor",
background: "transparent",
color: "currentColor/40",
cursor: "pointer",
transition: "200ms",
textDecoration: "none",
"&:hover": {
background: "black",
borderColor: "black",
color: "white",
},
"&:disabled": {
opacity: 0.25,
pointerEvents: "none",
},
},
variants: {
variant: {
outlined: {
// same as default styles
},
solid: {
"&:not(:hover)": {
background: "black",
borderColor: "black",
color: "white",
},
"&:hover": {
background: "transparent",
borderColor: "currentColor",
color: "currentColor",
},
},
},
},
});
More examples coming soon