Getting started
Last updated
Was this helpful?
Last updated
Was this helpful?
aragonUI is a React library based on aragonDS, the Aragon design system. It aims to provide the elements needed to build Aragon apps that feel native to the Aragon ecosystem.
This tutorial doesn’t cover the creation of your React app nor the way you bundle it, but we recommend
Install aragonUI alongside styled-components in your project:
Copy the aragonUI assets into your assets directory (assuming ./public
):
The only mandatory component that you need to define is . This component sets up the global styles and providers used by other components. We recommend wrapping your entire app with Main:
From that point on, you are ready to start building your app! Let’s go through a simple app to get an overview of the components that are often used in Aragon apps.
Aragon apps can take many shapes, but most tend to follow similar patterns. aragonUI provides components that can be used to build apps that are responsive, accessible, and theme-able by default.
This is how it looks:
The Tokens app and its layout variations.
Let’s start by defining what constitutes an Aragon app.
The Aragon client 1 displaying the Tokens app, in the app area 2.
As you can see, the app is only a part of what a user sees when interacting with the Aragon client, in a way that the app can not interfere with the interface of the client or the other apps.
The Tokens app, featuring the Header 1 and the Split 2 components.
This is how Header can be used inside an app.
There are a few things to note, the first one being the way these props are named. primary
and secondary
are names used by aragonUI components for “slots”. Slots don’t really exist in a technical sense: this is only a name for props that are expecting a subtree to be passed, similar to the way children
works in components accepting a single tree.
That’s pretty much it! We now have a drawer that opens from the right side of the screen (with left to right languages), that can be closed by the user. We’re ready to move to the next part of the app.
Three components used in this app: DataView 1, a Box 2, and another Box with Distribution 3.
Box is a straightforward component that renders as a surface (as defined by aragonDS) which can optionally have a heading. It is commonly used in either slot of Split.
To implement the “Token info” component, we are going to define some custom styles and use some specific text colors. To ensure your app is compatible with any aragonUI theme, make sure you always use colors from the useTheme()
hook.
Now that we implemented the different parts of the app, this is how the main component would look like in its final state:
And this is it for the tutorial. Of course, many components were not covered here, the idea being to provide an overview of an Aragon app's structure when it uses aragonUI.
This section takes the to illustrate the different elements that constitute a typical Aragon app and how they might be put together. Rather than implementing every behaviour in the Tokens app, we are going to focus on the structure of the app and its main components. To get an idea of what the final app looks like, you can visit the .
Two components that are commonly used in Aragon apps are and . Header handles the main title of an app and its main action. Split creates a two column layout when the available horizontal space allows it. On smaller screens, it renders as a single column. As we continue, we will also be using the and the components.
If you run this app, you might also notice that the component displays either a text label or an icon, adapting to the viewport size automatically. Some components adapt to where they are, which is the case here. , being in follows the behavior defined by aragonDS about how it should adapt to different viewport sizes. These variations make it easy to follow the patterns defined by aragonDS, and are always documented and overridable.
To make things a bit more interesting, we are going to add a that opens from the “Add tokens” header button. The SidePanel component can be inserted anywhere, as long as it is inside the Main tree.
Let’s define the layout, right after the Header, to get an idea of what the structure will look like:
Like , the component defines two slots using the same primary
and secondary
names.
is a powerful component that can be used to represent data in various ways, adapting itself to the available space. We are going to use it for the “holders” table.
To get more details about DataView and how it works, please have a look at its
Now that TokenInfoBox is done, there is one last bit remaining, which is the “ownership distribution” box. Luckily for us, the component will do most of the work.