Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@teste-ui/system

teste-ui9MIT2.2.2TypeScript support: included

Chakra UI system primitives

system, styled-component, emotion, ui-component, ui, chakra, style-props, design-system

readme

@teste-ui/system

Styled API for creating atomic, theme-aware component styling.

Installation

yarn add @teste-ui/system

# or

npm i @teste-ui/system

Problem

In modern web development, we have lots of solutions and architectures that have tried to unify how components are styled. We've seen CSS architectures like BEM, SMACSS, etc, and frameworks like theme-ui, and Tailwind CSS.

While these solutions work great, we still think there is a sheer amount of work required to create a fully customizable, theme-aware component.

Solutions

Chakra Elements

Chakra provides enhanced JSX elements that can be styled directly via props, or can accept the common sx prop for custom styles.

We'll provide a chakra function, just like styled-components. Users can create any component using the chakra.[element]. The resulting component will be a styled component and have all system props.

<chakra.button bg="green.200" _hover={{ bg: "green.300" }}>
  Click me
</chakra.button>

<chakra.h1 fontSize="lg"> Heading </chakra.h1>

// create your own box
const Box = chakra.div

// you can still use the `as` prop
<Box as="h1">This is my box</Box>

// for custom components
const ChakraPowered = chakra(YourComponent)

// TS: chakra will infer the types of Link and
// make it available in props
<chakra.a as={Link} to="/home"> Click me</chakra.a>

Chakra Component API

A way to define themeable components in chakra. We believe most re-usable, atomic components have the following modifiers:

  • Size: It has different size variations (small, medium, large)
  • Variant: It has different visual style (outline, solid, ghost)
  • Color scheme (Optional): For a given variant, it can have several color scheme. For example, an outline button with a red color scheme.
  • Color mode (Optional): Components also change their visual styles based on the user preferred color mode (light or dark)

Our goal with this component API is to design a common interface to style any component given these characteristics. Here's how it works:

// 1. create a component schema in your theme
const theme = {
  colors: {
    green: {
      light: "#dfdfdf",
      normal: "#dfdfdf",
      dark: "#d566Df",
      darker: "#dfd56f"
    },
    blue: {}
  },
  components: {
    Button: {
      defaultProps: {
        variant: "solid",
        size: "md",
    colorScheme: "blue"
      },
      variants: {
    // props has colorScheme, colorMode (light mode or dark mode)
        solid: props => ({
          bg: `${props.colorScheme}.normal`,
          color: "white",
        }),
        outline: {
          border: "2px",
          borderColor: "green.normal"
        }
      },
      sizes: {
        sm: {
          padding: 20,
          fontSize: 12
        },
        md: {
          padding: 40,
          fontSize: 15
        }
      }
    }
  }
};

// 2. create or import Button from teste-ui
import { Button } from "@teste-ui/react"

// or your own button
const Button = chakra("button", { themeKey: "Button" })

// 3. use the button. It'll have the visual props defined in defaultProps
<Button>Click me</Button>

// 4. override the defaultProps
<Button variant="outline" colorScheme="green">Click me</Button>

changelog

Change Log

2.2.2

Patch Changes

2.2.1

Patch Changes

2.2.0

Minor Changes

Patch Changes

2.1.3

Patch Changes

2.1.2

Patch Changes

2.1.1

Patch Changes

2.1.0

Minor Changes

  • #6050 ddea8d143 Thanks @segunadebayo! - Add support for responsive variants and sizes.

    `jsx live=false <Button variant={["sm", "lg"]}>Click me</Button>

    
    Add support for `!important` in token values as an escape hatch for overriding
    properties in responsive variants/sizes.
    
    ```jsx live=false
    <Button variant={["sm", "lg"]} fontSize="lg !important">
      Click me
    </Button>

    Notes

    • Based on how this is designed, there's no support for responsive colorScheme since it is technically not a variant
    • When using responsive sizes and variants, overriding properties via props might not work as expected. We use native CSS media queries to enable this feature so there's no "magic" under the hood. If you really want to override properties, you can consider using the important syntax

Patch Changes

2.0.2

Patch Changes

2.0.1

Patch Changes

2.0.0

Major Changes

Patch Changes

2.0.0-next.4

Major Changes

Patch Changes

2.0.0-next.3

Patch Changes

2.0.0-next.2

Patch Changes

2.0.0-next.1

Major Changes

Patch Changes

2.0.0-next.0

Major Changes

Patch Changes

1.12.1

Patch Changes

1.12.0

Minor Changes

  • #5532 cedec803f Thanks @TimKolberger! - Added [data-theme] to the CSS variables root selector. This allows the semantic tokens to change according to data-theme="dark" and data-theme="light" DOM element attributes.

Patch Changes

1.11.2

Patch Changes

1.11.1

Patch Changes

1.11.0

Minor Changes

  • #5508 e5e0f255c Thanks @TimKolberger! - Allow all JSX.IntrinsicElements for the chakra factory. This allows to use every DOM element with the shorthand version:

    jsx live=false <chakra.header>Header</chakra.header> <chakra.main>Main</chakra.main> <chakra.footer>Many more</chakra.footer>

Patch Changes

1.10.3

Patch Changes

1.10.2

Patch Changes

1.10.1

Patch Changes

1.10.0

Minor Changes

Patch Changes

1.9.1

Patch Changes

1.9.0

Minor Changes

  • #5243 ae6fd7a25 Thanks @TimKolberger! - Use the feature flag --strict-component-types for @teste-ui/cli tokens to generate strict component type for the theming props variant and size.

    teste-cli tokens --strict-component-types

    `tsx live=false // before

    <Button variant="abc" /> // valid type but variant is not available in the theme

    // after <Button variant="abc" /> // invalid // Type '"abc"' is not assignable to type '"link" | "outline" | "ghost" | "solid" | "unstyled" | undefined'. `

