vael-ui v0.5.7

Styling and cascade layers

vael-ui ships in @layer ui-components. Unlayered CSS always beats layered CSS, whatever its specificity, so an unlayered base reset overrides vael-ui’s styles without any warning. To prevent that, put your base styles in a layer too, and order that layer first.

Layer order

/* your app's main stylesheet, such as style.css */
@layer app-base, ui-components;

@layer app-base {
  * { margin: 0; box-sizing: border-box; }
  button, input, textarea, select { font: inherit; }
}
// main.ts
import './style.css'  // your base layer, loads first

Here, import order only sets the layer position. An unlayered override always wins, wherever it loads.

When you override one component on purpose, with the ui prop or a Tailwind utility, you want your rule to win. Keep that CSS unlayered, as it is by default. See Using with Tailwind.

CSS variables

vael-ui’s colors, radii, shadows and default motion timings come from CSS custom properties. Override any of them in your own unlayered stylesheet:

/* your own global stylesheet, unlayered so it always wins */
html { font-size: 14px; }
:root {
  --ui-primary: #6366f1;
  --ui-radius: 6px;
}

ConfigProvider’s theme sets primary, danger, radius and fontSize. Without fontSize, components follow your html font size, form fields included. If that’s under 16 px, call preventFocusZoom() once so iPhones don’t zoom into fields. Set the other tokens with CSS.

Colors

VariableDefaultDescription
--ui-primary#18181bPrimary action color: buttons, links and focus accents.
--ui-primary-hover#27272aHover color for primary.
--ui-primary-contrast#fafafaText and icon color on top of primary.
--ui-muted#f4f4f5Subtle background for secondary surfaces.
--ui-muted-hover#e4e4e7Hover color for muted backgrounds.
--ui-dangeroklch(0.586 0.253 26)Destructive and error color.
--ui-danger-hover—Hover color for this color.
--ui-danger-contrast#ffffffText and icon color on top of this color.
--ui-successoklch(71.335% 0.15901 160.899)Success color.
--ui-success-hover—Hover color for this color.
--ui-success-contrast#ffffffText and icon color on top of this color.
--ui-warningoklch(0.666 0.179 58.315)Warning color.
--ui-warning-hover—Hover color for this color.
--ui-warning-contrast#ffffffText and icon color on top of this color.
--ui-info#2563ebInformational color.
--ui-info-hover#1d4ed8Hover color for this color.
--ui-info-contrast#ffffffText and icon color on top of this color.
--ui-surface#ffffffBase background for panels, cards and dialogs.
--ui-text#18181bPrimary text color.
--ui-text-muted#71717aSecondary text color.
--ui-border#e4e4e7Default border color.
--ui-border-strong#d4d4d8Stronger border color for emphasized edges.
--ui-overlayrgb(0 0 0 / 0.4)Backdrop color behind dialogs and other modals.

Shape

VariableDefaultDescription
--ui-radius10pxBase corner radius for controls such as buttons, inputs and badges.
--ui-radius-surfacemin(var(--ui-radius), 1rem)Corner radius for large surfaces such as panels, cards and tables. It’s capped, so a large radius doesn’t turn them into pills.

Elevation and layering

VariableDefaultDescription
--ui-z-dialog50Stacking order for dialogs.
--ui-z-popover55Stacking order for popovers, menus and selects.
--ui-z-toast60Stacking order for toasts.
--ui-z-tooltip70Stacking order for tooltips, the topmost layer.
--ui-panel-shadow0 0 0 1px …, 0 8px 24px …, 0 24px 48px …Drop shadow for floating panels.

Motion

VariableDefaultDescription
--ui-ease-outcubic-bezier(0.23, 1, 0.32, 1)Default easing for elements entering and settling.
--ui-ease-in-outcubic-bezier(0.77, 0, 0.175, 1)Easing for movement on screen, such as resizing and repositioning.
--ui-ease-drawercubic-bezier(0.32, 0.72, 0, 1)Easing for slides from an edge, such as drawers and sheets.
--ui-duration-drawer500msHow long a drawer or sheet takes to slide open.
--ui-duration-press160msDuration of press feedback.
--ui-duration-enter200msDuration of opening and entering.
--ui-duration-exit150msDuration of closing and leaving.
--ui-duration-indicator120msHow long the hover highlight in lists and menus takes to glide to the next row.
--ui-duration-indicator-wide200msThe same glide for the wide rows of MenuList, Tree and DataTable.
--ui-ease-indicatorvar(--ui-ease-out)Easing of the hover highlight.
--ui-indicator-bgvar(--ui-muted)Color of the hover highlight. Set it instead of a row’s :hover background, which would paint over the highlight.
--ui-duration-tooltip125msDuration of a tooltip opening.
--ui-duration-tooltip-exit100msDuration of a tooltip closing.
--ui-duration-toast400msDuration of a toast entering.
--ui-duration-toast-exit200msDuration of a toast leaving.
--ui-ease-toasteaseEasing for toasts.
--ui-toast-offset1remDistance from the screen edge to the toast stack.

Before 0.2.0 only

Each component imports its own styles. Add the import below only if you’re on a version before 0.2.0 or want all styles loaded at once.
// main.ts
import './style.css'       // your base layer, loads first
import 'vael-ui/style.css' // every component's CSS at once

Advanced

Most apps don’t need this. It’s for building your own controls that plug into vael-ui.