All Projects → 47ng → chakra-next

47ng / chakra-next

Licence: MIT license
Opinionated design system for React, based on Chakra UI + Next.js, written in TypeScript.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to chakra-next

personal-website
My personal website, statically generated by Next.js
Stars: ✭ 16 (-91.16%)
Mutual labels:  chakra-ui
paw
🐾 Source code for floofy.dev and Noel's portfolio, a professional side of myself. This is probably the site you want to see if you're trying to hire me or looking to hire.
Stars: ✭ 16 (-91.16%)
Mutual labels:  chakra-ui
vitamin-android
Decathlon Design System UI components for Android applications
Stars: ✭ 34 (-81.22%)
Mutual labels:  design-system
carbon-components-svelte
Svelte implementation of the Carbon Design System
Stars: ✭ 1,615 (+792.27%)
Mutual labels:  design-system
anv-ui-components
AnyVision React components library
Stars: ✭ 35 (-80.66%)
Mutual labels:  design-system
gatsby-starter-specimens
Leverage the wide variety of powerful React components to build your design system. Display colors, typography or any other design tokens with ease. Works seamlessly with MDX.
Stars: ✭ 35 (-80.66%)
Mutual labels:  design-system
react-native-sketchbook
design system for react-native
Stars: ✭ 57 (-68.51%)
Mutual labels:  design-system
solar-components
Web Components Implementation of Solar Design System
Stars: ✭ 16 (-91.16%)
Mutual labels:  design-system
myPortfolio
This is a portfolio application built by using Next.js, ChakraUi, Typescript and Dev.to api.
Stars: ✭ 127 (-29.83%)
Mutual labels:  chakra-ui
rex-design
A responsive and adaptive components library, with ability to config theme and color mode.
Stars: ✭ 107 (-40.88%)
Mutual labels:  design-system
ui-ux
The learning guide contains the Basics, Intermediate and Advance resources for User Interface and User Experience Design
Stars: ✭ 187 (+3.31%)
Mutual labels:  design-system
nextjs-todo-app
https://nextjs-todoapp.vercel.app
Stars: ✭ 18 (-90.06%)
Mutual labels:  chakra-ui
School-Simplified
School Simplified is a digital nonprofit whose mission is to spread educational equality by providing free academic services, products, and opportunities for teenagers.
Stars: ✭ 17 (-90.61%)
Mutual labels:  chakra-ui
rescript-pulo
⚡️ [Pulo.dev] with ReScript, React, Recoil, and Chakra
Stars: ✭ 12 (-93.37%)
Mutual labels:  chakra-ui
wonder-blocks
React components for Wonder Blocks design system.
Stars: ✭ 110 (-39.23%)
Mutual labels:  design-system
tds-community
TELUS Design System Community Components
Stars: ✭ 22 (-87.85%)
Mutual labels:  design-system
pebble
Pebble Design System
Stars: ✭ 14 (-92.27%)
Mutual labels:  design-system
design-system
The Equinor design system
Stars: ✭ 49 (-72.93%)
Mutual labels:  design-system
vf-core
A (primarily CSS) framework that targets needs of life science websites and services
Stars: ✭ 16 (-91.16%)
Mutual labels:  design-system
open design system
Open Source Design System using Sketch. It's early days of my project.
Stars: ✭ 22 (-87.85%)
Mutual labels:  design-system

@47ng/chakra-next

NPM MIT License Continuous Integration Coverage Status

Opinionated design system for React, based on Chakra UI + Next.js.

Features

  • Default theme with semantic tokens
  • 100% TypeScript, transpiled to ESM (requires Next.js 12+)
  • Components:

Installation

In your Next.js app:

$ npm install @47ng/chakra-next

Theme tools

To resolve theme tokens across color modes, use useColorModeToken:

import { useColorModeToken } from '@47ng/chakra-next'

const fill = useColorModeToken('red.500', 'blue.500')
const shadow = useColorModeToken('md', 'dark-lg', 'shadows')

The following semantic tokens are provided:

  • colors:
    • body (follows the html/body/__next background color)
    • text.dim
    • text.dimmer
    • text.dimmest
    • card.bg
  • shadows:
    • card.shadow (make card shadow darker in dark mode to stand out)

Components

Links

import { RouteLink, OutgoingLink, ButtonRouteLink } from '@47ng/chakra-next'

export default () => (
  <>
    {/* Integrate Next.js routes with Chakra styles */}
    <RouteLink to="/login">Login</RouteLink>

    {/* Use `as` for dynamic routes */}
    <RouteLink to="/posts/[slug]" as="/posts/foo">Login</RouteLink>

    {/* Make external links stand out */}
    <OutgoingLink href="https://github.com" showExternalIcon>
      GitHub
    </RouteLink>

    {/* For when a button looks better, still outputs an <a> tag */}
    <ButtonRouteLink to="/logout">Logout</ButtonRouteLink>
  </>
)

NavLinks

Use NavLink when you want a link to have special styling depending on the current page.

By default, NavLinks:

  • Underline their text when active
  • Are active when the current path starts with the link path