Patch Changes

1.8.3

Patch Changes

1.8.2

Patch Changes

1.8.1

Patch Changes

1.8.0

Minor Changes

  • #4991 6095eaf9a Thanks @segunadebayo! - Update build system we use from a custom babel cli setup to preconstruct.

    The previous build system transpiles the code in src directory to dist/esm and dist/cjs keeping the same file structure. The new build system merges all files in src and transpiles to a single esm and cjs file.

    Potential Breaking Change: The side effect of this is that, if you imported any function, component or hook using the undocumented approach like import { useOutsideClick } from "@teste-ui/hooks/dist/use-outside-click", you'll notice that the this doesn't work anymore.

    Here's how to resolve it:

    `jsx live=false // Won't work 🎇 import { useOutsideClick } from "@teste-ui/hooks/dist/use-outside-click"

    // Works ✅ import { useOutsideClick } from "@teste-ui/hooks" `

    If this affected your project, we recommend that you import hooks, functions or components the way it's shown in the documentation. This will help keep your project future-proof.

Patch Changes

1.7.6

Patch Changes

1.7.5

Patch Changes

1.7.4

Patch Changes

1.7.3

Patch Changes

1.7.2

Patch Changes

1.7.1

Patch Changes

1.7.0

Minor Changes

  • 991ea2e29 #3998 Thanks @terrierscript! - The styled function allows a functional baseStyle property:

    import { styled } from '@teste-ui/react'
    
    const MyComponent = styled('div', {
      baseStyle: (props) => ({
        bg: props.highlightColor
      })
    })
    
    // ...
    
    <MyComponent highlightColor="red.500" />

Patch Changes

1.6.7

Patch Changes

1.6.6

Patch Changes

1.6.5

Patch Changes

1.6.4

Patch Changes

1.6.3

Patch Changes

1.6.2

Patch Changes

1.6.1

Patch Changes

1.6.0

Minor Changes

Patch Changes

1.5.1

Patch Changes

1.5.0

Minor Changes

Patch Changes

1.4.0

Minor Changes

Patch Changes

1.3.1

Patch Changes

1.3.0

Minor Changes

Patch Changes

1.2.1

Patch Changes

1.2.0

Minor Changes

  • 90c7a4fbf #3092 Thanks @TimKolberger! - - Improved theme typing in order to provide a better autocomplete experience
    • Fixed a type issue where pseudo style props like _hover and _active didn't allow regular css properties

Patch Changes

1.1.7

Patch Changes

1.1.6

Patch Changes

1.1.5

Patch Changes

1.1.4

Patch Changes

1.1.3

Patch Changes

1.1.2

Patch Changes

1.1.1

Patch Changes

1.1.0

Minor Changes

  • 730a2da1 Thanks @segunadebayo! - ## Pin Input

    🐛 Bug Fix

    • Fix issue where copy-paste doesn't work for pin-input

    Number Input

    🐛 Bug Fix

    • Fix issue where number input doesn't work when using with form libraries that use ref as entry point to setting initial values (e.g React hook form).

      We improved useNumberInput to sync the initial values in the ref passed to NumberInputField with the internal state.

    System

    🚀 Feature

    Add support for custom shouldForwardProp function in the chakra factory function.

Patch Changes

1.0.2

Patch Changes

1.0.1

Patch Changes

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

1.0.0 (2020-11-13)

Note: Version bump only for package @teste-ui/system

Change Log

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

1.0.0-rc.8 (2020-10-29)

Bug Fixes

  • toast: allow custom render in update (eb8bff9), closes #2362

Change Log

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

1.0.0-rc.7 (2020-10-25)

Note: Version bump only for package @teste-ui/system

1.0.0-rc.6 (2020-10-25)

Note: Version bump only for package @teste-ui/system

1.0.0-rc.5 (2020-09-27)

Note: Version bump only for package @teste-ui/system

1.0.0-rc.4 (2020-09-25)

Note: Version bump only for package @teste-ui/system

1.0.0-rc.3 (2020-08-30)

Note: Version bump only for package @teste-ui/system

Change Log

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

1.0.0-rc.2 (2020-08-09)

Note: Version bump only for package @teste-ui/system

Change Log

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

1.0.0-rc.1 (2020-08-06)

Bug Fixes

  • variables: drop unused imports (552b2e9)
  • connect drawer its correct theming (9ed9d3a)

Features

  • system: extend props (645c683)
  • added cookieStorageManager. still WIP (9a9c305)
  • cleaned up some storageManager code. set color mode cookie to expire after a year (d7ca15e)

Change Log

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

1.0.0-rc.0 (2020-07-26)

Note: Version bump only for package @teste-ui/system

Change Log

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

1.0.0-next.7 (2020-07-26)

Bug Fixes

  • give priority to props overrides (f2fe955)
  • null exception for style config (c28ba5a)

Features

  • add support for single and multipart config (a13d0f8)

Reverts

Change Log

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

1.0.0-next.6 (2020-07-15)

Note: Version bump only for package @teste-ui/system

Change Log

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

1.0.0-next.5 (2020-07-15)

Performance Improvements

Change Log

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

1.0.0-next.4 (2020-07-01)

Bug Fixes

Features

  • add support for inline-variant (67bf6ad)
  • add support for line-clamp (1173ca6)

Change Log

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

1.0.0-next.3 (2020-06-28)

Bug Fixes

Features

  • add support for inline-variant (67bf6ad)
  • add support for line-clamp (1173ca6)

Change Log

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

1.0.0-next.2 (2020-06-21)

Bug Fixes

Features

  • add support for inline-variant (67bf6ad)
  • add support for line-clamp (1173ca6)