Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onfido/castor-react

Package Overview
Dependencies
Maintainers
0
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onfido/castor-react

React component library for Castor.

  • 2.4.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
100
increased by28.21%
Maintainers
0
Weekly downloads
 
Created
Source

Castor React

npm version Bundle size

Castor React is Onfido's design system addition. It provides React component library.

Get started

Install packages

npm install @onfido/castor @onfido/castor-react

Follow Castor instructions for initial setup.

If you plan to use Icon component, also install Castor Icons package:

npm install @onfido/castor-icons

Then (only once) inline the SVG sprite in your app:

import { Icons } from '@onfido/castor-icons';
import React, { Fragment } from 'react';

const App = () => (
  <Fragment>
    <Icons />
    {/* ...anything else e.g. app routes */}
  </Fragment>
);

Use components

Include any Castor component and use it within JSX directly.

import { Button } from '@onfido/castor-react';

Then use within your JSX app. For example, as a "destructive" kind:

import React, { Fragment } from 'react';

const App = () => (
  <Fragment>
    <Button kind="destructive">Destructive Button</Button>
  </Fragment>
);

Please note that Castor is exported as an ECMAScript module targeting ECMAScript 2019.

You may wish to configure your bundler to transpile to a different module syntax, and/or to target a lower ECMAScript version.

For example, you might choose UMD module syntax targeting ES5 if your app needs to support IE11 (please note that Castor is not tested in Internet Explorer).

Use with TypeScript

Components extend base prop types with JSX additions.

When using with TypeScript, always import types from @onfido/castor-react.

Please note that the @onfido/castor-icons package is a peer dependency and is required to be installed for types to work properly. Yarn and newer versions of npm (using lockfile v2) will resolve it, otherwise it must be installed manually even if you don't plan to use icons.

Make custom styled components

You should use props for each component modifier, but it is also possible to create custom styled components.

For example, if you'd like a round button, you could create a component using "full" border-radius token:

import styled from '@emotion/styled';
import { borderRadius } from '@onfido/castor';
import { Button } from '@onfido/castor-react';

const RoundButton = styled(Button)({
  borderRadius: borderRadius('full'),
});

Use for prototyping

If you need to prototype with Castor, the quickest way is to use the generated single file global Castor exposed as IIFE module:

<script src="https://cdn.jsdelivr.net/npm/@onfido/castor-react/prototype.min.js"></script>

You can also use any previously released version (v1.2.0 and up), for example:

<script src="https://cdn.jsdelivr.net/npm/@onfido/castor-react@1.2.0/prototype.min.js"></script>

The same prototype file (not minified) is located on each npm package version.

For modern browsers you may use ECMAScript modules directly via Skypack:

<script type="module">
  import { borderRadius } from 'https://cdn.skypack.dev/@onfido/castor';
  import { Button } from 'https://cdn.skypack.dev/@onfido/castor-react';

  // all other app code
</script>

Also it is easy to use Skypack distributions with Deno.

FAQs

Package last updated on 16 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc