2.14.5 • Published 6 months ago

@onbeam/styled-system v2.14.5

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

@onbeam/styled-system

Table of Contents

Installation

Install the packages using your preferred package manager:

pnpm add @onbeam/styled-system@latest
pnpm add @pandacss/dev@latest --save-dev

To keep all @onbeam packages updated, you can use the CLI:

npx @onbeam/cli update -d [directory]

PandaCSS

Due to the component styles building just-in-time, you need to install and configure PandaCSS. This means that only the styles for the components you use will be generated, nothing more. When you decide to utilize PandaCSS in your own project, you will be able to use all design tokens and PandaCSS will combine the UI styles with your project styles before compiling the output.

Config

Create a panda.config.ts file in the root of your application and paste this snippet in there:

import { defineBeamUiConfig } from "@onbeam/styled-system/config";

export default defineBeamUiConfig({
  include: [
    "./node_modules/@onbeam/ui/dist/panda.buildinfo.json", // Only add this when you're using the @onbeam/ui package
    // TODO: Configure this line to target your own files that utilize the component library and PandaCSS
    "./src/**/*.{ts,tsx}",
  ],
});

PostCSS

Run npx panda init --postcss. This will create a postcss.config.cjs file in the root of your application with the following code:

module.exports = {
  plugins: {
    "@pandacss/dev/postcss": {},
  },
};

CSS

To enable the styles, create a global CSS file, for example named "globals.css" and paste the following snippet in there:

/* When adding libraries that could overwrite our styles, make sure to use css layers: */
/* https://panda-css.com/docs/overview/faq#how-can-i-prevent-other-libraries-from-overriding-my-styles */
@layer reset, base, tokens, recipes, utilities;

body {
  font-family: var(--beam-fonts-main);
  color: var(--beam-colors-mono-100);
}

/* TODO: These are all fonts used in the @onbeam/ui components, only add them if you are using @onbeam/ui. Add all your used fonts here */
@font-face {
  font-family: "Suisse Intl";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("../node_modules/@onbeam/ui/dist/fonts/SuisseIntl-Regular.otf");
}

@font-face {
  font-family: "Suisse Intl";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("../node_modules/@onbeam/ui/dist/fonts/SuisseIntl-Book.otf");
}

/* TODO: Remove this if you're not using the `ObjectTree` component */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("../node_modules/@onbeam/ui/dist/fonts/JetBrainsMono-Regular.ttf");
}

In the root of your project code, for example layout.tsx or _app.tsx, import your created css file:

import "./globals.css";

Scripts

To build the PandaCSS code, add the panda codegen command to your package.json's build script. For example:

"scripts": {
  "build": "panda codegen && next build",
},

Examples

Example 1: Basic usage of css and cx

import { cx, css } from "@onbeam/styled-system/css";

const Component = ({ className }) => (
  <div
    className={cx(
      css({ w: "full", mx: "4", background: "mono.1000" }),
      className
    )}
  >
    ...
  </div>
);

Example 2: Basic usage of a pattern

import { flex } from "@onbeam/styled-system/patterns";

const Component = ({ className }) => (
  <div className={flex({ align: "center" })}>...</div>
);

Example 3: Getting token values

import { token } from "@onbeam/styled-system/tokens";

const Component = ({ className }) => (
  <SomeIcon fill={token("colors.mono.300")} />
);

All @onbeam packages


That's it! Happy coding! 🌈

2.11.1

8 months ago

2.8.1

9 months ago

2.8.0

9 months ago

2.5.5

1 year ago

2.11.2

8 months ago

2.10.1

8 months ago

2.10.2

8 months ago

2.10.0

8 months ago

2.7.0

11 months ago

2.7.2

11 months ago

2.7.1

11 months ago

2.14.5

6 months ago

2.8.3

9 months ago

2.8.2

9 months ago

2.14.3

7 months ago

2.8.5

9 months ago

2.14.4

6 months ago

2.8.4

9 months ago

2.14.1

7 months ago

2.8.7

8 months ago

2.14.2

7 months ago

2.8.6

9 months ago

2.8.9

8 months ago

2.14.0

7 months ago

2.8.8

8 months ago

2.6.1

1 year ago

2.6.0

1 year ago

2.6.3

1 year ago

2.6.2

1 year ago

2.7.4

10 months ago

2.7.3

10 months ago

2.7.6

10 months ago

2.7.5

10 months ago

2.13.0

7 months ago

2.13.1

7 months ago

2.12.0

8 months ago

2.5.2

1 year ago

2.9.0

8 months ago

2.5.4

1 year ago

2.5.3

1 year ago

2.6.5

12 months ago

2.6.4

1 year ago

2.6.6

11 months ago

2.12.1

8 months ago

2.12.2

7 months ago

2.5.0

1 year ago

2.5.1

1 year ago

2.4.2

1 year ago

2.4.1

1 year ago

2.4.0

1 year ago

2.3.0

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.2.3

1 year ago

2.2.2

1 year ago

2.2.4

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.5

1 year ago

2.1.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

2 years ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-28

2 years ago

1.0.0-24

2 years ago

1.0.0-25

2 years ago

1.0.0-26

2 years ago

1.0.0-27

2 years ago

1.0.0-23

2 years ago

1.0.0-22

2 years ago

1.0.0-19

2 years ago

1.0.0-20

2 years ago

1.0.0-21

2 years ago

1.0.0-16

2 years ago

1.0.0-17

2 years ago

1.0.0-18

2 years ago

1.0.0-11

2 years ago

1.0.0-12

2 years ago

1.0.0-13

2 years ago

1.0.0-14

2 years ago

1.0.0-15

2 years ago

1.0.0-10

2 years ago

1.0.0-9

2 years ago

1.0.0-8

2 years ago

1.0.0-7

2 years ago

1.0.0-6

2 years ago

1.0.0-5

2 years ago

1.0.0-4

2 years ago

1.0.0-3

2 years ago

1.0.0-2

2 years ago

1.0.0-1

2 years ago