@lidofinance/lido-app-ui
v2.0.1
Published
Components for Lido app/widget products. The other current replacement for the deprecated [`@lidofinance/lido-ui`](https://www.npmjs.com/package/@lidofinance/lido-ui).
Readme
@lidofinance/lido-app-ui
Components for Lido app/widget products. The other current replacement for the deprecated @lidofinance/lido-ui.
Storybook: ui.lido.fi/lido-app-ui
Install
yarn add @lidofinance/lido-app-uiUsage
Import the stylesheet once — it carries the --lido-app-ui-* token layer, the bundled Manrope font, and every component's styles.
import { Button, RichInput, TokenSelector } from '@lidofinance/lido-app-ui'
import '@lidofinance/lido-app-ui/index.css'
function Widget() {
return (
<>
<RichInput label='Amount' placeholder='0' />
<Button variant='primary'>Supply</Button>
</>
)
}Theme providers (ThemeProvider, CookieThemeProvider) are re-exported from @lidofinance/lido-shared-ui. The color tokens follow the data-lido-theme attribute they set, so switching to the dark theme restyles these components. ThemeSwitcher is the app-ui-styled theme toggle, since the shared ThemeToggler relies on --lido-ui-* tokens that app-ui doesn't define. ThemeSwitcher needs CookieThemeProvider; the static ThemeProvider has no toggle, so the switcher renders but clicking does nothing. In SSR apps pass the request cookie as initialThemeName so the label is right on first paint (the icon already follows data-lido-theme in CSS).
Set color: var(--lido-app-ui-color-text-default) and font-family: var(--lido-app-ui-font-family) on body: app-ui sets no default text color.
Optional mono font: --lido-app-ui-font-family-mono (system stack by default) is for keys and hashes (the Operators design renders them in Manrope, so this is opt-in). To use a webfont, load it yourself and override the token on :root. See the Foundations/Setup story for the full setup.
Router links
Every app-ui link (TextLink, NavLink, Button and IconButton with href, SmallCard, Tag with href, Breadcrumbs items with href, Logo with href) renders a plain <a> by default. Wrap the app in LinkProvider to route in-app hrefs through your router's link component; externalComponent does the same for absolute URLs. In-app hash links, download links and links with a non-_self target stay a plain <a>; absolute URLs always go to externalComponent when one is set. Absolute http(s) URLs open in a new tab (target="_blank", rel="noopener noreferrer") unless target is passed. Adapters must be forwardRef components: under React 18 ref is never passed as a prop.
Next.js 13+ — next/link renders its own <a> and forwards its ref, so pass it directly:
import NextLink from 'next/link'
import { LinkProvider } from '@lidofinance/lido-app-ui'
;<LinkProvider component={NextLink}>{children}</LinkProvider>Next.js 12 — next/link needs an <a> child, so wrap it once at module level. Router-only options (e.g. prefetch) are set here, on the component you give to LinkProvider:
import { forwardRef } from 'react'
import type { AppProps } from 'next/app'
import NextLink from 'next/link'
import { LinkProvider, type LinkComponentProps } from '@lidofinance/lido-app-ui'
const AppLink = forwardRef<HTMLAnchorElement, LinkComponentProps>(
({ href, ...rest }, ref) => (
<NextLink href={href} prefetch={false}>
<a ref={ref} {...rest} />
</NextLink>
),
)
export default function App({ Component, pageProps }: AppProps) {
return (
<LinkProvider component={AppLink}>
<Component {...pageProps} />
</LinkProvider>
)
}react-router — it takes to instead of href:
import { forwardRef } from 'react'
import { Link } from 'react-router-dom'
import type { LinkComponentProps } from '@lidofinance/lido-app-ui'
const AppLink = forwardRef<HTMLAnchorElement, LinkComponentProps>(
({ href, ...rest }, ref) => <Link ref={ref} to={href} {...rest} />,
)Router-only options such as prefetch apply to every link: set them inside your LinkProvider component. The per-link linkProps prop and the LinkRouterProps augmentation are deprecated.
Typography
Typography renders the type scale; it sets no color unless asked.
variant:h1,h2,h3,amount,bodyLarge,body(default),description,caption. Also decides the tag; override withas.weight:thin|regular|medium|semibold|bold; overrides the variant's weight on any variant.thinis Manrope ExtraLight (200).color:default,secondary,tertiary,neutral,active,success,warning,error,info,inverse,disabled. Omit to inherit.- Shortcuts:
H1,H2,H3,BodyLarge,Body,Description,Caption.
app-ui sets no default text color, so set it once in the app:
body {
color: var(--lido-app-ui-color-text-default);
}PostCSS mixins: font-amount, font-caption (plus font-h1, font-body, ...). font-rich-input and font-group-name are deprecated.
Deprecated aliases: GroupName (use Caption), variants richInput (use amount) and groupName (use caption).
Customization
Override any token after importing the stylesheet. Non-color tokens (radii, typography, z-index, spacing) are theme-independent and live on :root. Color tokens and --lido-app-ui-shadow-default and --lido-app-ui-shadow-default-filter (they read color tokens) are redeclared on every theme scope, so override them on :root, [data-lido-theme] or per theme, not on :root alone:
:root {
--lido-app-ui-border-radius-card: 20px;
}
:root,
[data-lido-theme='light'] {
--lido-app-ui-color-border-active: #0085ff;
}
[data-lido-theme='dark'] {
--lido-app-ui-color-border-active: #339dff;
}The typography and motion mixins (typography-mixins.css, motion-mixins.css) and breakpoint definitions are published too under @lidofinance/lido-app-ui/styles/*, for products running postcss-mixins / postcss-custom-media. mixinsDir picks up both mixin files. The motion mixins use nested rules, so keep postcss-nested (or target browsers with native CSS nesting):
// postcss.config.mjs
import { createRequire } from 'node:module'
import path from 'node:path'
const require = createRequire(import.meta.url)
const stylesDir = path.dirname(
require.resolve('@lidofinance/lido-app-ui/styles/breakpoints.css'),
)
export default {
plugins: {
'@csstools/postcss-global-data': {
files: [path.join(stylesDir, 'breakpoints.css')],
},
'postcss-mixins': { mixinsDir: stylesDir },
'postcss-nested': {},
'postcss-custom-media': { preserve: false },
},
}Motion
Durations, easings and amplitudes are tokens: enter --lido-app-ui-duration-{fast,base,slow}, exit -exit variants (shorter), --lido-app-ui-easing-*, --lido-app-ui-motion-{shift,shift-lg,scale}, --lido-app-ui-transition-colors. Override them on :root to retune.
Custom components can reuse the mixins (motion-fade, motion-pop, motion-slide, motion-scrim, motion-collapse, motion-press; see the postcss-mixins setup above) on elements keyed by data-state (open / closed) and data-motion (enter / exit). Mixins respect prefers-reduced-motion.
Layout
Breakpoints are desktop-first: -down is (width <= N), -up is (width > N). The queries use range syntax (Safari 16.4+, Chrome 104+, Firefox 63+).
| Name | N |
| ---- | ------ |
| xl | 1280px |
| lg | 1024px |
| md | 900px |
| sm | 600px |
| xs | 400px |
The Sidebar drawer and Logo auto switch at lg. In JS, downQuery('md') / upQuery('md') build the matching matchMedia strings.
In CSS use @media (--lido-app-ui-breakpoint-md-down). Responsive props such as Stack gap take { base, mdDown, smDown, … } (bare md/sm are aliases), where a key applies at that width and below:
<Stack gap={{ base: 24, smDown: 12 }}>{children}</Stack>For @container, which postcss-custom-media doesn't resolve, use raw values such as @container (width <= 400px).
Banner, Card and EmptyState size their layout to their own width via container queries, so give them a definite-width parent; in a shrink-to-fit parent they collapse.
Page shells align to the page gutter, which shrinks on narrow screens: padding-inline: var(--lido-app-ui-page-gutter).
Popovers, tooltips, drawers and modals with withOverlay portal to <body> and stack by --lido-app-ui-z-index-*: header 250, drawer, popover and modal 1000, toast 1050, tooltip 1100. Keep your own app chrome below 1000. Modal inertOthers makes the rest of <body> inert; mark body-level toast or live-region roots with data-lido-overlay-keep to keep them live.
More
This package is part of the lidofinance/ui monorepo — see the repo README for the full package overview, theming, CSS variable customization, and contribution guide.
