Prerequisites
To use Box UI Elements, you need the following Node and React versions:- Node version:
>=18.18.2 <20.11.0 - React version
>=18.0.0
Migration to React 18
For existing projects based on React 17 or below, check the React 18 migration guide. Once you upgrade React in your project, update thebox-ui-elements package with npm or yarn:
package.json file:
NPM installation
Use this when you are building a React based app and would like to import the components directly into your app at build time.Note The--legacy-peer-depsflag is necessary when installing UI elements withnpmdue to library dependencies.
Learn more on the NPM website
Manual installation
All the UI elements are also available directly from the Box CDN.Versions
Most of the UI elements have 2 distinct versions.- A standard
*.jsfile (e.g.explore.js) that includes React and ReactDOM in the bundle.- Use this when you are not building a React based app or you don’t want to include the components as part of your app’s build process.
- It includes React and ReactDOM libraries.
- The file size of this asset will be larger than the one below.
- A smaller
*.no.react.jsfile (e.g.explore.no.react.js) that does not get bundled with React and ReactDOM.- Use this when both React and ReactDOM libraries are already loaded on the application.
- These libraries expect a React and ReactDOM
>= 16.6and< 18.
Supported Locales
The above asset URLs useen-US. If you want to use another locale, then
replace en-US in the URLs above with any of the following:
en-AU, en-CA, en-GB, da-DK, de-DE, es-ES, fi-FI, fr-CA, fr-FR,
it-IT, ja-JP,, ko-KR, nb-NO, nl-NL, pl-PL, pt-BR, ru-RU,
sv-SE, tr-TR, zh-CN, zh-TW
Self-hosting Content Preview
To serve the Box Content Preview library from your own server, follow these steps.1. Download release
Either fork the repository and check out the version you want to serve or download the specific version as a zip.- Check out a specific version with
git checkout v2.106.0. - Download a specific version as a zip from the releases page.
2. Install dependencies
Install the dependencies and build the library with the following command.3. Serve files
Self-serve everything except for thedev folder from the /dist folder. You
must not alter the folder structure and third-party needs to be in the same
folder as 2.106.0.
For example, if you self-host using a box-assets directory, these URLs must
be accessible:
https://cdn.YOUR_SITE.com/box-assets/2.106.0/en-US/preview.jshttps://cdn.YOUR_SITE.com/box-assets/third-party/text/2.65.0/papaparse.min.jshttps://cdn.YOUR_SITE.com/box-assets/third-party/model3d/1.12.0/three.min.js
