Détail du package

tastycss

OutpostHQ52MIT0.17.2

CSS-in-JS solution modules that include state-to-style bindings, SSR, and next-level developer experience.

component, components, create, css

readme

TastyCSS

CSS-in-JS solution modules that include state-to-style bindings, SSR, and next-level developer experience.

NPM Version Discord

Installation

# with npm
npm install tastycss

# with yarn
yarn add tastycss

# with pnpm
pnpm add tastycss

Usage of Tasty API

Let's look at styled API:

```typescript jsx import { tasty } from 'tastycss';

const Element = tasty({ / The tag name of the element. */ as: 'span', / Default styles of the element. / styles: { // tokens '@local-padding': ['2x', '1x'], // responsive styles '@text-color': 'rgba(255, 0, 0)', // styles padding: '@local-padding', color: { // the default color '': '#text', // the color if blue mod is specified blue: 'blue', }, // use color token }, /** Default attributes (example) / role: 'article', /* The list of styles that can be provided by props / styleProps: ['align'], });


Now you can use this element inside your React App:

```typescript jsx
export default function Component({ title, children }) {
  return (
    <>
      <Heading>{title}</Heading>
      <Element>{children}</Element>
    </>
  );
}

Extend base options

You can use tasty() function to extend styling of the existing component.

```typescript jsx const CustomElement = tasty(Element, { / Change tag name */ as: 'input', / Extend or rewrite styles / styles: { color: '#purple', }, /** Add more default properties/attributes / role: 'article', });


#### Define global styles

Use `tasty()` to define global styles for elements:

```typescript jsx
import { tasty } from 'tastycss';

const GlobalStyledHeading = tasty('.myButton', {
  display: 'inline-block',
  padding: '1x 2x',
  preset: 't2',
  border: true,
  radius: true,
});

Style variants

You can reduce the amount of CSS for your component by splitting it into variants.

```typescript jsx import { tasty } from 'tastycss';

const StyledButton = tasty(Button, { styles: { / default styles / }, variants: { // define themes using variants default: { // default (fallback) variant // define new styles for default variant or override default styles. }, danger: { // define new styles for danger variant or override default styles. }, }, });


Usage example:

```typescript jsx
<StyledButton variant="danger">Danger Button</StyledButton>

If the variant prop is not provided then the default variant will be used.

IMPORTANT: It's preferred that the component will not receive any change in variant prop to avoid style replacement. But this case is supported.

Documentation is work in progress.

Contributing

Please follow our contributing guidelines.

License

TastyCSS is a project by Outpost.

Released under the MIT License.

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

0.8.9 (2022-10-07)

Note: Version bump only for package tasty

0.8.8 (2022-10-02)

Bug Fixes

  • optimize bundle size and turbo script (f82574f)

0.8.7 (2022-09-18)

Note: Version bump only for package tasty

0.8.6 (2022-09-01)

Note: Version bump only for package tasty

0.8.4 (2022-08-31)

Note: Version bump only for package tasty

0.8.3 (2022-08-31)

Note: Version bump only for package tasty

0.8.2 (2022-08-29)

Note: Version bump only for package tasty

0.8.1 (2022-08-27)

Note: Version bump only for package tasty

0.7.9 (2022-08-07)

Note: Version bump only for package tasty

0.7.8 (2022-08-07)

Note: Version bump only for package tasty

0.7.7 (2022-07-30)

Note: Version bump only for package tasty

0.7.6 (2022-07-30)

Bug Fixes

  • (preset-style) font-family fallback and notf. (fb65272)

0.7.5 (2022-06-27)

Note: Version bump only for package tasty

0.7.4 (2022-06-24)

Note: Version bump only for package tasty

0.7.3 (2022-06-24)

Note: Version bump only for package tasty

0.7.2 (2022-06-04)

Note: Version bump only for package tasty

0.7.1 (2022-05-30)

Note: Version bump only for package tasty

0.6.5 (2022-03-30)

Note: Version bump only for package tasty

0.6.4 (2022-03-24)

Bug Fixes

  • transition style for some widgets (b4bfb25)

0.6.3 (2022-03-18)

Note: Version bump only for package tasty

0.6.2 (2022-02-22)

Note: Version bump only for package tasty

0.6.1 (2022-02-10)

Note: Version bump only for package tasty

0.5.7 (2022-02-10)

Note: Version bump only for package tasty

0.5.6 (2022-02-09)

Note: Version bump only for package tasty

0.5.5 (2022-01-30)

Note: Version bump only for package tasty

0.5.4 (2022-01-20)

Note: Version bump only for package tasty

0.5.3 (2022-01-20)

Note: Version bump only for package tasty

0.5.2 (2022-01-11)

Bug Fixes

0.5.1 (2022-01-11)

Note: Version bump only for package tasty

0.5.0 (2022-01-11)

Features

  • add suffix support for selectors (b3ebd75)

0.4.4 (2021-10-15)

Note: Version bump only for package tasty

0.4.3 (2021-10-15)

Note: Version bump only for package tasty

0.4.2 (2021-10-15)

Note: Version bump only for package tasty