Example:

import { NavLink } from '@47ng/chakra-next'

export default () => (
  <>
    <NavLink to="/blog">Blog</NavLink>
  </>
)

The link will be active for the following paths:

Path Active
/home false
/blog true
/blog/ true
/blog/foo true
Custom active styles
import { NavLink } from '@47ng/chakra-next'

export default () => (
  <>
    <NavLink
      to="/blog"
      borderBottomWidth="3px"
      borderBottomColor="transparent"
      active={{ color: 'blue.500', borderBottomColor: 'blue.500' }}
    >
      Blog
    </NavLink>
  </>
)
Exact paths

Sometimes, you want the NavLink to be active only on exact route matches:

import { NavLink, navLinkMatch } from '@47ng/chakra-next'

export default () => (
  <>
    <NavLink to="/home" shouldBeActive={navLinkMatch.exact}>
      Home
    </NavLink>
  </>
)

You can also have custom logic to determine whether a NavLink should be active:

import { NavLink, navLinkMatch } from '@47ng/chakra-next'

export default () => (
  <>
    <NavLink
      to="/blog/[post]"
      as="/blog/another-blog-post?active=true"
      shouldBeActive={({ to, as, router }) =>
        navLinkMatch.exact({ to, as, router }) &&
        router?.query.active === 'true'
      }
    >
      Another Blog Post
    </NavLink>
  </>
)

Redirect

Redirect will change the current URL to the one given, when mounted.

import { Redirect } from '@47ng/chakra-next'

export default ({ loggedIn }) => (
  <>{loggedIn ? <Text>Hello !</Text> : <Redirect to="/login" />}</>
)

By default, the redirection will be pushed onto the navigation history stack. You can replace the history stack instead with the replace prop:

import { Redirect } from '@47ng/chakra-next'

export default () => (
  <>
    <Redirect to="/home" replace />
  </>
)

Next.js dynamic paths are also supported:

import { Redirect } from '@47ng/chakra-next'

export default () => (
  <>
    <Redirect to="/blog/[slug]" as="/blog/foo-bar" />
  </>
)

If you want to redirect to an external link (not an internal route), you will have to set the external prop:

import { Redirect } from '@47ng/chakra-next'

export default () => (
  <>
    <Redirect to="https://example.com" external />

    {/* You can also have the history replaced with external URLs: */}
    <Redirect to="https://example.com" external replace />
  </>
)

You can also pass transition options:

<Redirect to="/home" shallow scroll={false} />

Cards

import { Card, cardProps } from '@47ng/chakra-next'

export default () => (
  <>
    {/* Card as Box */}
    <Card>I'm in a card</Card>

    {/* Apply Card styles to a custom component */}
    <MyChakraComponent {...cardProps} />
  </>
)

Svg

Extends chakra.svg with with:

  • SVG namespace pre-filled
  • role="img"
import { Svg } from '@47ng/chakra-next'

export default () => (
  <Svg
    aria-labelledby="svg-demo-title svg-demo-desc"
    viewBox="0 0 24 24"
    display="block"
    my={4}
    mx="auto"
  >
    <title id="svg-demo-title">A red circle</title>
    <desc id="svg-demo-desc">
      Svg lets you style SVG container tags with Chakra UI style props.
    </desc>
    <circle fill="red" cx="12" cy="12" r="10">
  </Svg>
)

Note: to use theme tokens for fills, strokes and other SVG properties, you must resolve them first:

import { useToken } from '@chakra-ui/react'

export default () => (
  <Svg
    aria-labelledby="svg-demo-title svg-demo-desc"
    viewBox="0 0 24 24"
    display="block"
    my={4}
    mx="auto"
    fill={useToken('colors', 'red.500')} // Resolve theme tokens with `useToken`
  >
    <title id="svg-demo-title">A red circle</title>
    <desc id="svg-demo-desc">
      Svg lets you style SVG container tags with Chakra UI style props.
    </desc>
    <circle
      // You can also use the CSS prop names directly:
      fill="var(--chakra-colors-red.500)"
      cx="12"
      cy="12"
      r="10"
    >
  </Svg>
)

NoSSR

Sometimes you want to render a component only on the client, and have a skeleton or fallback component rendered on the server, whether for SSR or static output.

import { NoSSR } from '@47ng/chakra-next'

export default () => (
  <>
    <NoSSR>This is only rendered on the client</NoSSR>

    {/* Skeleton is rendered on SSR/SSG, TheRealThing is rendered on the client.*/}
    <NoSSR fallback={<Skeleton />}>
      <TheRealThing />
    </NoSSR>
  </>
)

Examples

Header with navigation links:

import { Box, Stack } from '@chakra-ui/core'
import { NavLink } from '@47ng/chakra-next'

export default () => (
  <Box as="header">
    <Stack as="nav" isInline>
      <NavLink to="/features">Features</NavLink>
      <NavLink to="/pricing">Pricing</NavLink>
      <NavLink to="/docs">Documentation</NavLink>
    </Stack>
  </Box>
)

License

MIT - Made with ❤️ by François Best.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].