UI-React is a React component library for building powerful applications at scale, easily

UI-React is a React component library for building powerful applications at scale, easily

UI-React promotes strong separation between the theming and layout in your applications. This practice allows efficient, beautiful, consistent UIs to be built quickly by teams of all sizes.

UI-React

UI-React is a React component library for building powerful applications at scale.

(Yes, we need a better name. If you have a suggestion, post here: https://github.com/kibalabs/ui-react/issues/12.)

UI-React promotes strong separation between the theming and layout in your applications. This practice allows efficient, beautiful, consistent UIs to be built quickly by teams of all sizes.

Documentation

Read all our principles and see live examples of all components in the storybook documentation.

Here's a good example, our Button component.

Using UI-React

Installing

To install UI-React you can simply run:

npm install @kibalabs/ui-react styled-components

UI-React is built on styled-components and styled-components should be installed as a peer dependency which is why you need to install it yourself with the above command.

Setup

The easiest way to setup your code to be ready to use UI-React components is to use the KibaApp component. It should be used at the topmost level and needs to be passed a theme object like so:

import React from 'react';
import { KibaApp, buildTheme } from '@kibalabs/ui-react';

const theme = buildTheme();

export const App = (): React.ReactElement => {
  ...
  return (
    <KibaApp theme={theme}>
      ...
    </KibaApp>
  );
};

If you don't want to use the KibaApp component (because, for example, it adds CSS to make everything look plain by default), you can instantiate the ThemeProvider yourself like this:

import React from 'react';
import { ThemeProvider, buildTheme, GlobalCSS } from '@kibalabs/ui-react';

const theme = buildTheme();

export const App = (): React.ReactElement => {
  ...
  return (
    <ThemeProvider theme={theme}>
      <React.Fragment>
        <GlobalCss resetCss={<your reset css>} theme={theme} />
        ...
      </React.Fragment>
    </ThemeProvider>
  );
};

This should work just as well but won't include the CSS to clear by default and you will need to provide it yourself as resetCss (it can just be an empty string).

Example code

Here's some code to show you what it's like to work with (it's taken from the everypage console).

import React from 'react';
import { IWebsite } from '@kibalabs/everypage-core'
import { Box, Text, Stack, Direction, KibaIcon, Alignment, Spacing } from '@kibalabs/ui-react'

interface IMetaItemProps {
  isChecked: boolean;
  text: string;
}

const MetaItem = (props: IMetaItemProps): React.ReactElement => {
  return (
    <Stack direction={Direction.Horizontal} contentAlignment={Alignment.Start} childAlignment={Alignment.Center} shouldAddGutters={true}>
      <KibaIcon variant='small' iconId={props.isChecked ? 'ion-checkmark-circle-outline' : 'ion-close-circle-outline'} />
      <Text variant='small'>{ props.text }</Text>
    </Stack>
  );
}

interface ISiteMetaCardProps {
  website: IWebsite;
}

export const SiteMetaCard = (props: ISiteMetaCardProps): React.ReactElement => {
  return (
    <Box variant='bordered'>
      <Stack direction={Direction.Vertical}>
        <Text variant='header5'>Metadata</Text>
        <Spacing />
        <MetaItem text='name' isChecked={!!props.website.name} />
        <MetaItem text='description' isChecked={!!props.website.description} />
        <MetaItem text='faviconImageUrl' isChecked={!!props.website.faviconImageUrl} />
        <MetaItem text='socialCardImageUrl' isChecked={!!props.website.socialCardImageUrl} />
      </Stack>
    </Box>
  );
}

The code generates this visual:

Everypage Console Metadata Card

The important thing to notice here is that this code only includes the layout of the components. All the theming is done globally and accessed via variants on each of the atomic elements provided by UI-React (e.g. Box, Text and Stack). You can read more about this in our Theming Goals documentation.

This practice makes new interfaces extremely quick to create and allows your components to be supre re-usable.

Customizing your theme

To customize the theming in your application, you should provide a parameter to the buildTheme function. This parameter can contain a subset of an entire theme object (which you can find in buildTheme.ts in this project).

Here's a simple example where just some colors are changed (see subatoms/colors/theme.ts):

const theme = buildTheme({
  colors: {
    brandPrimary: '#E56B6F',
    brandSecondary: '#6D597A',
    background: '#000000',
    text: '#ffffff',
    placeholderText: 'rgba(255, 255, 255, 0.5)',
  },
});

Here's a more complex example where a custom font is used for all text and all buttons and inputs are changed to have a box shadow when hovered or focussed:

const theme = buildTheme({
  colors: {
    brandPrimary: '#2B59C3',
    brandSecondary: '#1d3557',
  },
  fonts: {
    main: {
      url: 'https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700,800,900&display=swap',
    },
  },
  texts: {
    default: {
      'font-family': "Montserrat, apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif"
    }
  },
  buttons: {
    default: {
      normal: {
        focus: {
          background: {
            "box-shadow": "0 4px 8px 0 rgba(0,0,0,0.2)"
          }
        },
        hover: {
          background: {
          "box-shadow": "0 4px 8px 0 rgba(0,0,0,0.2)"
          }
        }
      }
    }
  },
  inputWrappers: {
    default: {
      normal: {
        focus: {
          background: {
            "box-shadow": "0 4px 8px 0 rgba(0,0,0,0.2)"
          }
        },
        hover: {
          background: {
            "box-shadow": "0 4px 8px 0 rgba(0,0,0,0.2)"
          }
        }
      }
    }
  }
});

Hopefully this starts to give you a sense of how powerful the separation of theming and layout can be.

// TODO(krishan711): we need way more documentation on this!

Support

UI-React is mostly written by me (krishan711) at the moment. If you want help with contributing or even if you want help using UI-React in your own application just reach out, I'd love to help 🙌.

Built with UI-React

everypage - a website (landing page) builder which is actually just a thin, application-specific layer on top of UI-React. If you want to build a landing page just with JSON, check it out!

Appage - a small application built on top of everypage. It lets you build a landing page for your mobile app in minutes!

Download Details:

Author: kibalabs

Demo: https://ui-react-docs.kibalabs.com/

Source Code: https://github.com/kibalabs/ui-react

react reactjs javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Increase Performance of React Applications Via Array JavaScript Methods

Increase Performance of React Applications Via Array JavaScript Methods. We will create a simple event management application in the react to add, update, and delete an event.

Routing in React without React-Router

I have been using React JS in my projects for quite some time now and am used to managing routing in my app using the react-router package. I have always been keen on having as little dependencies in my apps as possible, so, I always felt perturbed by the use of this particular package in simpler apps which did not have complex routes.

The Ugly Side of React Hooks

In this post, I will share my own point of view about React Hooks, and as the title of this post implies, I am not a big fan.

ReactJS: The Javascript Developer’s Guide

This article will walk you through the concepts you would need to know to step into the world of widely used ReactJS.