mobrix-ui
TypeScript icon, indicating that this package has built-in type declarations

3.8.1 • Public • Published

MoBrix-ui

NPM npm (scoped) Maintenance


Smart React components for every app, easily customizable for every purpose.


npm bundle size (scoped) tested with jest MoBrix-ui CI




Note for older MoBrix-ui version

MoBrix-ui v3 introduces some breaking changes that makes it not compatible with older MoBrix verions (using different lib versions in parallel is possible, but can cause some unexpected errors). If you are using MoBrix 2.X.X or lower, upgrade it to v3.X.X if possible! Please read the old versions guide if you want to use older MoBrix-ui versions.




Summary




Check out the official MoBrix-ui guide page for more details


MoBrix-ui philosophy

This library is built upon few (but important) concepts:

  • Small library size, to not impact on final app bundle size
  • Few dependencies, to not introduce a bunch of additional packages (that could also introduce bugs or version conflicts with pre-existent packages)
  • Let the user customize every part as desired, but with default values set otherwise, to make every component ready to be used without so many parameters
  • Every component should be integrable into every react app, so their behaviour must be customizable too (with callbacks, for example)

The same concepts are also the base of another project I maintain, MoBrix-engine (check it out, it is also the base of MoBrix-ui guide page !)



Components building process

This library use a standardized process to build every component. As result, every component has a shared initial logic, shared CSS styles and shared properties. Some properties are shared between all components, for a smoother dev experience. In addition, this makes every single component easily re-usable.



Shared Properties


MoBrix-ui components shares some properties:

Parameter
Type
Default
string
/
string
/
boolean
false
boolean
false
string
/
boolean
true
CSSProperties
/
boolean
false
boolean
true
fade-in | slide-in-left | slide-in-right | slide-in-top | shake
/
boolean
true
boolean
true
boolean
false
Record<string, any>
/

Check out the complete components list for more details


CSS variables


MoBrix-ui is globally configurable, with CSS variables. By defining some specific custom CSS variables into your app css, you'll change the UI of all components:

Css variable
Fallback
Default
/
/
linear-gradient(to right, #fff, #ededee, #e6e7e7)
linear-gradient(to right, #2d3748, #1d232e)
/
/
#e9e9e9
#1d232e
/
/
#dfeaf8
#3a3552
/
/
linear-gradient(to right, #ececec, #e1e1e6, #dbdddd)
linear-gradient(to right, #364257, #252d3b)
/
/
#1b1b1b
white
/
/
#413c5c
#dfeaf8
#464545
#464545
/
/
#7785ff
#fb7a10

Check out the complete components list for more details


Reactive components


Some components are designed with a specific structure, to sync their internal state with an external input value. This kind of component handle internally their actual value, using the value parameter as starting point. This let the component to be driven in 2 different way:

  • Internally, Its internal value, when using the component without changing its value parameter from code

  • External, passing the value parameter

So, we have 2 scenarios:

  • If you change the component value using the component (without changing the value parameter), it will be updated internally.

  • If you change the passed value parameter, the component will sync its value with the given one.

A clear example is the Input component. When changing the value parameter, the component will sync its actual value.







Getting started


Installation

If you want to use this library inside your project, just install it:


npm i mobrix-ui



Usage

After installation, you can use every MoBrix-ui component in your app. Run this example to see them in action:

import { Card, Container, Link } from "mobrix-ui";
import { render } from "react-dom";

render(
  <Container animated>
    <Card
      dark={true}
      body={<p>This page is entirely made with MoBrix-ui components !</p>}
      footer={
        <Link to="https://cianciarusocataldo.github.io/mobrix-ui">
          MoBrix-ui page
        </Link>
      }
    />
  </Container>,
  document.getElementById("root"),
);

Try it !


If you want to customize the UI globally, initialize the dedicated CSS variables:

* {
  --mbx-ui-text-color: #f5f5f5;
  --mbx-ui-background-color: #1b1b1b;
}





Tests

Unit tests for every component are located inside tests folder. The test script is executed with pre-defined test command:

npm run test


Authors


License

This project is licensed under the MIT License - see the LICENSE file for details

Package Sidebar

Install

npm i mobrix-ui

Weekly Downloads

5

Version

3.8.1

License

MIT

Unpacked Size

632 kB

Total Files

131

Last publish

Collaborators

  • cianciarusocataldo