npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@onbeam/styled-system

v2.6.5

Published

## Table of Contents

Downloads

2,016

Readme

@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! 🌈